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
Array shape is oversimplified when defined with a variable key #9907
I know that this is basically an array combination. But unfortunately I can't find a "good" option. Unfortunately, the proposed solution for my example feels wrong, because variation_count will not contain any change information.
The new error appears to resolve the phpstan type, unfortunately not yet as an intersection.
In my case at least it doesn't work without a clean intersection. but I don't know whether phpstan can process this internally, since I think it works with type elimination.
Maybe one of the developers can say something about it.
Activity
nusphere commentedon Sep 25, 2023
I recognized a similar problem.
https://phpstan.org/r/32f37b9f-fdd9-472b-a040-9218f14b62e5
the optimal return value is:
or
I know that this is basically an array combination. But unfortunately I can't find a "good" option. Unfortunately, the proposed solution for my example feels wrong, because
variation_countwill not contain any change information.Unfortunately that feels wrong.
nusphere commentedon Sep 25, 2023
also i tried to use own phpstan-type to combine them as intersections, but this also fails
https://phpstan.org/r/d0127c2e-8c01-4738-9f3f-54c29220349c
phpstan-bot commentedon Oct 1, 2023
@nusphere After the latest push in 1.11.x, PHPStan now reports different result with your code snippet:
Full report
nusphere commentedon Oct 2, 2023
The new error appears to resolve the phpstan type, unfortunately not yet as an intersection.
In my case at least it doesn't work without a clean intersection. but I don't know whether phpstan can process this internally, since I think it works with type elimination.
Maybe one of the developers can say something about it.
Add regression test for #9907
Add regression test for #9907
Add regression test for #9907
Add regression tests for related issues fixed by constant array shape…
phpstan-bot commentedon Mar 14, 2026
Closed via merging phpstan/phpstan-src#5193
github-actions commentedon Apr 15, 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.