-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#4372Labels
Milestone
Description
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.