Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock file maintenance #250

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
"laminas/laminas-escaper": "^2.13",
"laminas/laminas-eventmanager": "^3.12",
"laminas/laminas-filter": "^2.33",
"laminas/laminas-i18n": "^2.24",
"laminas/laminas-i18n": "^2.24.1",
"laminas/laminas-modulemanager": "^2.15.0",
"laminas/laminas-recaptcha": "^3.6",
"laminas/laminas-recaptcha": "^3.7",
"laminas/laminas-servicemanager": "^3.22.1",
"laminas/laminas-session": "^2.16",
"laminas/laminas-text": "^2.10.0",
"laminas/laminas-validator": "^2.42",
"laminas/laminas-session": "^2.17",
"laminas/laminas-text": "^2.11.0",
"laminas/laminas-validator": "^2.43",
"laminas/laminas-view": "^2.32",
"phpunit/phpunit": "^10.4.2",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.15"
"vimeo/psalm": "^5.16"
},
"conflict": {
"doctrine/annotations": "<1.14.0",
Expand Down
35 changes: 18 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
<files psalm-version="5.16.0@2897ba636551a8cb61601cc26f6ccfbba6c36591">
<file src="src/Annotation/AbstractBuilder.php">
<InvalidArrayOffset>
<code><![CDATA[$params['elementSpec']['spec']['type']]]></code>
</InvalidArrayOffset>
<RedundantConditionGivenDocblockType>
<code>is_string($entity)</code>
</RedundantConditionGivenDocblockType>
<NullArgument>
<code>$filterSpec</code>
</NullArgument>
</file>
<file src="src/Annotation/AttributeBuilder.php">
<NullArgument>
Expand Down Expand Up @@ -93,9 +93,7 @@
</file>
<file src="src/Element/Collection.php">
<DocblockTypeContradiction>
<code><![CDATA[$this->object instanceof Traversable]]></code>
<code>is_array($object)</code>
<code><![CDATA[is_array($this->object)]]></code>
</DocblockTypeContradiction>
<ImplementedParamTypeMismatch>
<code>$object</code>
Expand All @@ -119,13 +117,21 @@
<code>bindValues</code>
</TooManyArguments>
</file>
<file src="src/Element/MultiCheckbox.php">
<NoValue>
<code>$value</code>
</NoValue>
</file>
Comment on lines +120 to +124
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NoValue issue here and in Select are the result of better type inference for setting value options via setAttributes, which is deprecated and invalid according to the docblock type of array<string, scalar>

<file src="src/Element/Select.php">
<MissingClosureParamType>
<code>$value</code>
</MissingClosureParamType>
<MissingClosureReturnType>
<code>static function ($value) use ($unselectedValue) {</code>
</MissingClosureReturnType>
<NoValue>
<code>$value</code>
</NoValue>
</file>
<file src="src/ElementFactory.php">
<InvalidStringClass>
Expand Down Expand Up @@ -187,9 +193,6 @@
<code>$spec</code>
<code>$validationGroup</code>
</ArgumentTypeCoercion>
<InvalidArrayOffset>
<code>$values[$cKey]</code>
</InvalidArrayOffset>
<LessSpecificReturnStatement>
<code>$this</code>
<code>$this</code>
Expand Down Expand Up @@ -365,9 +368,6 @@
</PossiblyNullArgument>
</file>
<file src="test/Annotation/AbstractBuilderTestCase.php">
<DocblockTypeContradiction>
<code>assertNotNull</code>
</DocblockTypeContradiction>
<PossiblyUndefinedMethod>
<code>allowEmpty</code>
<code>getFilterChain</code>
Expand Down
19 changes: 7 additions & 12 deletions src/Annotation/AbstractBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,12 @@ public function getEventManager(): EventManagerInterface
*/
public function getFormSpecification($entity): ArrayObject
{
if (! is_object($entity)) {
if (
(is_string($entity) && (! class_exists($entity))) // non-existent class
|| (! is_string($entity)) // not an object or string
) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an object or valid class name; received %s',
__METHOD__,
var_export($entity, true)
));
}
if (! is_object($entity) && ! is_string($entity) || (is_string($entity) && ! class_exists($entity))) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an object or valid class name; received %s',
__METHOD__,
var_export($entity, true)
));
}

$this->entity = $entity;
Expand All @@ -138,7 +133,7 @@ public function getFormSpecification($entity): ArrayObject
* second element is the input filter specification.
*
* @param class-string|object $entity
* @return array
* @return array{0: ArrayObject, 1: ArrayObject}
*/
abstract protected function getFormSpecificationInternal($entity): array;

Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/AnnotationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class AnnotationBuilder extends AbstractBuilder
*
* @param object|class-string $entity
* @throws ReflectionException
* @return array
* @return array{0: ArrayObject, 1: ArrayObject}
*/
protected function getFormSpecificationInternal($entity): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Annotation/AttributeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct()
*
* @param object|class-string $entity
* @throws ReflectionException
* @return array
* @return array{0: ArrayObject, 1: ArrayObject}
*/
protected function getFormSpecificationInternal($entity): array
{
Expand Down
7 changes: 4 additions & 3 deletions src/Element/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Laminas\Form\Element;

use ArrayAccess;
use Laminas\Form\ElementInterface;
use Laminas\Form\Exception;
use Laminas\Form\Fieldset;
Expand Down Expand Up @@ -32,7 +33,7 @@ class Collection extends Fieldset
*/
public const DEFAULT_TEMPLATE_PLACEHOLDER = '__index__';

/** @var array */
/** @var array|ArrayAccess */
protected $object;

/**
Expand Down Expand Up @@ -603,8 +604,8 @@ protected function replaceTemplateObjects(): void
}

foreach ($fieldsets as $fieldset) {
$i = $fieldset->getName();
if (isset($this->object[$i])) {
$i = (string) $fieldset->getName();
if ($i !== '' && isset($this->object[$i])) {
$fieldset->setObject($this->object[$i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public function setObject($object)
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an object argument; received "%s"',
__METHOD__,
$object
get_debug_type($object),
));
}

Expand Down
6 changes: 2 additions & 4 deletions test/Annotation/AbstractBuilderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use PHPUnit\Framework\TestCase;
use Throwable;

use function count;
use function getenv;

abstract class AbstractBuilderTestCase extends TestCase
Expand Down Expand Up @@ -282,7 +281,6 @@ public function testAllowsComposingMultipleChildEntitiesWithEntityBind(): void
self::assertInstanceOf(InputFilterProviderFieldset::class, $target);
$this->validateEntityFilterSpec($target->getInputFilterSpecification());

self::assertNull($entity->child);
$form->bind($entity);
$form->setData([
'child' => [
Expand All @@ -291,8 +289,8 @@ public function testAllowsComposingMultipleChildEntitiesWithEntityBind(): void
],
]);
self::assertTrue($form->isValid());
self::assertNotNull($entity->child);
self::assertEquals(2, count($entity->child));
self::assertIsArray($entity->child);
self::assertCount(2, $entity->child);
self::assertInstanceOf(EntityObjectPropertyHydrator::class, $entity->child[0]);
self::assertEquals('email@test.com', $entity->child[0]->password);
self::assertEquals('user', $entity->child[0]->username);
Expand Down
2 changes: 2 additions & 0 deletions test/Element/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ final class DateTest extends TestCase
{
/**
* Stores the original set timezone
*
* @var non-empty-string
*/
private string $originaltimezone;

Expand Down