diff --git a/src/Contract/Analyser/EventHelper.php b/src/Contract/Analyser/EventHelper.php index c6d649157..a4c937044 100644 --- a/src/Contract/Analyser/EventHelper.php +++ b/src/Contract/Analyser/EventHelper.php @@ -33,15 +33,16 @@ public function __construct( */ public function shouldViolationBeSkipped(string $depender, string $dependent): bool { - if (!array_key_exists($depender, $this->skippedViolations)) { - return false; - } - $key = array_search($dependent, $this->unmatchedSkippedViolation[$depender], true); - if (false === $key) { + $skippedViolation = $this->skippedViolations[$depender] ?? []; + $matched = [] !== $skippedViolation && in_array($dependent, $skippedViolation, true); + + if (!$matched) { return false; } - unset($this->unmatchedSkippedViolation[$depender][$key]); + if (false !== ($key = array_search($dependent, $this->unmatchedSkippedViolation[$depender], true))) { + unset($this->unmatchedSkippedViolation[$depender][$key]); + } return true; }