phpstan-doctrine icon indicating copy to clipboard operation
phpstan-doctrine copied to clipboard

getResult() should return a list, not an array

Open yguedidi opened this issue 2 years ago • 1 comments

When using listType: true feature toggle from bleeding edge, and using the list<*> type as the return type of a repository method that returns the result of getResult(), we have an error Method MyRepository::myMethod() should return list<*> but returns array<*>.

In DQL, any query that does not use INDEX BY returns a list I think, so better be more precise :)

yguedidi avatar Feb 01 '23 14:02 yguedidi

Note that this must not always return a list (which is what was done and reverted in 1.3.31). It must be done based on the analysis of the query.

stof avatar Feb 01 '23 15:02 stof