[Core][DeadCode] Remove ClassMethodManipulator->isPropertyPromotion() (#2346)

This commit is contained in:
Abdul Malik Ikhsan 2022-05-22 23:59:41 +07:00 committed by GitHub
parent 8fbc6582f9
commit a9c6d9bd06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 16 deletions

View File

@ -8,6 +8,7 @@ use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\NodeAnalyzer\ParamAnalyzer;
use Rector\Core\NodeManipulator\ClassMethodManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\MethodName;
@ -20,7 +21,8 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
final class RemoveDeadConstructorRector extends AbstractRector
{
public function __construct(
private readonly ClassMethodManipulator $classMethodManipulator
private readonly ClassMethodManipulator $classMethodManipulator,
private readonly ParamAnalyzer $paramAnalyzer
) {
}
@ -91,7 +93,7 @@ CODE_SAMPLE
return true;
}
if ($this->classMethodManipulator->isPropertyPromotion($classMethod)) {
if ($this->paramAnalyzer->hasPropertyPromotion($classMethod->params)) {
return true;
}

View File

@ -8,6 +8,7 @@ use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\NodeAnalyzer\ParamAnalyzer;
use Rector\Core\NodeManipulator\ClassMethodManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\MethodName;
@ -22,7 +23,8 @@ final class RemoveEmptyClassMethodRector extends AbstractRector
{
public function __construct(
private readonly ClassMethodManipulator $classMethodManipulator,
private readonly ControllerClassMethodManipulator $controllerClassMethodManipulator
private readonly ControllerClassMethodManipulator $controllerClassMethodManipulator,
private readonly ParamAnalyzer $paramAnalyzer
) {
}
@ -121,7 +123,7 @@ CODE_SAMPLE
return true;
}
if ($this->classMethodManipulator->isPropertyPromotion($classMethod)) {
if ($this->paramAnalyzer->hasPropertyPromotion($classMethod->params)) {
return true;
}

View File

@ -105,18 +105,6 @@ final class ClassMethodManipulator
return $paramName;
}
public function isPropertyPromotion(ClassMethod $classMethod): bool
{
foreach ($classMethod->params as $param) {
/** @var Param $param */
if ($param->flags !== 0) {
return true;
}
}
return false;
}
/**
* @param string[] $possibleNames
*/