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
Reading an optional key of a large array shape with ?? returns oversized-array with other value types (regression in 2.3.0) #15459
Since 2.3.0, reading an optional key of a large array shape with ?? can return the wrong type. The type gets &oversized-array and, when the shape has other keys, the value types of those keys (here string). 2.2.16 returns the declared type.
It happens when the shape has more than about 256 entries if nested keys are counted: 197 string keys plus 20 optional array{currency: string, price: float}|null keys (197 + 20 × 3 = 257) triggers it, 156 + 30 optional (246) does not. 86 optional nested keys alone (258) give (array{currency: string, price: float}&oversized-array)|null; 85 (255) give the correct type.
The array is not built in the code. It is only the declared @return type of a function, and the code only reads two keys.
array{currency: string, price: float}|null, as in 2.2.16.
Effect on real code
In our project a value object returns a shape with about 160 keys and about 30 optional nested keys. Code that reads two or three optional keys with ?? and then accesses an offset now gets Cannot access offset 'currency' on mixed. and Parameter #1 $num of function number_format expects float, mixed given. (about 40 new errors). Analysis of one such file also became much slower, and the total memory use went from below 1 GB to about 1.25 GB. I did not confirm that the memory increase has the same cause.
Did PHPStan help you today? Did it make you happy in any way?
Yes. It found the dead assignments and unused variables that 2.3 now reports.
Activity
mergeable commentedon Oct 11, 2026
This bug report is missing a link to reproduction at phpstan.org/try.
It will most likely be closed after manual review.
bmdevel commentedon Oct 11, 2026
Auto-generated answer by Claude Opus 5.5.
Added the playground link to the description: https://phpstan.org/r/088dccaa-717e-4859-a9e9-2699bf7fe933 (it shows
Dumped type: (array{currency: string, price: float}&oversized-array)|string|null).