From 262604219d74d0e8a8feb9ce4893f6de0957f21b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:55:29 +0000 Subject: [PATCH 1/3] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/composer.lock b/composer.lock index 65fe787c..c2a93a5d 100644 --- a/composer.lock +++ b/composer.lock @@ -3147,16 +3147,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.8", + "version": "10.1.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "84838eed9ded511f61dc3e8b5944a52d9017b297" + "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/84838eed9ded511f61dc3e8b5944a52d9017b297", - "reference": "84838eed9ded511f61dc3e8b5944a52d9017b297", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a56a9ab2f680246adcf3db43f38ddf1765774735", + "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735", "shasum": "" }, "require": { @@ -3213,7 +3213,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.8" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.9" }, "funding": [ { @@ -3221,7 +3221,7 @@ "type": "github" } ], - "time": "2023-11-15T13:31:15+00:00" + "time": "2023-11-23T12:23:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5593,16 +5593,16 @@ }, { "name": "vimeo/psalm", - "version": "5.15.0", + "version": "5.16.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "5c774aca4746caf3d239d9c8cadb9f882ca29352" + "reference": "2897ba636551a8cb61601cc26f6ccfbba6c36591" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/5c774aca4746caf3d239d9c8cadb9f882ca29352", - "reference": "5c774aca4746caf3d239d9c8cadb9f882ca29352", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/2897ba636551a8cb61601cc26f6ccfbba6c36591", + "reference": "2897ba636551a8cb61601cc26f6ccfbba6c36591", "shasum": "" }, "require": { @@ -5627,8 +5627,8 @@ "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", "sebastian/diff": "^4.0 || ^5.0", "spatie/array-to-xml": "^2.17.0 || ^3.0", - "symfony/console": "^4.1.6 || ^5.0 || ^6.0", - "symfony/filesystem": "^5.4 || ^6.0" + "symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" }, "conflict": { "nikic/php-parser": "4.17.0" @@ -5650,7 +5650,7 @@ "psalm/plugin-phpunit": "^0.18", "slevomat/coding-standard": "^8.4", "squizlabs/php_codesniffer": "^3.6", - "symfony/process": "^4.4 || ^5.0 || ^6.0" + "symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0" }, "suggest": { "ext-curl": "In order to send data to shepherd", @@ -5663,7 +5663,7 @@ "psalm-refactor", "psalter" ], - "type": "library", + "type": "project", "extra": { "branch-alias": { "dev-master": "5.x-dev", @@ -5695,10 +5695,11 @@ "static analysis" ], "support": { + "docs": "https://psalm.dev/docs", "issues": "https://github.com/vimeo/psalm/issues", - "source": "https://github.com/vimeo/psalm/tree/5.15.0" + "source": "https://github.com/vimeo/psalm" }, - "time": "2023-08-20T23:07:30+00:00" + "time": "2023-11-22T20:38:47+00:00" }, { "name": "webimpress/coding-standard", From d56192f2b2e0840799314b68f21d639702e8deff Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 28 Nov 2023 11:32:50 +0000 Subject: [PATCH 2/3] Bump dev dependencies Signed-off-by: George Steel --- composer.json | 12 ++++++------ composer.lock | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 2a4dcb31..97c61496 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index c2a93a5d..c7fd41ee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "221f176618f7611133dd0af3c3032429", + "content-hash": "60b00d26fc51fc8ef303809bc1f450bb", "packages": [ { "name": "laminas/laminas-filter", From 5026cc014e96236c73559b0b2012a61f586a84aa Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 28 Nov 2023 11:35:57 +0000 Subject: [PATCH 3/3] QA: Fix a range of newly discovered psalm issues Signed-off-by: George Steel --- psalm-baseline.xml | 24 ++++++++++----------- src/Annotation/AbstractBuilder.php | 19 ++++++---------- src/Annotation/AnnotationBuilder.php | 2 +- src/Annotation/AttributeBuilder.php | 2 +- src/Element/Collection.php | 7 +++--- src/Fieldset.php | 2 +- test/Annotation/AbstractBuilderTestCase.php | 6 ++---- test/Element/DateTest.php | 2 ++ 8 files changed, 30 insertions(+), 34 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4e63f677..966d560a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,12 +1,12 @@ - + - - is_string($entity) - + + $filterSpec + @@ -93,9 +93,7 @@ - object instanceof Traversable]]> is_array($object) - object)]]> $object @@ -119,6 +117,11 @@ bindValues + + + $value + + $value @@ -126,6 +129,9 @@ static function ($value) use ($unselectedValue) { + + $value + @@ -187,9 +193,6 @@ $spec $validationGroup - - $values[$cKey] - $this $this @@ -365,9 +368,6 @@ - - assertNotNull - allowEmpty getFilterChain diff --git a/src/Annotation/AbstractBuilder.php b/src/Annotation/AbstractBuilder.php index 2b61e621..5000c16d 100644 --- a/src/Annotation/AbstractBuilder.php +++ b/src/Annotation/AbstractBuilder.php @@ -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; @@ -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; diff --git a/src/Annotation/AnnotationBuilder.php b/src/Annotation/AnnotationBuilder.php index 7d9f9563..15bf3161 100644 --- a/src/Annotation/AnnotationBuilder.php +++ b/src/Annotation/AnnotationBuilder.php @@ -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 { diff --git a/src/Annotation/AttributeBuilder.php b/src/Annotation/AttributeBuilder.php index 1c5841d7..32b41133 100644 --- a/src/Annotation/AttributeBuilder.php +++ b/src/Annotation/AttributeBuilder.php @@ -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 { diff --git a/src/Element/Collection.php b/src/Element/Collection.php index ee572da8..1790621c 100644 --- a/src/Element/Collection.php +++ b/src/Element/Collection.php @@ -4,6 +4,7 @@ namespace Laminas\Form\Element; +use ArrayAccess; use Laminas\Form\ElementInterface; use Laminas\Form\Exception; use Laminas\Form\Fieldset; @@ -32,7 +33,7 @@ class Collection extends Fieldset */ public const DEFAULT_TEMPLATE_PLACEHOLDER = '__index__'; - /** @var array */ + /** @var array|ArrayAccess */ protected $object; /** @@ -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]); } } diff --git a/src/Fieldset.php b/src/Fieldset.php index acb5dad4..543a0885 100644 --- a/src/Fieldset.php +++ b/src/Fieldset.php @@ -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), )); } diff --git a/test/Annotation/AbstractBuilderTestCase.php b/test/Annotation/AbstractBuilderTestCase.php index ed0b3f7d..99e3efaa 100644 --- a/test/Annotation/AbstractBuilderTestCase.php +++ b/test/Annotation/AbstractBuilderTestCase.php @@ -33,7 +33,6 @@ use PHPUnit\Framework\TestCase; use Throwable; -use function count; use function getenv; abstract class AbstractBuilderTestCase extends TestCase @@ -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' => [ @@ -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); diff --git a/test/Element/DateTest.php b/test/Element/DateTest.php index 8bbf3e63..1a7c1fbe 100644 --- a/test/Element/DateTest.php +++ b/test/Element/DateTest.php @@ -25,6 +25,8 @@ final class DateTest extends TestCase { /** * Stores the original set timezone + * + * @var non-empty-string */ private string $originaltimezone;