From c54c557e02bda20bc84883ab1d0f94319f124dfe Mon Sep 17 00:00:00 2001 From: Ludwig Rafelsberger Date: Fri, 22 Mar 2024 11:05:00 +0100 Subject: [PATCH] Fix psalm errors: remove override of template type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/doctrine/collections/issues/368 for the same issue in doctrine/collections which has been fixed there. The issue happens when using ->contains(). Running psalm emits > InvalidArgument - Argument 1 of Doctrine\ORM\PersistentCollection::contains > expects > TMaybeContained:fn-doctrine\common\collections\readablecollection::contains > as mixed, but … provided. Solution: we should either not define @template TMaybeContained or re-define the complete psalm docblock from ReadableCollection. Repairing the docblock necessitates an update to the psalm baseline: one "known issue" is no longer an issue and thus removed. --- psalm-baseline.xml | 3 --- src/LazyCriteriaCollection.php | 6 +++--- src/PersistentCollection.php | 5 ----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7a3b729e849..d04835c1e85 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -462,9 +462,6 @@ - - - diff --git a/src/LazyCriteriaCollection.php b/src/LazyCriteriaCollection.php index 5580f971eb0..48040922616 100644 --- a/src/LazyCriteriaCollection.php +++ b/src/LazyCriteriaCollection.php @@ -76,11 +76,11 @@ public function isEmpty() } /** - * {@inheritDoc} - * * Do an optimized search of an element * - * @template TMaybeContained + * @param mixed $element The element to search for. + * + * @return bool TRUE if the collection contains $element, FALSE otherwise. */ public function contains($element) { diff --git a/src/PersistentCollection.php b/src/PersistentCollection.php index 4470a64a5cd..c94bb77496b 100644 --- a/src/PersistentCollection.php +++ b/src/PersistentCollection.php @@ -412,11 +412,6 @@ public function containsKey($key): bool return parent::containsKey($key); } - /** - * {@inheritDoc} - * - * @template TMaybeContained - */ public function contains($element): bool { if (! $this->initialized && $this->getMapping()['fetch'] === ClassMetadata::FETCH_EXTRA_LAZY) {