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

[PHP8.3] add new rectors for get_class()/get_parent_class() without arguments #6405

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

cabbey
Copy link
Contributor

@cabbey cabbey commented Oct 30, 2024

This adds two new rules to the PHP8.3 collection for replacing the newly deprecated calls to get_class() and get_parent_class() without passing an object argument to them.

I choose to use __CLASS__ as the replacement for get_class() as it has wider support, going back to 5.0, than the alternative of self::class, which only goes back to 5.4.

I choose to use parent::class as the replacement for get_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.)

@samsonasik
Copy link
Member

You need to rebase latest main branch to fix unit test:

git checkout main
git pull [email protected]:rectorphp/rector-src.git main
git checkout add-get-class-rectors
git rebase main
git push --force origin add-get-class-rectors

@cabbey
Copy link
Contributor Author

cabbey commented Oct 30, 2024

You need to rebase latest main branch to fix unit test:

git checkout main
git pull [email protected]:rectorphp/rector-src.git main
git checkout add-get-class-rectors
git rebase main
git push --force origin add-get-class-rectors

ugh, I just realized I keep git pulling and it's pulling from my fork on git hub instead of the correct upstream... no wonder things haven't changed all week. 🤦 Will get this rebased shortly.

@cabbey
Copy link
Contributor Author

cabbey commented Oct 30, 2024

even with the correct main pulled (d246d27), still a failure in an unrelated test, both on main and on my rebased branch:

1) Rector\Tests\Issues\AutoImport\AutoImportTest::test with data set #1 ('/Volumes/Git/rector-src/tests...hp.inc')
Failed on fixture file "doctrine_deep_annotation.php.inc"
...

@samsonasik
Copy link
Member

composer update :)

@cabbey
Copy link
Contributor Author

cabbey commented Oct 30, 2024

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. :)

@cabbey cabbey marked this pull request as draft October 30, 2024 19:17
@cabbey
Copy link
Contributor Author

cabbey commented Oct 30, 2024

converting to draft while I re-work the rules... may take a few days given my other workload.

@cabbey cabbey marked this pull request as ready for review November 4, 2024 21:54
Copy link
Member

@samsonasik samsonasik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TomasVotruba
Copy link
Member

Thank you 🥳

@TomasVotruba TomasVotruba merged commit f7ea3db into rectorphp:main Nov 4, 2024
36 checks passed
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.

3 participants