[PHP8.3] add new rectors for get_class()/get_parent_class() without arguments#6405
Merged
TomasVotruba merged 3 commits intorectorphp:mainfrom Nov 4, 2024
Merged
Conversation
Member
|
You need to rebase latest main branch to fix unit test: git checkout main
git pull git@github.com:rectorphp/rector-src.git main
git checkout add-get-class-rectors
git rebase main
git push --force origin add-get-class-rectors |
Contributor
Author
ugh, I just realized I keep |
…ass() without arguments
2a2e573 to
6ad00a7
Compare
Contributor
Author
|
even with the correct main pulled (d246d27), still a failure in an unrelated test, both on main and on my rebased branch: |
Member
|
composer update :) |
Contributor
Author
|
TA-DA! all clean on both main and my branch now. Thanks for that tip! I guess I'm spoiled by having all of our repos at work automatically do that whenever git detects a change to the composer.* files. :) |
samsonasik
reviewed
Oct 30, 2024
samsonasik
reviewed
Oct 30, 2024
rules/Php83/Rector/FuncCall/RemoveGetParentClassNoArgsRector.php
Outdated
Show resolved
Hide resolved
samsonasik
reviewed
Oct 30, 2024
Contributor
Author
|
converting to draft while I re-work the rules... may take a few days given my other workload. |
57573db to
79a25e6
Compare
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.
This adds two new rules to the PHP8.3 collection for replacing the newly deprecated calls to
get_class()andget_parent_class()without passing an object argument to them.I choose to use
__CLASS__as the replacement forget_class()as it has wider support, going back to 5.0, than the alternative ofself::class, which only goes back to 5.4.I choose to use
parent::classas the replacement forget_parent_class()as it felt like the most direct logical mapping.These are also my first rectors, I welcome feedback on them. (I have since writing these a couple months back written a few more significantly more complex ones that are unique to our codebase, these were my first foray to learn how they work.)