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

Add a command to generate new rules #298

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

GeniJaho
Copy link
Collaborator

Why

It's very difficult to add new rules to the repository, every time you have to copy an existing one and change everything.

I think we should implement a way to generate the base scaffolding needed for writing a new rule.

Modifying the CustomRuleCommand in the core Rector repository would make it unnecessarily complicated (rectorphp/rector-src#6676).

Changes

  • Ported an implementation of the original command without all the options and dependencies. The reason is I couldn't make RectorConfig run user-defined commands. I think they need to be configured in the core Rector implementation somehow.
  • Added a new directory called Commands, registered in autoload-dev so it doesn't make it to the users' vendor.
  • Added a new composer script to make it easy to run the command, called composer make:rule.
  • Added two new dev dependencies to work with the filesystem, but they can be refactored out since the use-case is very limited.
  • To Do: cleanup, remove dependencies, generate configurable rules, add to Readme, etc

@peterfox what do you think? Can we use something like this? Is there a better way to generate new rules?

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.

1 participant