From 7e94512c36a9d6e9d27e5eef9ab6e4e5645624f3 Mon Sep 17 00:00:00 2001 From: Gennadi McKelvey Date: Tue, 20 Jun 2023 10:59:24 +0200 Subject: [PATCH] fix #1226 --- src/Contract/Analyser/EventHelper.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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; }