Skip to content

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

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

Merged
merged 3 commits into from
Apr 14, 2025

Conversation

rdavaillaud
Copy link
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

@@ -20,7 +20,7 @@
/**
* Retrieves data from a persistence layer.
*
* @template T of object
* @template T of object|array
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

right!

Copy link
Contributor Author

@rdavaillaud rdavaillaud Apr 11, 2025

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.

@soyuka soyuka merged commit c12d3dc into api-platform:4.1 Apr 14, 2025
76 of 78 checks passed
@rdavaillaud
Copy link
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