Try Rector
Hire Team
Find Rule
NEW
Play & Learn
NEW
Contact
Blog
Docs
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:
cb76a5
- released at 2024-11-19 18:25