Skip to content

Safe way to finalize PHP - find classes with children, entities first to create guard map, finalize rest then with Rector

License

Notifications You must be signed in to change notification settings

staabm/finalize

 
 

Repository files navigation

Finalize

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

Install

composer require tomasvotruba/finalize --dev

Usage

  1. 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.


  1. 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.

About

Safe way to finalize PHP - find classes with children, entities first to create guard map, finalize rest then with Rector

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 94.7%
  • Shell 5.3%