Skip to content

Commit

Permalink
Fix psalm errors: remove override of template type
Browse files Browse the repository at this point in the history
See doctrine/collections#368 for the same
issue in doctrine/collections which has been fixed there.

The issue happened when using ->contains(). Running psalm emitted

  > InvalidArgument - Argument 1 of Doctrine\ORM\PersistentCollection::contains
  > expects
  > TMaybeContained:fn-doctrine\common\collections\readablecollection::contains
  > as mixed, but … provided.

We should either not define @template TMaybeContained or re-define
the psalm docblock from ReadableCollection completely.

Repairing the docblock necessitates an update to the psalm baseline:
one "known issue" is no longer an issue and could thus be removed.
  • Loading branch information
tantegerda1 committed Mar 20, 2024
1 parent 55c4845 commit 096182a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 12 deletions.
3 changes: 0 additions & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@
</UnsupportedReferenceUsage>
</file>
<file src="src/Internal/Hydration/ObjectHydrator.php">
<InvalidArgument>
<code><![CDATA[$element]]></code>
</InvalidArgument>
<PossiblyFalseArgument>
<code><![CDATA[$index]]></code>
</PossiblyFalseArgument>
Expand Down
4 changes: 0 additions & 4 deletions src/LazyCriteriaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ public function isEmpty(): bool
}

/**
* {@inheritDoc}
*
* Do an optimized search of an element
*
* @template TMaybeContained
*/
public function contains(mixed $element): bool
{
Expand Down
5 changes: 0 additions & 5 deletions src/PersistentCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ public function containsKey(mixed $key): bool
return parent::containsKey($key);
}

/**
* {@inheritDoc}
*
* @template TMaybeContained
*/
public function contains(mixed $element): bool
{
if (! $this->initialized && $this->getMapping()->fetch === ClassMetadata::FETCH_EXTRA_LAZY) {
Expand Down

0 comments on commit 096182a

Please sign in to comment.