Bug report
When assigning values to a nested array within a typed array, since 2.1.12 the nested array type transitions from array{} to *NEVER* to mixed as values are assigned and then reports an offsetAccess.nonOffsetAccessible error.
The issue appears to be triggered by the type annotation on the parent array @var array<string, mixed>, removing the annotation makes the issue disappear.
Code snippet that reproduces the problem
https://phpstan.org/r/2894f0cc-6c77-48bf-952c-5aa5677c6913
Expected output
- PHPStan should maintain the array type information through the assignments
- The type should be something like
array<string, int> after the assignments
- Subsequent array access should be valid
Actual behaviour
- Initial empty array is correctly typed as
array{}
- After first assignment, type becomes
*NEVER*
- After second assignment, type becomes
mixed
Did PHPStan help you today? Did it make you happy in any way?
Yes, it catches refactoring errors all time I couldn't ship as safely without it.
Bug report
When assigning values to a nested array within a typed array, since 2.1.12 the nested array type transitions from
array{}to*NEVER*tomixedas values are assigned and then reports anoffsetAccess.nonOffsetAccessibleerror.The issue appears to be triggered by the type annotation on the parent array
@var array<string, mixed>, removing the annotation makes the issue disappear.Code snippet that reproduces the problem
https://phpstan.org/r/2894f0cc-6c77-48bf-952c-5aa5677c6913
Expected output
array<string, int>after the assignmentsActual behaviour
array{}*NEVER*mixedDid PHPStan help you today? Did it make you happy in any way?
Yes, it catches refactoring errors all time I couldn't ship as safely without it.