Repository: qossmic/deptrac (php)

Issue:
Baseline not skipping multiple violations of same reference
Reproducer: https://github.com/gennadigennadigennadi/deptrac/tree/reproducer-skipped-multiple-violations-in-one-file
```yaml
deptrac:
  skip_violations:
    Qossmic\Deptrac\Core\Ast\Parser\Cache\AstFileReferenceFileCache:
      - Qossmic\Deptrac\Supportive\DependencyInjection\Exception\CacheFileException

```
```bash
 Reason                     Ast                                                                                                                                                             
 -------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  DependsOnDisallowedLayer   Qossmic\Deptrac\Core\Ast\Parser\Cache\AstFileReferenceFileCache must not depend on Qossmic\Deptrac\Supportive\DependencyInjection\Exception\CacheFileException  
                             You are depending on token that is a part of a layer that you are not allowed to depend on. (DependencyInjection)                                               
                             /var/www/deptrac/src/Core/Ast/Parser/Cache/AstFileReferenceFileCache.php:139                                                                                    
 -------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------- 


 -------------------- ----- 
  Report                    
 -------------------- ----- 
  Violations           1    
  Skipped violations   1    
  Uncovered            24   
  Allowed              347  
  Warnings             0    
  Errors               0    
 -------------------- ----- 


Process finished with exit code 1

```

Pull request description:
fix #1226 - skipped multiple violations in one file
fixes #1226 

Patch:
diff --git a/src/Contract/Analyser/EventHelper.php b/src/Contract/Analyser/EventHelper.php
index c6d64915..a4c93704 100644
--- a/src/Contract/Analyser/EventHelper.php
+++ b/src/Contract/Analyser/EventHelper.php
@@ -33,15 +33,16 @@ final class EventHelper
      */
     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;
     }


Test patch:
diff --git a/tests/Contract/Analyser/EventHelperTest.php b/tests/Contract/Analyser/EventHelperTest.php
index 713db592..5e605e70 100644
--- a/tests/Contract/Analyser/EventHelperTest.php
+++ b/tests/Contract/Analyser/EventHelperTest.php
@@ -26,6 +26,13 @@ final class EventHelperTest extends TestCase
         ];
         $helper = new EventHelper($configuration, new LayerProvider([]));
 
+        self::assertTrue(
+            $helper->shouldViolationBeSkipped(
+                ClassLikeToken::fromFQCN('ClassWithOneDep')->toString(),
+                ClassLikeToken::fromFQCN('DependencyClass')->toString()
+            )
+        );
+        // also skips multiple occurrences
         self::assertTrue(
             $helper->shouldViolationBeSkipped(
                 ClassLikeToken::fromFQCN('ClassWithOneDep')->toString(),
@@ -73,6 +80,13 @@ final class EventHelperTest extends TestCase
         ];
         $helper = new EventHelper($configuration, new LayerProvider([]));
 
+        self::assertTrue(
+            $helper->shouldViolationBeSkipped(
+                ClassLikeToken::fromFQCN('ClassWithOneDep')->toString(),
+                ClassLikeToken::fromFQCN('DependencyClass')->toString()
+            )
+        );
+        // also skips multiple occurrences
         self::assertTrue(
             $helper->shouldViolationBeSkipped(
                 ClassLikeToken::fromFQCN('ClassWithOneDep')->toString(),