Skip to content

Fix fatal error when path has array value in ignoreErrors#5183

Merged
VincentLanglet merged 1 commit intophpstan:2.1.xfrom
janedbal:fix-14231-path-type-validation
Mar 19, 2026
Merged

Fix fatal error when path has array value in ignoreErrors#5183
VincentLanglet merged 1 commit intophpstan:2.1.xfrom
janedbal:fix-14231-path-type-validation

Conversation

@janedbal
Copy link
Contributor

@staabm
Copy link
Contributor

staabm commented Mar 10, 2026

why is this parameter not validated against the schema?

@janedbal
Copy link
Contributor Author

The ValidateIgnoredErrorsExtension::loadConfiguration() runs during DI container compilation, before the schema validation. So the schema (path: string()) never gets a chance to catch the wrong type.

@VincentLanglet
Copy link
Contributor

@ondrejmirtes you might want to give a word about the error wording ?

… ignoreErrors

When a user accidentally writes `path:` with an array value (intending
`paths:`), ValidateIgnoredErrorsExtension crashes with a TypeError
because FileExcluder::isAbsolutePath() receives an array instead of a
string. The schema validation that would catch this runs after the DI
extension, so it never gets a chance to report the misconfiguration.

Added type checks for `path` (must be string) and `paths` (must be
array) with helpful error messages suggesting the correct key name.
@staabm staabm force-pushed the fix-14231-path-type-validation branch from ce331a9 to 29ee169 Compare March 19, 2026 05:48
@VincentLanglet
Copy link
Contributor

Let's merge this, ondrej can still change the wording later ; it won't be a BC break.

@VincentLanglet VincentLanglet merged commit d067441 into phpstan:2.1.x Mar 19, 2026
649 of 651 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants