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 might not have offset, if array is deep #13637
Activity
ondrejmirtes commentedon Oct 6, 2025
Easy work around is to do a single assignment: https://phpstan.org/r/a89086d8-c68a-4ecd-967a-c2ec872ea2c0
But yeah, it should not report an error, especially when it works for two levels nesting, but not for three.
ondrejmirtes commentedon Oct 6, 2025
/cc @staabm
Fix deeply nested array assignments marking keys as optional in loops
Fix deeply nested array offset tracking losing required keys
Fix deep nested array dim assignment marking keys as optional
Fix deep nested array dim assignment marking keys as optional
phpstan-bot commentedon May 20, 2026
@imhdCePo After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
Preserve integer range bounds for sealed array values in loop general…
phpstan-bot commentedon May 21, 2026
@imhdCePo After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:
Full report
Function DoesNotWork() should return array<int, array<int, array<int, array{abc: int, def: int, ghi: int}>>> but returns array<int<0, 4>, non-empty-array<int, non-empty-array<int<1, 9>, array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}>>>.phpstan-bot commentedon Sep 11, 2026
@imhdCePo After the latest push in 2.3.x, PHPStan now reports different result with your code snippet:
Full report
Variable $l is never read.Function DoesNotWork() should return array<int, array<int, array<int, array{abc: int, def: int, ghi: int}>>> but returns array<int<0, 4>, non-empty-array<int, non-empty-array<int<1, 9>, array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}>>>.Variable $k is never read.Variable $l is never read.phpstan-bot commentedon Sep 11, 2026
@ondrejmirtes After the latest push in 2.3.x, PHPStan now reports different result with your code snippet:
Full report
Variable $l is never read.phpstan-bot commentedon Sep 15, 2026
@imhdCePo After the latest push in 2.3.x, PHPStan now reports different result with your code snippet:
Full report
Variable $l is never read.Function DoesNotWork() should return array<int, array<int, array<int, array{abc: int, def: int, ghi: int}>>> but returns array<int<0, 4>, non-empty-array<int<0, 8>, non-empty-array{3?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 1?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 2?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 4?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 5?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 6?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 7?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, 8?: array{abc: int<0, 4>, def?: int<0, 4>, ghi?: int<0, 4>}, ...}>>.Variable $k is never read.Variable $l is never read.