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

Psalm annotations ArrayCollection->contains() incorrect #368

Closed
Hikariii opened this issue May 8, 2023 · 2 comments · Fixed by #369
Closed

Psalm annotations ArrayCollection->contains() incorrect #368

Hikariii opened this issue May 8, 2023 · 2 comments · Fixed by #369

Comments

@Hikariii
Copy link

Hikariii commented May 8, 2023

ArrayCollection->contains() defines a psalm template for TMaybeContained but does not define a param and return-type for that template. This gives the following psalm error:

Psalm output (using commit [d4c5f85](https://github.com/vimeo/psalm/commit/d4c5f85)): 

ERROR: [InvalidArgument](https://psalm.dev/004) - 68:17 - Argument 1 of ArrayCollection::contains expects TMaybeContained:fn-readablecollection::contains as mixed, but 3 provided

Psalm.dev example:
https://psalm.dev/r/aae16c4dc8

ArrayCollection either needs to not define @template TMaybeContained or re-define the psalm docblock from ReadableCollection completely.

ArrayCollection->indexOf() re-defines all psalm docblocks and works correctly because of that.

annervisser added a commit to annervisser/collections that referenced this issue May 8, 2023
The override of this template type causes Psalm to throw an error
whenever contains is called: https://psalm.dev/r/a2f9439bd2

Removing the extra type works as expected: https://psalm.dev/r/de5f58d52f

Fixes doctrine#368
annervisser added a commit to annervisser/collections that referenced this issue May 11, 2023
The override of this template type causes Psalm to throw an error
whenever contains is called: https://psalm.dev/r/a2f9439bd2

Removing the extra type works as expected: https://psalm.dev/r/de5f58d52f

Fixes doctrine#368
@Seros
Copy link

Seros commented Jul 24, 2023

Hey,
could we please have a new release to resolve this for people who are using Psalm ^5.10 to make their and our CI pipeline work again?

@derrabus
Copy link
Member

Sure, done. 🙂

tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 20, 2024
See doctrine/collections#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.

We should either not define @template TMaybeContained or re-define
the psalm docblock from ReadableCollection completely.
tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 20, 2024
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.
tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 20, 2024
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.
tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 21, 2024
See doctrine/collections#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.
tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 21, 2024
See doctrine/collections#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.
tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 21, 2024
See doctrine/collections#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.
tantegerda1 added a commit to tantegerda1/orm that referenced this issue Mar 22, 2024
See doctrine/collections#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants