Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Run Rector on your code to see what it can do for you:
PHP snippet to change
<?php final class DemoFile { public function run(bool $param) { if ($this->isTrue($param)) { return 5; } return '10'; } private function isTrue($value) { return $value === true; } }
Config
rector.php
<?php use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; return RectorConfig::configure() // A. whole set ->withPreparedSets(typeDeclarations: true) // B. or few rules ->withRules([ TypedPropertyFromAssignsRector::class ]);
Run Rector
Rector version:
c4b68d
- released at 2025-05-06 21:50