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
Fix spurious nullCoalesce.offset error after nested ?? with nullable types
- Fixed false positive where `$x[0] ?? null` was flagged as unnecessary after
`$x[0]['bar'] ?? null` when the inner type was nullable (e.g. list<array<?string>>)
- Root cause: revertNonNullability used specifyExpressionType which recursively
creates expression type holders for parent arrays as side effects, leaving
spurious Yes-certainty expression types for intermediate array dim fetches
- Added sideEffectSave flag to EnsuredNonNullabilityResultExpression to distinguish
target saves (null actually removed) from side-effect saves (type changed by
recursive parent narrowing)
- After reverting, unset expression types for side-effect saves that didn't exist
in the original scope
- Added unsetExpressionType method to MutatingScope
- New regression test in tests/PHPStan/Rules/Variables/data/bug-13921.php
Closesphpstan/phpstan#13921
0 commit comments