rector / rector-generator
Generate Rector rules from command line
Fund package maintenance!
tomasvotruba
Installs: 897 449
Dependents: 8
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 5
Open Issues: 0
Type:rector-extension
Requires
- php: >=8.1
- illuminate/container: ^10.20
- nette/utils: ^3.2
- nikic/php-parser: ^4.17
- symfony/console: ^6.3
- symfony/filesystem: ^6.3
- symfony/finder: ^6.3
- webmozart/assert: ^1.11
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.3
- rector/rector: *
- rector/rector-src: dev-main
- symplify/easy-coding-standard: ^12.0
- symplify/easy-testing: ^11.1
- symplify/phpstan-extensions: ^11.0
- symplify/phpstan-rules: ^12.0
- symplify/vendor-patches: ^11.0
- tomasvotruba/class-leak: ^0.1.3
- tomasvotruba/cognitive-complexity: ^0.1.1
- tomasvotruba/type-coverage: ^0.2.1
- tomasvotruba/unused-public: 0.3.2.72
- tracy/tracy: ^2.10
This package is auto-updated.
Last update: 2023-09-04 16:23:48 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?
- 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 :)