Finalize classes in a safe way. We first look for those, that should be skipped:
- classes who are in parent position
- Doctrine entities by docblocks and attribute
composer require tomasvotruba/finalize --dev
- First run command, that detects parent classes, entities etc.
vendor/bin/finalize detect src/ tests/
It will generate .finalize.json
files with all found classes, that should be skipped.
- Run Rector with config that contains
TomasVotruba\Finalize\Rector\FinalizeClassRector
rule.
Rector uses data from .finalize.json
to keep used classes non final and finalize only the safe ones:
vendor/bin/rector process --config vendor/tomasvotruba/finalize/config/prepared-rector.php
Do not keep this run in your main rector.php
. Family map can change with any new class, e.g. some new class will come and it will be extended, and Rector would not finalize valid class.