paramAnalyzer = $paramAnalyzer; } public function getRuleDefinition(): RuleDefinition { return new RuleDefinition('Remove unused parameter in constructor', [ new CodeSample( <<<'CODE_SAMPLE' final class SomeClass { private $hey; public function __construct($hey, $man) { $this->hey = $hey; } } CODE_SAMPLE , <<<'CODE_SAMPLE' final class SomeClass { private $hey; public function __construct($hey) { $this->hey = $hey; } } CODE_SAMPLE ), ]); } /** * @return string[] */ public function getNodeTypes(): array { return [ClassMethod::class]; } /** * @param ClassMethod $node */ public function refactor(Node $node): ?Node { if (! $this->isName($node, MethodName::CONSTRUCT)) { return null; } if ($node->params === []) { return null; } foreach ($node->params as $param) { if ($this->paramAnalyzer->isParamUsedInClassMethod($node, $param)) { continue; } $this->nodeRemover->removeParam($node, $param); } return null; } }