Skip to content
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

[Transform] Do not create a new node if the existing node is already the correct one on AttributeKeyToClassConstFetchRector #5328

Merged
merged 2 commits into from
Dec 16, 2023

Conversation

SerethiX
Copy link
Contributor

@SerethiX SerethiX commented Dec 5, 2023

As stated in rectorphp/rector#8341 replacing the node, even if it leads to the same reference, forces a change, that is not required.
I added a check to skip recreating the node if the class reference stays the same.

During testing I found out, that resolving the value works differently based on if the referenced class actually exists or not.
So the added testfile currently passes the test, but only because the resolved value is not present as a key in the map.

Is there already a real class with constants that could be used, to make it a real test?

@SerethiX SerethiX marked this pull request as ready for review December 5, 2023 19:54
@samsonasik
Copy link
Member

The rule is configurable, you need to register in the config test when needed https://github.com/rectorphp/rector-src/blob/main/rules-tests/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector/config/configured_rule.php

@samsonasik
Copy link
Member

Please create at least 2 commits, first for failing test case, second for the fix so we know what it tries to fix

@SerethiX
Copy link
Contributor Author

SerethiX commented Dec 7, 2023

@samsonasik Splitted into two commits as requested.

@SerethiX SerethiX reopened this Dec 12, 2023
@samsonasik
Copy link
Member

Please update PR title to something like:

[Transform] Do not create a new node if the existing node is already the correct one on AttributeKeyToClassConstFetchRector

@SerethiX SerethiX changed the title Do not create a new node if the existing node is already the correct one [Transform] Do not create a new node if the existing node is already the correct one on AttributeKeyToClassConstFetchRector Dec 15, 2023
@samsonasik samsonasik merged commit 227e974 into rectorphp:main Dec 16, 2023
@samsonasik
Copy link
Member

Thank you @SerethiX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants