Skip to content

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

Open
janedbal wants to merge 1 commit intophpstan:2.1.xfrom
janedbal:fix-14231-path-type-validation
Open

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

Conversation

@janedbal
Copy link
Contributor

… 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
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.

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.

2 participants