Referee is a simple tool for refactoring legacy PHP code, based on the strategies presented in Paul M. Jones' book Modernizing Legacy Applications in PHP.
The preferred installation method is composer;
composer require-dev elvanto/referee
A list of valid commands can be found by running vendor/bin/referee list
. Before executing any of the commands, it is recommended that you are using a version control system with a clean working copy. This will ensure that any unwanted changes can be rolled back without affecting prior changes.
Using the --dry-run
flag with any of the commands will result in changes being reported without any files being updated.
The extract-class
command takes the name of a file containing function definitions and generates a namespaced class with equivalent static methods. Any usages of the original functions in the <search>
directories will be replaced with appropriate static method calls on the newly generated class. All files are changed in place.
Further commands will be added in future.