Fix phpstan/phpstan#12430: Baseline generator won't take care of removing errors from changed file locations or renames#5414
Closed
phpstan-bot wants to merge 1 commit intophpstan:2.1.xfrom
Conversation
- Baseline entries (identified by having a 'count' key) with paths to deleted/renamed files caused "is neither a directory, nor a file path, nor a fnmatch pattern" errors during container initialization - The message validation already skipped baseline entries but the path validation did not - Added the same 'count' check to skip baseline entries in the path validation loop in ValidateIgnoredErrorsExtension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When files are deleted or renamed, their baseline entries contain paths that no longer exist. PHPStan refused to run with "Path ... is neither a directory, nor a file path, nor a fnmatch pattern" instead of treating them as unmatched ignored errors at runtime.
Changes
countkey check to skip baseline entries during path validation insrc/DependencyInjection/ValidateIgnoredErrorsExtension.phptests/PHPStan/DependencyInjection/InvalidIgnoredErrorExceptionTest.phptests/PHPStan/DependencyInjection/invalidIgnoreErrors/baseline-nonexistent-path.neonRoot cause
In
ValidateIgnoredErrorsExtension::loadConfiguration(), the message validation loop (line 148) already skipped baseline entries (those with acountkey) with the comment "ignoreError coming from baseline will be correct". However, the path validation loop (line 174) did not have this same check, so baseline entries with paths to deleted/renamed files triggered the hard error during container initialization instead of being handled gracefully at runtime as unmatched ignored errors.Test
The regression test loads a config with a baseline-style
ignoreErrorsentry (withcountand a non-existentpath) and verifies that the container can be created without throwingInvalidIgnoredErrorPatternsException.Fixes phpstan/phpstan#12430