diff --git a/src/Analyser/IgnoredErrorHelperResult.php b/src/Analyser/IgnoredErrorHelperResult.php index bc5c1bf7ae..8d63d78f9a 100644 --- a/src/Analyser/IgnoredErrorHelperResult.php +++ b/src/Analyser/IgnoredErrorHelperResult.php @@ -223,6 +223,16 @@ public function process(array $errors, bool $onlyFiles, bool $reachedInternalErr $unmatchedIgnoredError['realCount'] === 1 ? 'time' : 'times' ), $unmatchedIgnoredError['file'], $unmatchedIgnoredError['line'], false); } + } elseif (isset($unmatchedIgnoredError['realPath'])) { + $errors[] = new Error( + sprintf( + 'Ignored error pattern %s was not matched in reported errors.', + IgnoredError::stringifyPattern($unmatchedIgnoredError) + ), + $unmatchedIgnoredError['realPath'], + null, + false + ); } elseif (!$onlyFiles) { $errors[] = sprintf( 'Ignored error pattern %s was not matched in reported errors.', diff --git a/tests/PHPStan/Analyser/AnalyserTest.php b/tests/PHPStan/Analyser/AnalyserTest.php index 9e1449441a..fa45f9e716 100644 --- a/tests/PHPStan/Analyser/AnalyserTest.php +++ b/tests/PHPStan/Analyser/AnalyserTest.php @@ -175,9 +175,10 @@ public function testIgnoreErrorByPathAndCountMissing(): void $this->assertSame(7, $result[2]->getLine()); $this->assertSamePaths(__DIR__ . '/data/two-fails.php', $result[2]->getFile()); - $this->assertIsString($result[3]); - $this->assertStringContainsString('Ignored error pattern #Some custom error\.# in path', $result[3]); - $this->assertStringContainsString('was not matched in reported errors.', $result[3]); + $this->assertInstanceOf(Error::class, $result[3]); + $this->assertStringContainsString('Ignored error pattern #Some custom error\.# in path', $result[3]->getMessage()); + $this->assertStringContainsString('was not matched in reported errors.', $result[3]->getMessage()); + $this->assertSamePaths(__DIR__ . '/data/two-fails.php', $result[2]->getFile()); } public function testIgnoreErrorByPaths(): void