-
-
Notifications
You must be signed in to change notification settings - Fork 738
Closed
rectorphp/rector-src
#7799Labels
Description
Bug Report
Hello, I just bumped on this Rector run Fail :
{ "totals": { "changed_files": 0, "errors": 1 }, "errors": [ { "message": "System error: \"Rector\\DeadCode\\Rector\\ClassMethod\\RemoveParentDelegatingConstructorRector::matchParentConstructorCallArgs(): Argument #1 ($stmt) must be of type PhpParser\\Node\\Stmt, null given, called in /var/www/vendor/rector/rector/rules/DeadCode/Rector/ClassMethod/RemoveParentDelegatingConstructorRector.php on line 100\"\nRun Rector with \"--debug\" option and post the report here: https://github.com/rectorphp/rector/issues/new", "file": "/var/www/storage/demo/gq7sfvrntg1nlbi31c2q/rector_analyzed_file.php", "line": 135 } ] }
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/bbd24251-be91-4fc8-ab5d-08dbd5d6619b
<?php
class A
{
public function __construct()
{
$this->init();
}
private function init(): void
{
echo 'A init';
}
}
final class B extends A
{
private string $prop;
public function __construct(string $prop)
{
$this->prop = $prop;
parent::__construct();
}
public function prop(): string
{
return $this->prop;
}
}Responsible minimal config
<?php
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector;
use Rector\ValueObject\PhpVersion;
return RectorConfig::configure()
->withPhpSets(php83: true)
->withRules([
RemoveParentDelegatingConstructorRector::class,
])
;Expected Behaviour
No error and maybe a fix proposal similiar to this ? :
final class B extends A
{
public function __construct(private string $prop)
{
parent::__construct();
}
public function prop(): string
{
return $this->prop;
}
}