Rector is a FLOSS tool that instantly upgrades and refactors the PHP code of any PHP 5.3+ code.
https://github.com/rectorphp/rector
Documentation:
https://getrector.com/documentation
Configuration to be tested (please feel free to update as you test more):
```
name=rector.php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {
// directories to be touched by Rector
$rectorConfig->paths([
__DIR__ . '/conf',
__DIR__ . '/externals',
__DIR__ . '/resources',
__DIR__ . '/scripts',
__DIR__ . '/src',
__DIR__ . '/support',
__DIR__ . '/webroot',
]);
// https://getrector.com/documentation/import-names// actions to be executed by rector
// $rectorConfig->importNames();sets( [
// trying to add support to this PHP version and below (PHP 8.1)
Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81,
] );
// trying to set the current (and minimum) PHP version to be adopted as base
// https://getrector.com/documentation/php-version-features
// https://we.phorge.it/book/phorge/article/installation_guide/
$rectorConfig->phpVersion(PhpVersion::PHP_55);
// trying to respect obsolete Phorge's code styles previous to PHP 5.5
$rectorConfig->skip([
// for some reasons we want long "array()" instead of "[]"...
// https://we.phorge.it/book/contrib/article/php_coding_standards/
Rector\Php54\Rector\Array_\LongArrayToShortArrayRector::class,
]);
$// https://getrectorConfig->sets( [.com/documentation/troubleshooting-parallel
LevelSetList::UP_TO_PHP_81,// trying to don't destroy my computer
] );// defaults: 120, 16, 20
$rectorConfig->parallel( 120, 8, 20 );
};
```
To run it locally:
```
vendor/bin/rector process --debug
```
WARNING:NOTE: This could melt your CPU; nuke your storage; kill polar bears. Don't think that Greta Thunberg will be happy about this. Try only on an SSD. Try on `arcanist` first, notTry only on Phorgean SSD.
Online demo:
https://getrector.com/demo
== Running on Arcanist ===
Some errors that maybe should be addressed when tryin to execute `vendor/bin/rector process` in Arcanist:
```
[ERROR] Could not process "arcanist/src/config/option/ArcanistAliasesConfigOption.php" file, due to:
"System error: "Syntax error, unexpected T_STRING, expecting T_VARIABLE6"
Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 54
```
For the records line 54 is just the end of the file. There are multiple errors like that.