-
-
Notifications
You must be signed in to change notification settings - Fork 738
Closed
Labels
Description
Bug Report
Hello, I have got this issue when migrating some old code :
"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
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/122b127a-762c-4551-8cac-f0d41e8886a4
<?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;
}
}Responsible rules
ClassPropertyAssignToConstructorPromotionRectorPropertyTypeFromStrictSetterGetterRector
Expected Behavior
removing the getObjects method suggests me this without error :
class ObjectProvider
{
private $objects;
- private $prop;
- public function __construct(iterable $objects, $prop)
+ public function __construct(iterable $objects, private $prop)
{
- $this->prop = $prop;
foreach ($objects as $object) {
$this->clients[$client::class] = $client;
}
}
}