rector/docs/RectorRecipe.md

49 lines
1.1 KiB
Markdown
Raw Normal View History

2020-03-21 12:10:24 +01:00
# Generating your own Rector from a Recipe
2019-11-26 02:25:45 +01:00
2020-03-21 12:10:24 +01:00
## 1. Configure a Rector Recipe in `rector.yaml`
2019-11-26 02:25:45 +01:00
```yaml
# rector.yaml
parameters:
rector_recipe:
# run "bin/rector create" to create a new Rector + tests from this config
package: "Celebrity"
name: "SplitToExplodeRector"
node_types:
2020-03-21 12:10:24 +01:00
# put the main node first, it is used to create the namespace
2019-11-26 02:25:45 +01:00
- "Assign"
2020-03-21 12:10:24 +01:00
description: "Removes unneeded $a = $a assignments"
2019-11-26 02:25:45 +01:00
code_before: >
<?php
class SomeClass
{
public function run()
{
$a = $a;
}
}
code_after: >
<?php
class SomeClass
{
public function run()
{
}
}
source: # e.g. link to RFC or headline in upgrade guide, 1 or more in the list
- ""
set: "celebrity" # e.g. symfony30, target config to append this rector to
```
## 2. Generate it
```bash
vendor/bin/rector create
```
That's it :)