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

[DX] Deprecate NonPhpRectorInterface, the only rule and its file processor, to make Rector handle exlusively PHP #4761

Merged
merged 4 commits into from
Aug 10, 2023

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Aug 10, 2023

Rector as any other tools like ECS, PHPStan, PHP-CS-Fixer, PHPUnit, Pest etc. focuses on working with PHP files.
Yet, in some cases it can change yaml, twig or latte files too. While using PHP classes in templates is a bad practise, it cannot be avoided like in Symfony configs.

That's why added a "special file processor" that was able to handle some non-php files too. This is not-so-known feature, that works in a magic way:

  • those files are processed only if passed into the explicit paths, e.g.
# this will process them
bin/rector config src

# this will not
bin/rector src
  • it only renames class names matching regex pattern:
# this is skipped
use App\SomeType;

class: SomeType
  • it only renames classes, not constant, nor method names etc.

This magic is hidden deep and it leads to unnexpected cases, that some class are renamed and some not.
Instead these files should be skipped completely and Rector handle PHP files only. This will show same behavior as other CLI tools mention above and make you handle non-PHP files yourself in consistent way 👍

That's why I've decided to remove this magic feature before going Rector 1.0 stable

@TomasVotruba TomasVotruba changed the title tv keep rector on php [WIP] tv keep rector on php Aug 10, 2023
@TomasVotruba TomasVotruba force-pushed the tv-keep-rector-on-php branch from ed2e49b to 959bb88 Compare August 10, 2023 19:07
@TomasVotruba TomasVotruba force-pushed the tv-keep-rector-on-php branch from b31453d to b22c2ff Compare August 10, 2023 19:15
@TomasVotruba TomasVotruba changed the title [WIP] tv keep rector on php [DX] Deprecate NonPhpRectorInterface, the only rule and its file processor, to make Rector handle exlusively PHP instead Aug 10, 2023
@TomasVotruba TomasVotruba changed the title [DX] Deprecate NonPhpRectorInterface, the only rule and its file processor, to make Rector handle exlusively PHP instead [DX] Deprecate NonPhpRectorInterface, the only rule and its file processor, to make Rector handle exlusively PHP Aug 10, 2023
@TomasVotruba TomasVotruba merged commit 1659ca2 into main Aug 10, 2023
@TomasVotruba TomasVotruba deleted the tv-keep-rector-on-php branch August 10, 2023 19:22
@staabm
Copy link
Contributor

staabm commented Aug 10, 2023

I like this direction 👍

@TomasVotruba
Copy link
Member Author

@staabm Thanks for feedback, I feel this has been a mistake past 2 years 🙏 Time to fix bad design choices

@samsonasik
Copy link
Member

/cc @grandmaster44 @sabbelasichon FYI

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