From d626cf59fb888ea45caf333a9f8bf7d367ae83ab Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 17 Apr 2024 15:56:07 +0200 Subject: [PATCH] Less issue with psalm (#619) --- composer.json | 3 +-- psalm-baseline.xml | 17 ----------------- psalm.xml | 1 - src/Collection/AuditedCollection.php | 20 +++++++++++--------- tests/Fixtures/Issue/Issue308User.php | 4 +--- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index 723ca513..67a2a5a8 100644 --- a/composer.json +++ b/composer.json @@ -47,8 +47,7 @@ "symfony/security-bundle": "^5.4 || ^6.2 || ^7.0", "symfony/twig-bundle": "^5.4 || ^6.2 || ^7.0", "symfony/var-dumper": "^5.4 || ^6.2 || ^7.0", - "vimeo/psalm": "^5.7", - "weirdan/doctrine-psalm-plugin": "^2.8" + "vimeo/psalm": "^5.7" }, "conflict": { "doctrine/doctrine-bundle": "<2.7", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 618351cc..5733a34c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -6,21 +6,4 @@ Controller - - - - - - - - - - - - - - - - - diff --git a/psalm.xml b/psalm.xml index 8e1e5863..b8ca2546 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,7 +10,6 @@ - diff --git a/src/Collection/AuditedCollection.php b/src/Collection/AuditedCollection.php index 546b8968..f5d8749a 100644 --- a/src/Collection/AuditedCollection.php +++ b/src/Collection/AuditedCollection.php @@ -80,7 +80,9 @@ public function __construct( } /** - * @return true + * @return void + * + * @phpstan-ignore-next-line https://github.com/phpstan/phpstan-doctrine/pull/560 */ #[\ReturnTypeWillChange] public function add(mixed $element) @@ -293,9 +295,10 @@ public function exists(\Closure $p) /** * @return Collection * - * @phpstan-param \Closure(T, int|string):bool $p - * @psalm-param \Closure(T=):bool $p - * @psalm-return Collection + * @phpstan-param \Closure(T, TKey):bool $p + * @phpstan-return Collection + * + * @psalm-suppress MoreSpecificImplementedParamType https://github.com/doctrine/collections/pull/411 */ #[\ReturnTypeWillChange] public function filter(\Closure $p) @@ -323,9 +326,7 @@ public function forAll(\Closure $p) * * @phpstan-template U * @phpstan-param \Closure(T):U $func - * @psalm-return Collection - * - * @psalm-suppress ImplementedParamTypeMismatch,InvalidArgument + * @phpstan-return Collection */ #[\ReturnTypeWillChange] public function map(\Closure $func) @@ -339,7 +340,9 @@ public function map(\Closure $func) * @return array> * * @phpstan-param \Closure(TKey, T):bool $p - * @psalm-return array{0: Collection, 1: Collection} + * @phpstan-return array{0: Collection, 1: Collection} + * + * @psalm-suppress MoreSpecificImplementedParamType https://github.com/doctrine/collections/pull/411 */ #[\ReturnTypeWillChange] public function partition(\Closure $p) @@ -454,7 +457,6 @@ public function count() * @return T|null * * @phpstan-return T|null - * @psalm-return mixed|null */ #[\ReturnTypeWillChange] public function findFirst(\Closure $p) diff --git a/tests/Fixtures/Issue/Issue308User.php b/tests/Fixtures/Issue/Issue308User.php index 0f212924..6ee6dce2 100644 --- a/tests/Fixtures/Issue/Issue308User.php +++ b/tests/Fixtures/Issue/Issue308User.php @@ -64,11 +64,9 @@ public function addChild(self $child): void */ public function getChildren(): ReadableCollection { - $activeChildren = $this->children->filter( + return $this->children->filter( static fn (self $user): bool => $user->isActive() ); - - return $activeChildren; } public function getParent(): ?self