-
-
Notifications
You must be signed in to change notification settings - Fork 424
Introduce FileNode to handle file-level changes #7728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
3af10dd to
4263eff
Compare
6d9c96d to
652b580
Compare
ec1edaa to
a4b2b44
Compare
samsonasik
reviewed
Dec 22, 2025
a4b2b44 to
4af1f44
Compare
samsonasik
reviewed
Dec 22, 2025
41954f4 to
3fc5f1e
Compare
samsonasik
reviewed
Dec 22, 2025
samsonasik
reviewed
Dec 22, 2025
samsonasik
reviewed
Dec 22, 2025
3fc5f1e to
e53b2fa
Compare
083efb3 to
cbc1c5e
Compare
samsonasik
reviewed
Dec 22, 2025
…clareStrictTypesRector
…n-namespaced file
6208ebe to
ff771b0
Compare
samsonasik
approved these changes
Dec 22, 2025
Member
Author
|
Let's ship it 👍 |
This was referenced Dec 23, 2025
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.
At the moment, there is no way to handle file-level operations, like adding
declare(...)to a file. We hack around this usingbeforeTraverse(), which is internal part ofphp-parserand should be avoided.This PR adds a
FileNodeto fix that. It allows to make changes directly inrefactor()method as it should be 👍It also opens-up possibility to have a single place to manage use statements (now handled by couple meta services). Next step will be marking
beforeTraverse()andafterTraverse()finalinAbstractRector, to keep BC promise only forRectorInterface(as it should be from the start).This PR keeps BC as much as possible and adds reporting about deprecation to in custom rules.
Use of
FileWithoutNamespace::classnode: https://github.com/search?q=%22FileWithoutNamespace%3A%3Aclass%22+NOT+is%3Afork&type=codeTodo
FileWithoutNamespacestill workgetNodeTypes()and explain upgrade pathRelated package PRs
FileNoderector-doctrine#474