Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Rector run Failed:
{ "totals": { "changed_files": 0, "errors": 1 }, "errors": [ { "message": "System error: \"PhpParser\\PrettyPrinterAbstract::p(): Argument #1 ($node) must be of type PhpParser\\Node, null given, called in /var/www/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php on line 612\"\nRun Rector with \"--debug\" option and post the report here: https://github.com/rectorphp/rector/issues/new", "file": "/var/www/storage/demo/cfuin1hxzuep582ypa66/rector_analyzed_file.php", "line": 571 } ] }
Run Rector on your code to see what it can do for you:
PHP snippet to change
<?php final class DemoFile { private function getSort() { $sort = null; switch('tel') { case 'number': case 'percentage': case 'integer': case 'price': case 'decimal': $sort = SORT_NUMERIC; break; case 'string': case 'list': case 'text': $sort = SORT_NATURAL | SORT_FLAG_CASE; break; default: $sort = SORT_REGULAR; } return $sort; } }
Config
rector.php
<?php use Rector\Config\RectorConfig; return RectorConfig::configure() // B. or few rules ->withRules([ \Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class ]);
Run Rector
Rector version:
e65ac6
- released at 2026-02-05 16:20