rector/rector-generator

Generate Rector rules from command line

Fund package maintenance!
tomasvotruba

Installs: 173 718

Dependents: 5

Suggesters: 0

Security: 0

Stars: 5

Watchers: 4

Forks: 2

Open Issues: 0

Type:rector-extension

0.4.4 2021-11-02 23:40 UTC

This package is auto-updated.

Last update: 2021-11-02 23:40:32 UTC


README

Every Rector rule requires test, test fixtures, config and the rule.

- rules/Package/Rector/Category/SomeRector.php

- rules-tests/Package/Rector/Category/SomeRector/SomeRectorTest.php
- rules-tests/Package/Rector/Category/SomeRector/config/confured_rule.php
- rules-tests/Package/Rector/Category/SomeRector/Fixture/some_fixture.php.inc

~80 % of the code is repeated text - namespace, Rector name, default test setup etc.

This package will save your typing the repeated code and gives you more space for writing refactor() method logic.

How to Generate a new Rule?

  1. Initialize rector-recipe.php config
vendor/bin/rector init-recipe
  1. Complete parameters in rector-recipe.php to design your new rule

  2. Run command

vendor/bin/rector generate

That's it :)