Skip to content

Commit

Permalink
include path when counting errors ignored by identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
pilif authored and ondrejmirtes committed Jun 13, 2024
1 parent f638dc4 commit 386ccd0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Analyser/Ignore/IgnoredErrorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function initialize(): IgnoredErrorHelperResult
continue;
}

$key = '';
$key = $ignoreError['path'];
if (isset($ignoreError['message'])) {
$key = sprintf("%s\n%s", $ignoreError['message'], $ignoreError['path']);
$key = sprintf("%s\n%s", $key, $ignoreError['message']);
}
if (isset($ignoreError['identifier'])) {
$key = sprintf("%s\n%s", $key, $ignoreError['identifier']);
Expand Down
26 changes: 26 additions & 0 deletions tests/PHPStan/Analyser/AnalyserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,32 @@ public function dataTrueAndFalse(): array
];
}

/**
* @dataProvider dataTrueAndFalse
*/
public function testIgnoreErrorByPathAndIdentifierCountsCorrectly(bool $onlyFiles): void
{
$ignoreErrors = [
[
'identifier' => 'tests.alwaysFail',
'count' => 3,
'path' => __DIR__ . '/data/two-fails.php',
],
[
'identifier' => 'tests.alwaysFail',
'count' => 2,
'path' => __DIR__ . '/data/two-different-fails.php',
],
];

$filesToAnalyze = [
__DIR__ . '/data/two-fails.php',
__DIR__ . '/data/two-different-fails.php',
];
$result = $this->runAnalyser($ignoreErrors, true, $filesToAnalyze, $onlyFiles);
$this->assertSame([], $result);
}

/**
* @dataProvider dataTrueAndFalse
*/
Expand Down

0 comments on commit 386ccd0

Please sign in to comment.