From f0b3d52184aa22e81c53ba6762c073f78be8374c Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Tue, 17 Sep 2024 09:59:41 +0200 Subject: [PATCH] Dial back a bit --- src/Analyser/RuleErrorTransformer.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Analyser/RuleErrorTransformer.php b/src/Analyser/RuleErrorTransformer.php index 916f284505..b45ce15acd 100644 --- a/src/Analyser/RuleErrorTransformer.php +++ b/src/Analyser/RuleErrorTransformer.php @@ -8,6 +8,7 @@ use PHPStan\Rules\LineRuleError; use PHPStan\Rules\MetadataRuleError; use PHPStan\Rules\NonIgnorableRuleError; +use PHPStan\Rules\RuleError; use PHPStan\Rules\TipRuleError; final class RuleErrorTransformer @@ -17,7 +18,7 @@ final class RuleErrorTransformer * @param class-string $nodeType */ public function transform( - IdentifierRuleError $ruleError, + RuleError $ruleError, Scope $scope, string $nodeType, int $nodeLine, @@ -29,6 +30,7 @@ public function transform( $filePath = $scope->getFile(); $traitFilePath = null; $tip = null; + $identifier = null; $metadata = []; if ($scope->isInTrait()) { $traitReflection = $scope->getTraitReflection(); @@ -56,6 +58,10 @@ public function transform( $tip = $ruleError->getTip(); } + if ($ruleError instanceof IdentifierRuleError) { + $identifier = $ruleError->getIdentifier(); + } + if ($ruleError instanceof MetadataRuleError) { $metadata = $ruleError->getMetadata(); } @@ -74,7 +80,7 @@ public function transform( $tip, $nodeLine, $nodeType, - $ruleError->getIdentifier(), + $identifier, $metadata, ); }