Description
Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector is removing valid code due to some false positives regarding callables. I'm not quite sure how to tackle this, so I'm just leaving the issue, sorry.
Current Behaviour
final class MyClass
{
public function run()
{
$array = [3, 2, 1];
usort($array, [$this, 'sort']);
return $array;
}
-
- private function sort($a, $b)
- {
- return $a <=> $b;
- }
}
Either [$this, 'sort'], [self::class, 'sort'], [static::class, 'sort'], [MyClass::class, 'sort'] are valid callables that I can recall.
Minimal PHP Code Causing Issue
Probably \Rector\NodeContainer\ParsedNodesByType::collect is not accounting for it.
Expected Behaviour
final class MyClass
{
public function run()
{
$array = [3, 2, 1];
usort($array, [$this, 'sort']);
return $array;
}
private function sort($a, $b)
{
return $a <=> $b;
}
}
Description
Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRectoris removing valid code due to some false positives regarding callables. I'm not quite sure how to tackle this, so I'm just leaving the issue, sorry.Current Behaviour
final class MyClass { public function run() { $array = [3, 2, 1]; usort($array, [$this, 'sort']); return $array; } - - private function sort($a, $b) - { - return $a <=> $b; - } }Either
[$this, 'sort'],[self::class, 'sort'],[static::class, 'sort'],[MyClass::class, 'sort']are valid callables that I can recall.Minimal PHP Code Causing Issue
Probably
\Rector\NodeContainer\ParsedNodesByType::collectis not accounting for it.Expected Behaviour
final class MyClass { public function run() { $array = [3, 2, 1]; usort($array, [$this, 'sort']); return $array; } private function sort($a, $b) { return $a <=> $b; } }