Skip to content

Commit 3b0c6a2

Browse files
committed
Unmatched ignored error for a specific file reported in that file
1 parent 7955fb5 commit 3b0c6a2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Analyser/IgnoredErrorHelperResult.php

+10
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ public function process(array $errors, bool $onlyFiles, bool $reachedInternalErr
223223
$unmatchedIgnoredError['realCount'] === 1 ? 'time' : 'times'
224224
), $unmatchedIgnoredError['file'], $unmatchedIgnoredError['line'], false);
225225
}
226+
} elseif (isset($unmatchedIgnoredError['realPath'])) {
227+
$errors[] = new Error(
228+
sprintf(
229+
'Ignored error pattern %s was not matched in reported errors.',
230+
IgnoredError::stringifyPattern($unmatchedIgnoredError)
231+
),
232+
$unmatchedIgnoredError['realPath'],
233+
null,
234+
false
235+
);
226236
} elseif (!$onlyFiles) {
227237
$errors[] = sprintf(
228238
'Ignored error pattern %s was not matched in reported errors.',

tests/PHPStan/Analyser/AnalyserTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ public function testIgnoreErrorByPathAndCountMissing(): void
175175
$this->assertSame(7, $result[2]->getLine());
176176
$this->assertSamePaths(__DIR__ . '/data/two-fails.php', $result[2]->getFile());
177177

178-
$this->assertIsString($result[3]);
179-
$this->assertStringContainsString('Ignored error pattern #Some custom error\.# in path', $result[3]);
180-
$this->assertStringContainsString('was not matched in reported errors.', $result[3]);
178+
$this->assertInstanceOf(Error::class, $result[3]);
179+
$this->assertStringContainsString('Ignored error pattern #Some custom error\.# in path', $result[3]->getMessage());
180+
$this->assertStringContainsString('was not matched in reported errors.', $result[3]->getMessage());
181+
$this->assertSamePaths(__DIR__ . '/data/two-fails.php', $result[2]->getFile());
181182
}
182183

183184
public function testIgnoreErrorByPaths(): void

0 commit comments

Comments
 (0)