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: \"Rector\\TypeDeclaration\\NodeAnalyzer\\ClassMethodAndPropertyAnalyzer::isLocalPropertyVariableAssign(): Argument #1 ($onlyClassMethodStmt) must be of type PhpParser\\Node\\Stmt, null given, called in /var/www/vendor/rector/rector/rules/TypeDeclaration/NodeAnalyzer/ClassMethodAndPropertyAnalyzer.php on line 48\"\nRun Rector with \"--debug\" option and post the report here: https://github.com/rectorphp/rector/issues/new", "file": "/var/www/storage/demo/5almemv582etbv9uvbiu/rector_analyzed_file.php", "line": 70 } ] }
Run Rector on your code to see what it can do for you:
PHP snippet to change
<?php class ObjectProvider { private $objects; private $prop; public function __construct(iterable $objects, $prop) { $this->prop = $prop; foreach ($objects as $object) { $this->clients[$client::class] = $client; } } public function getObjects(): array { return $this->objects; } }
Config
rector.php
<?php use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\Class_\PropertyTypeFromStrictSetterGetterRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; return RectorConfig::configure() ->withRules([ ClassPropertyAssignToConstructorPromotionRector::class, PropertyTypeFromStrictSetterGetterRector::class, ]) ;
Run Rector
Rector version:
eac1ef
- released at 2026-02-01 16:47