diff --git a/src/Analyser/Analyser.php b/src/Analyser/Analyser.php index df6a044..db61b1a 100644 --- a/src/Analyser/Analyser.php +++ b/src/Analyser/Analyser.php @@ -215,17 +215,20 @@ className: $violation->className, continue; } - $violations = $rule instanceof MultipleRuleViolationInterface - ? $rule->evaluateAll($classNode) - : [$rule->evaluate($classNode)]; - - $isFixable = $rule instanceof FixableInterface; - - foreach ($violations as $violation) { + if ($rule instanceof MultipleRuleViolationInterface) { + $violations = $rule->evaluateAll($classNode); + } else { + $violation = $rule->evaluate($classNode); if (! $violation instanceof RuleViolation) { continue; } + $violations = [$violation]; + } + + $isFixable = $rule instanceof FixableInterface; + + foreach ($violations as $violation) { // Inject the rule key into the violation $ruleViolationCollection->add(new RuleViolation( message: $violation->message,