diff --git a/src/Analyser/Analyser.php b/src/Analyser/Analyser.php index 0ddf4b727c..f45f649418 100644 --- a/src/Analyser/Analyser.php +++ b/src/Analyser/Analyser.php @@ -3,7 +3,7 @@ namespace PHPStan\Analyser; use Closure; -use PHPStan\Rules\Registry; +use PHPStan\Rules\Registry as RuleRegistry; use Throwable; use function array_fill_keys; use function array_merge; @@ -15,7 +15,7 @@ class Analyser public function __construct( private FileAnalyser $fileAnalyser, - private Registry $registry, + private RuleRegistry $ruleRegistry, private NodeScopeResolver $nodeScopeResolver, private int $internalErrorsCountLimit, ) @@ -57,7 +57,7 @@ public function analyse( $fileAnalyserResult = $this->fileAnalyser->analyseFile( $file, $allAnalysedFiles, - $this->registry, + $this->ruleRegistry, null, ); $errors = array_merge($errors, $fileAnalyserResult->getErrors()); diff --git a/src/Analyser/FileAnalyser.php b/src/Analyser/FileAnalyser.php index 4d9cdb9297..4f2d357f66 100644 --- a/src/Analyser/FileAnalyser.php +++ b/src/Analyser/FileAnalyser.php @@ -18,7 +18,7 @@ use PHPStan\Rules\LineRuleError; use PHPStan\Rules\MetadataRuleError; use PHPStan\Rules\NonIgnorableRuleError; -use PHPStan\Rules\Registry; +use PHPStan\Rules\Registry as RuleRegistry; use PHPStan\Rules\TipRuleError; use function array_key_exists; use function array_keys; @@ -59,7 +59,7 @@ public function __construct( public function analyseFile( string $file, array $analysedFiles, - Registry $registry, + RuleRegistry $ruleRegistry, ?callable $outerNodeCallback, ): FileAnalyserResult { @@ -72,7 +72,7 @@ public function analyseFile( $parserNodes = $this->parser->parseFile($file); $linesToIgnore = $this->getLinesToIgnoreFromTokens($file, $parserNodes); $temporaryFileErrors = []; - $nodeCallback = function (Node $node, Scope $scope) use (&$fileErrors, &$fileDependencies, &$exportedNodes, $file, $registry, $outerNodeCallback, $analysedFiles, &$linesToIgnore, &$temporaryFileErrors): void { + $nodeCallback = function (Node $node, Scope $scope) use (&$fileErrors, &$fileDependencies, &$exportedNodes, $file, $ruleRegistry, $outerNodeCallback, $analysedFiles, &$linesToIgnore, &$temporaryFileErrors): void { if ($node instanceof Node\Stmt\Trait_) { foreach (array_keys($linesToIgnore[$file] ?? []) as $lineToIgnore) { if ($lineToIgnore < $node->getStartLine() || $lineToIgnore > $node->getEndLine()) { @@ -87,7 +87,7 @@ public function analyseFile( } $uniquedAnalysedCodeExceptionMessages = []; $nodeType = get_class($node); - foreach ($registry->getRules($nodeType) as $rule) { + foreach ($ruleRegistry->getRules($nodeType) as $rule) { try { $ruleErrors = $rule->processNode($node, $scope); } catch (AnalysedCodeException $e) { diff --git a/src/Command/WorkerCommand.php b/src/Command/WorkerCommand.php index c55d30bd62..843b57bfb7 100644 --- a/src/Command/WorkerCommand.php +++ b/src/Command/WorkerCommand.php @@ -8,7 +8,7 @@ use PHPStan\Analyser\NodeScopeResolver; use PHPStan\DependencyInjection\Container; use PHPStan\File\PathNotFoundException; -use PHPStan\Rules\Registry; +use PHPStan\Rules\Registry as RuleRegistry; use PHPStan\ShouldNotHappenException; use React\EventLoop\StreamSelectLoop; use React\Socket\ConnectionInterface; @@ -189,9 +189,9 @@ private function runWorker( $out->on('error', $handleError); /** @var FileAnalyser $fileAnalyser */ $fileAnalyser = $container->getByType(FileAnalyser::class); - /** @var Registry $registry */ - $registry = $container->getByType(Registry::class); - $in->on('data', function (array $json) use ($fileAnalyser, $registry, $out, $analysedFiles, $tmpFile, $insteadOfFile, $output): void { + /** @var RuleRegistry $ruleRegistry */ + $ruleRegistry = $container->getByType(RuleRegistry::class); + $in->on('data', function (array $json) use ($fileAnalyser, $ruleRegistry, $out, $analysedFiles, $tmpFile, $insteadOfFile, $output): void { $action = $json['action']; if ($action !== 'analyse') { return; @@ -207,7 +207,7 @@ private function runWorker( if ($file === $insteadOfFile) { $file = $tmpFile; } - $fileAnalyserResult = $fileAnalyser->analyseFile($file, $analysedFiles, $registry, null); + $fileAnalyserResult = $fileAnalyser->analyseFile($file, $analysedFiles, $ruleRegistry, null); $fileErrors = $fileAnalyserResult->getErrors(); $dependencies[$file] = $fileAnalyserResult->getDependencies(); $exportedNodes[$file] = $fileAnalyserResult->getExportedNodes();