Repository navigation
Make glob() failure return a RuntimeException - #1653
Merged
Merged
Conversation
cpeel
reviewed
Sep 28, 2026
This can only happen in some limited scenarios, none of which we can do anything about at runtime: - if PHP runs out of memory while processing the glob; - if the pattern is longer than MAXPATHLEN (typically 4kB); - if the flag to glob is invalid If these happen, `glob()` returns `false`. By contrast, not having permission to read the directory, or not matching the pattern returns an empty array. `glob()` returning false causes PHP to error with type mismatchs in all the following code (which assumes `glob()` returned an array). By throwing our own RuntimeException we get better error messages, and quell some PHPStan level 7 warnings.
bpfoley
force-pushed
the
level-7-glob
branch
from
September 28, 2026 19:22
666e89f to
1fb47cc
Compare
cpeel
approved these changes
Sep 28, 2026
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.
This can only happen in some limited scenarios, none of which we can do anything about at runtime:
If these happen,
glob()returnsfalse.By contrast, not having permission to read the directory, or not matching the pattern returns an empty array.
glob()returning false causes PHP to error with type mismatchs in all the following code (which assumesglob()returned an array). By throwing our own RuntimeException we get better error messages, and quell some PHPStan level 7 warnings.