Skip to content

Commit

Permalink
[Core][DeadCode] Remove ClassMethodManipulator->isPropertyPromotion() (
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed May 22, 2022
1 parent 8fbc658 commit a9c6d9b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand All @@ -20,7 +21,8 @@
final class RemoveDeadConstructorRector extends AbstractRector
{
public function __construct(
private readonly ClassMethodManipulator $classMethodManipulator
private readonly ClassMethodManipulator $classMethodManipulator,
private readonly ParamAnalyzer $paramAnalyzer
) {
}

Expand Down Expand Up @@ -91,7 +93,7 @@ private function shouldSkipPropertyPromotion(ClassMethod $classMethod): bool
return true;
}

if ($this->classMethodManipulator->isPropertyPromotion($classMethod)) {
if ($this->paramAnalyzer->hasPropertyPromotion($classMethod->params)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand All @@ -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
) {
}

Expand Down Expand Up @@ -121,7 +123,7 @@ private function shouldSkipClassMethod(ClassMethod $classMethod): bool
return true;
}

if ($this->classMethodManipulator->isPropertyPromotion($classMethod)) {
if ($this->paramAnalyzer->hasPropertyPromotion($classMethod->params)) {
return true;
}

Expand Down
12 changes: 0 additions & 12 deletions src/NodeManipulator/ClassMethodManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,6 @@ public function addMethodParameterIfMissing(Node $node, ObjectType $objectType,
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
*/
Expand Down

0 comments on commit a9c6d9b

Please sign in to comment.