You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need an sequential integer type such that array<sequential-int, string> can safely resolve to list<string> #12576
We heavily use Laravel Collections in our code, but this has started causing conflicts in places where list<...>s are expected. Despite calling ->values()->all() (which ensures the data is a list), phpstan still thinks it's an array<int, string>:
I've tried updating the values method to return static<int<0, max>, TValue> but this didn't work either. Would it be a good idea to create a new sequential-int type that represents this and can be safely converted to list<TValue>?
Or is there a better way to solve this with PHPDocs? I know it would be possible to create a Larastan extension that checks if ->all()/->toArray() is called on ->values() and could update the return type accordingly, but that feels rather overblown...
Thanks!
Did PHPStan help you today? Did it make you happy in any way?
sequential-int does not make sense as the type of a single key. Being a list is a feature impacting the array itself, not something that impacts the type of a single key.
Activity
stof commentedon Feb 11, 2025
sequential-intdoes not make sense as the type of a single key. Being a list is a feature impacting the array itself, not something that impacts the type of a single key.calebdw commentedon Feb 11, 2025
Do you have any thoughts on how to solve this? I'd rather not have to wrap the collection in
array_values...ondrejmirtes commentedon Feb 12, 2025
Some prior art in other languages would be useful here, although PHP arrays are so weird and unique I doubt any exists.
Two ideas:
Add regression tests for issues fixed by unresolved template arguments
Add regression tests for issues fixed by unresolved template arguments
Add regression tests for issues fixed by unresolved template arguments
Add regression tests for issues fixed by unresolved template arguments
Add regression tests for issues fixed by unresolved template arguments
Add regression tests for issues fixed by unresolved template arguments
Add regression tests for issues fixed by unresolved template arguments
github-actions commentedon Oct 9, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.