Various arrays improvements#5523
Merged
Merged
Conversation
When assigning into a nested array dim fetch like `$ret[$val]['cat2'] = 'blah2'` with a union offset `$val`, the outer `$ret` gets merged via `setOffsetValueType()` which widens value types with a union. The directly tracked expression `$ret[$val]` in the Scope holds more precise information, but it was being re-derived from the widened outer `$ret` via `getOffsetValueType()` when computing additional expressions and when drilling down for subsequent levels. This caused previously-set keys to become optional again on the next chained assignment. - When drilling into nested levels in `produceArrayDimFetchAssignValueToWrite`, prefer `Scope::getType()` for intermediate dim fetches that are tracked in Scope, instead of re-deriving from the parent array. - When producing `additionalExpressions`, use the intermediate value computed during the reverse assignment loop instead of drilling into the widened outer container. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
4ba0604 to
c7b767a
Compare
c7b767a to
1cca345
Compare
Closes phpstan/phpstan#7893 Closes phpstan/phpstan#2294 Closes phpstan/phpstan#14448 Closes phpstan/phpstan#11146 Closes phpstan/phpstan#11533 Closes phpstan/phpstan#13699 Closes phpstan/phpstan#13623 Closes phpstan/phpstan#12653 Closes phpstan/phpstan#3795 Closes phpstan/phpstan#14336 Closes phpstan/phpstan#11820 Closes phpstan/phpstan#13000 Closes phpstan/phpstan#13272 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closes phpstan/phpstan#13304 Closes phpstan/phpstan#13643 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 23, 2026
Contributor
|
Wwooaarr 😍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes phpstan/phpstan#7893
Closes phpstan/phpstan#2294
Closes phpstan/phpstan#14448
Closes phpstan/phpstan#11146
Closes phpstan/phpstan#11533
Closes phpstan/phpstan#13699
Closes phpstan/phpstan#13623
Closes phpstan/phpstan#13304
Closes phpstan/phpstan#12653
Closes phpstan/phpstan#3795
Closes phpstan/phpstan#14336
Closes phpstan/phpstan#11820
Closes phpstan/phpstan#13000
Closes phpstan/phpstan#13643
Closes phpstan/phpstan#13272