Repository navigation
[Core] Drop file positions on reprinted nodes copied from another file - #8928
Merged
Merged
Conversation
The shared Cache service keeps the directory it was first built with, while the entry count read the current cache_dir parameter. Depending on test order, the two pointed at different directories.
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.
Fixes rectorphp/rector#9963
ClassDependencyManipulator::resolveConstruct()clones the parent__construct()and passes it toNodeFactory::createReprintedNode(). That clearedORIGINAL_NODE, but keptstartFilePos/endFilePos/token positions from the parent's file.On scope refresh, BetterReflection scans for a trailing param comment from
endFilePos + 1in the child's source. When the parent constructor sits deeper in its file than the child file is long, this crashes withFailed to scan trailing parameter comment.When the offset fits, it reads unrelated bytes of the child.Now
createReprintedNode()also drops file and token positions. BetterReflection skips the scan whenendFilePosis missing.Test: a test-only rule adds a constructor dependency to a child whose parent constructor is far into another file. Fails on
mainwith the crash, passes with the fix.