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: \"Typed property PHPStan\\Type\\StaticType::$classReflection must not be accessed before initialization\"\nRun Rector with \"--debug\" option and post the report here: https://github.com/rectorphp/rector/issues/new", "file": "/var/www/storage/demo/mcpbk8ww2d7hx921rnd6/rector_analyzed_file.php", "line": 71 } ] }
Run Rector on your code to see what it can do for you:
PHP snippet to change
<?php class DemoFile { /** * @inheritDoc */ public function mymethod(string $name): static { assert( str_contains($name, ' ') && !str_starts_with($name, ' '), "The name '{$name}' is missing a space. Names should look like `cake routes`", ); $this->name = $name; return $this; } }
Config
rector.php
<?php use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector; use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration; use Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType; return RectorConfig::configure() ->withConfiguredRule(AddReturnTypeDeclarationRector::class, [ new AddReturnTypeDeclaration('DemoFile', 'mymethod', new SimpleStaticType('DemoFile')), ]);
Run Rector
Rector version:
0594c1
- released at 2026-05-08 19:57