PHP 8.2.31
Preview: ClassMethodParamRemover.php Size: 1.35 KB
//opt/cpanel/ea-wappspector/vendor/rector/rector/rules/DeadCode/NodeManipulator/ClassMethodParamRemover.php

<?php

declare (strict_types=1);
namespace Rector\DeadCode\NodeManipulator;

use PhpParser\Node\Stmt\ClassMethod;
use Rector\NodeAnalyzer\ParamAnalyzer;
use Rector\Removing\NodeManipulator\ComplexNodeRemover;
final class ClassMethodParamRemover
{
    /**
     * @readonly
     * @var \Rector\NodeAnalyzer\ParamAnalyzer
     */
    private $paramAnalyzer;
    /**
     * @readonly
     * @var \Rector\Removing\NodeManipulator\ComplexNodeRemover
     */
    private $complexNodeRemover;
    public function __construct(ParamAnalyzer $paramAnalyzer, ComplexNodeRemover $complexNodeRemover)
    {
        $this->paramAnalyzer = $paramAnalyzer;
        $this->complexNodeRemover = $complexNodeRemover;
    }
    public function processRemoveParams(ClassMethod $classMethod) : ?ClassMethod
    {
        $paramKeysToBeRemoved = [];
        foreach ($classMethod->params as $key => $param) {
            if ($this->paramAnalyzer->isParamUsedInClassMethod($classMethod, $param)) {
                continue;
            }
            $paramKeysToBeRemoved[] = $key;
        }
        if ($paramKeysToBeRemoved === []) {
            return null;
        }
        $removedParamKeys = $this->complexNodeRemover->processRemoveParamWithKeys($classMethod, $paramKeysToBeRemoved);
        if ($removedParamKeys !== []) {
            return $classMethod;
        }
        return null;
    }
}

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
1.35 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.71 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
3.88 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
4.35 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.62 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).