Keep the class body in its existing order when merging - #164
Merged
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
|
Thank you. |
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.
The preparatory PR from #163. No 8.6 here, this only makes the order stable.
Why members move
compareStatements()rebuilds a class body by category:filterStatementsByVersion()returns[$oldStmts, $newStmts]and the caller reads it as[$untouchedStmts, $oldStmts]. So anything that has aged out of the window is written before every method,wherever it used to sit.
Your
DateTimeexample is exactly this.__wakeupcarries#[\Until('8.5')], so itsuntilIdis 80499.Coming from 8.4 that is not below 80400 and it stays put. Coming from 8.5 it is below 80500, it becomes
untouched, and it jumps to the top of the class.
That also means the churn grows at each step, because more members age out every version.
The change
Walk the old body in its own order. Each member is replaced by its merged version in place, and whatever
the new version adds is appended after. Aged-out members keep their position instead of being hoisted.
Effect
Measured on the 8.5 to 8.6 run, which is what #163 does:
The 16 reordering files are simply gone, and the other two columns are unchanged, so nothing else moved.
DateTime.php,DateInterval.phpandDatePeriod.phpare no longer touched at all.The committed stubs were generated by the old order, so the first run after this reorders them once. That
is the one-time cost, and it is why this goes first.
No stubs are committed here, the workflow commits those on
main.