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

DoctrineTargetEntityStringToClassConstantRector should keep self::class #8081

Closed
OskarStark opened this issue Jul 23, 2023 · 7 comments
Closed
Labels

Comments

@OskarStark
Copy link
Contributor

Bug Report

Subject Details
Rector version e.g. v0.17.6

self::class should not be refactored

Minimal PHP Code Causing Issue

I tried to reproduce the error in a demo here:
https://getrector.com/demo/f95978a5-496b-4e3a-bcfe-e8fe06141988

but it does not refactor anything, while in my code I see:
CleanShot 2023-07-23 at 21 53 40

Expected Behaviour

self::class is valid and should be kept, because if this gets refactored to App\Entity\Deadline, my PHP-CS-Fixer comes and fixes it back to self::class, so I end up in an infinite loop.

I am unable to create a failing test case :-(

@OskarStark OskarStark added the bug label Jul 23, 2023
@OskarStark OskarStark changed the title DoctrineTargetEntityStringToClassConstantRector should keep self DoctrineTargetEntityStringToClassConstantRector should keep self::class Jul 23, 2023
@TomasVotruba
Copy link
Member

TomasVotruba commented Jul 23, 2023

Hi, the screenshot shows 3 rules being active at the same time. Could you re-run your local rector.php with only DoctrineTargetEntityStringToClassConstantRector? What is the output?

I made a test fixture for only DoctrineTargetEntityStringToClassConstantRector but is passes, so it will be combination of rules causing this.

What's your minimal rector.php setup causing this?

@OskarStark
Copy link
Contributor Author

In the end I skipped this rule and everything is fine, even when skipping the other mentioned rules and activating only the DoctrineTargetEntityStringToClassConstantRector, I receive:
CleanShot 2023-07-23 at 22 13 25

I enabled all the three rules here, but still no error:
https://getrector.com/demo/a916553a-9f8a-4bde-9b5a-05c12e924a3b

Not sure if the demo really gets, that it is a Doctrine entity class... 🤔

@TomasVotruba
Copy link
Member

My test fixture is passing well, and demo is working the same 👍


Could you share minimal rector.php that is causing this? I think there will be missconfiguration in your autoloading.

@OskarStark
Copy link
Contributor Author

@samsonasik
Copy link
Member

@TomasVotruba
Copy link
Member

Ah, I see :) I'll make a new release then. Thanks @samsonasik 👍

@OskarStark
Copy link
Contributor Author

Thanks 👏

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

No branches or pull requests

3 participants