Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 1.15 KB

rector_recipe.md

File metadata and controls

52 lines (43 loc) · 1.15 KB

Generating your own Rector from a Recipe

1. Configure a Rector Recipe in rector.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:
            # put the main node first, it is used to create the namespace
            - "Assign"
        description: "Removes unneeded $a = $a assignments"
        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

vendor/bin/rector create-rector

There is also a shortcut command:

vendor/bin/rector c

That's it :)