Skip to content

Commit 386ccd0

Browse files
pilifondrejmirtes
authored andcommitted
include path when counting errors ignored by identifier
this fixes phpstan/phpstan#11177
1 parent f638dc4 commit 386ccd0

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Analyser/Ignore/IgnoredErrorHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function initialize(): IgnoredErrorHelperResult
6868
continue;
6969
}
7070

71-
$key = '';
71+
$key = $ignoreError['path'];
7272
if (isset($ignoreError['message'])) {
73-
$key = sprintf("%s\n%s", $ignoreError['message'], $ignoreError['path']);
73+
$key = sprintf("%s\n%s", $key, $ignoreError['message']);
7474
}
7575
if (isset($ignoreError['identifier'])) {
7676
$key = sprintf("%s\n%s", $key, $ignoreError['identifier']);

tests/PHPStan/Analyser/AnalyserTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,32 @@ public function dataTrueAndFalse(): array
207207
];
208208
}
209209

210+
/**
211+
* @dataProvider dataTrueAndFalse
212+
*/
213+
public function testIgnoreErrorByPathAndIdentifierCountsCorrectly(bool $onlyFiles): void
214+
{
215+
$ignoreErrors = [
216+
[
217+
'identifier' => 'tests.alwaysFail',
218+
'count' => 3,
219+
'path' => __DIR__ . '/data/two-fails.php',
220+
],
221+
[
222+
'identifier' => 'tests.alwaysFail',
223+
'count' => 2,
224+
'path' => __DIR__ . '/data/two-different-fails.php',
225+
],
226+
];
227+
228+
$filesToAnalyze = [
229+
__DIR__ . '/data/two-fails.php',
230+
__DIR__ . '/data/two-different-fails.php',
231+
];
232+
$result = $this->runAnalyser($ignoreErrors, true, $filesToAnalyze, $onlyFiles);
233+
$this->assertSame([], $result);
234+
}
235+
210236
/**
211237
* @dataProvider dataTrueAndFalse
212238
*/

0 commit comments

Comments
 (0)