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.
- Initialize
rector-recipe.php
config
vendor/bin/rector init-recipe
-
Complete parameters in
rector-recipe.php
to design your new rule -
Run command
vendor/bin/rector generate
That's it :)