Skip to content

Commit

Permalink
Do not report nonexistent paths in ignoreErrors if `reportUnmatchedIg…
Browse files Browse the repository at this point in the history
…noredErrors: false`
  • Loading branch information
ondrejmirtes committed Aug 8, 2024
1 parent 6ee5c22 commit b7fe990
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ jobs:
cp -r tmp-node-modules node_modules
OUTPUT=$(../../bin/phpstan analyse -c ignoreNonexistentExcludePath.neon)
echo "$OUTPUT"
- script: |
cd e2e/bad-exclude-paths
OUTPUT=$(../../bin/phpstan analyse -c ignoreReportUnmatchedFalse.neon)
echo "$OUTPUT"
steps:
- name: "Checkout"
Expand Down
12 changes: 12 additions & 0 deletions e2e/bad-exclude-paths/ignoreReportUnmatchedFalse.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- ../../conf/bleedingEdge.neon

parameters:
level: 8
paths:
- src
reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
message: '#aaa#'
path: tests
5 changes: 5 additions & 0 deletions src/Command/CommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ public static function begin(
$errorOutput->writeLineFormatted($error);
$errorOutput->writeLineFormatted('');
}

$errorOutput->writeLineFormatted('To ignore non-existent paths in ignoreErrors,');
$errorOutput->writeLineFormatted('set <fg=cyan>reportUnmatchedIgnoredErrors: false</> in your configuration file.');
$errorOutput->writeLineFormatted('');

throw new InceptionNotSuccessfulException();
} catch (InvalidExcludePathsException $e) {
$errorOutput->writeLineFormatted(sprintf('<error>Invalid %s in excludePaths:</error>', count($e->getErrors()) === 1 ? 'entry' : 'entries'));
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/NeonAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class NeonAdapter implements Adapter
{

public const CACHE_KEY = 'v27-optional-path';
public const CACHE_KEY = 'v28-ignore-errors';

private const PREVENT_MERGING_SUFFIX = '!';

Expand Down
4 changes: 3 additions & 1 deletion src/DependencyInjection/ValidateIgnoredErrorsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ public function getRegistry(): OperatorTypeSpecifyingExtensionRegistry
}
}

if ($noImplicitWildcard) {
$reportUnmatched = (bool) $builder->parameters['reportUnmatchedIgnoredErrors'];

if ($noImplicitWildcard && $reportUnmatched) {
foreach ($ignoreErrors as $ignoreError) {
if (!is_array($ignoreError)) {
continue;
Expand Down

0 comments on commit b7fe990

Please sign in to comment.