Repository navigation
Merge degraded members into one oversized array only when each is an array - #7217
Merged
Merged
Conversation
…array
OversizedArrayWidening merged its results into one general array when
each member held a shape it degraded. A member such as
bool|int|list{...}|string holds shapes without being an array, and its
iterable key and value types are *ERROR*, so the merged array was
non-empty-array<*ERROR*, *ERROR*>&oversized-array. Such a member now
gives its arrays to the merged array and keeps the rest beside it.
bug-6948.php (`$row[] = $row` fifteen times) took the same path: $row
was non-empty-list<non-empty-array<*ERROR*>&oversized-array>, and is now
the nested non-empty-list<int|non-empty-list<int|...>> its values are.
Computing with those nested lists is the price of the new numbers.
Amp-Thread-ID: https://ampcode.com/threads/T-01a21c4a-f4aa-73fb-ab5d-2ac321ba792a
ondrejmirtes
force-pushed
the
oversized-widening-non-array-member
branch
from
November 27, 2026 13:35
95764e5 to
bc52dd7
Compare
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.
OversizedArrayWidening merged its results into one general array when each member held a shape it degraded. A member such as
bool|int|list{...}|string(the values of shapes merged byArrayUnion::mergeIntoGeneralArray()) holds shapes without being an array, so its iterable key and value types are*ERROR*and the merged array becamenon-empty-array<*ERROR*, *ERROR*>&oversized-array. Such members now stay apart.Regression from 4268fd0, found in openemr/openemr by the phpstan/phpstan integration tests.
Closes phpstan/phpstan#15861
The benchmark
bug-6948.phptook the same path and always measured a broken type (non-empty-list<non-empty-array<*ERROR*>&oversized-array>, also before 4268fd0). It now infers the nestednon-empty-list<int|non-empty-list<int|...>>, which costs 692.1M instead of 211.9M instructions; the new numbers are accepted in this PR. The other failing benchmark shards (bug-7214, ConstantArrayTypeBench, TypeCombinatorBench) fail the same way on 2.3.x.