Skip to content

fix(state): update generic template type variable in ProviderInterface#7083

Merged
soyuka merged 3 commits into
api-platform:4.1from
rdavaillaud:provider-interface-phpstan
Apr 14, 2025
Merged

fix(state): update generic template type variable in ProviderInterface#7083
soyuka merged 3 commits into
api-platform:4.1from
rdavaillaud:provider-interface-phpstan

Conversation

@rdavaillaud

Copy link
Copy Markdown
Contributor
Q A
Branch? 4.1
Tickets #5303
License MIT

The actual phpDoc @template definition does not allow the provider to return arrays (like Doctrine mixed results).

This tiny PR avoid PHPStan (and probably Psalms too) to throw some errors like the following

@param for parameter \$collectionProvider is not subtype of template type T of object of interface

This was initially a feedback by @nesl247 for Psalm and not really fixed by #5024

* Retrieves data from a persistence layer.
*
* @template T of object
* @template T of object|array

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be iterable instead of array ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right!

@rdavaillaud rdavaillaud Apr 11, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, no, it's not an iterable, as it's really an array of compound data.
Like, in my case, in Doctrine Orm, I have a DQL query like SELECT o, some_scalar as somevalue ... which produce an array with the object/entity in the first array element, and the scalar in 'somevalue' array element.

So it's not an iterable.

@rdavaillaud

Copy link
Copy Markdown
Contributor Author

reverted, see this comment for explanation

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 this pull request may close these issues.

2 participants