Skip to content

Ignored error on removed file doesn't trigger error unless cache is emptied #3058

@Daeroni

Description

@Daeroni

Bug report

If an error was ignored with a baseline, and then the file containing the error, phpstan doesn't notice that the error is not matched anymore because it doesn't analyze deleted files (obviously).

When cache is deleted, the error about unmatched error is shown.

Code snippet that reproduces the problem

$ echo '<?php print "abc";' > ok.php
$ echo '<?php print "abc" + 1;' > notok.php
$ /path/to/phpstan/bin/phpstan analyze --error-format=baselineNeon --level 8 . | tee phpstan-baseline.neon
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

parameters:
        ignoreErrors:
                -
                        message: "#^Binary operation \"\\+\" between 'abc' and 1 results in an error\\.$#"
                        count: 1
                        path: notok.php

$ echo -e "includes:\n    - phpstan-baseline.neon" > phpstan.neon
$ /path/to/phpstan/bin/phpstan analyze -c phpstan.neon --level 8 .
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%



 [OK] No errors


$ rm notok.php
$ /path/to/phpstan/bin/phpstan analyze -c phpstan.neon --level 8 .
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%



 [OK] No errors


$ rm -rf /tmp/phpstan/
$ /path/to/phpstan/bin/phpstan analyze -c phpstan.neon --level 8 .
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 -- ---------------------------------------------------------------------------------------------------
     Error
 -- ---------------------------------------------------------------------------------------------------
     Ignored error pattern #^Binary operation "\+" between 'abc' and 1 results in an error\.$# in path
     /home/teemu/phpstantest/ignored_error/notok.php was not matched in reported errors.
 -- ---------------------------------------------------------------------------------------------------


 [ERROR] Found 1 error

Expected output

Error about ignored error not matched should be shown when running phpstan after deleting a file with an ignored error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions