Skip to content

Commit

Permalink
[NodeAnalyzer] Remove unused AstResolver on VariadicAnalyzer (#6353)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Oct 5, 2024
1 parent 45be85a commit 5fc55ce
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/NodeAnalyzer/VariadicAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Function_;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\MethodReflection;
use Rector\DeadCode\NodeManipulator\VariadicFunctionLikeDetector;
use Rector\PhpParser\AstResolver;
use Rector\Reflection\ReflectionResolver;

final readonly class VariadicAnalyzer
{
public function __construct(
private AstResolver $astResolver,
private ReflectionResolver $reflectionResolver,
private VariadicFunctionLikeDetector $variadicFunctionLikeDetector
private ReflectionResolver $reflectionResolver
) {
}

Expand All @@ -30,20 +25,7 @@ public function hasVariadicParameters(FuncCall | StaticCall | MethodCall $call):
return false;
}

if ($this->hasVariadicVariant($functionLikeReflection)) {
return true;
}

if ($functionLikeReflection instanceof FunctionReflection) {
$function = $this->astResolver->resolveFunctionFromFunctionReflection($functionLikeReflection);
if (! $function instanceof Function_) {
return false;
}

return $this->variadicFunctionLikeDetector->isVariadic($function);
}

return false;
return $this->hasVariadicVariant($functionLikeReflection);
}

private function hasVariadicVariant(MethodReflection | FunctionReflection $functionLikeReflection): bool
Expand Down

0 comments on commit 5fc55ce

Please sign in to comment.