mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-10 21:22:21 +00:00
[Core][DeadCode] Remove ClassMethodManipulator->isPropertyPromotion() (#2346)
This commit is contained in:
parent
8fbc6582f9
commit
a9c6d9bd06
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user