Harden include-loading rules against masked failures - #1034
Merged
Conversation
mglaman
force-pushed
the
audit/1b-include-hardening
branch
from
August 5, 2026 17:15
5bc7d7d to
a178ab7
Compare
Narrow the blanket catch (Throwable) in LoadIncludes and ModuleLoadInclude to wrap only the require_once, so PHPStan's own exceptions propagate instead of being reported as unloadable files. Add the missing non-constant-args guard to ModuleLoadInclude, which previously interpolated false into its error message, and document parseLoadIncludeArgs()'s sentinel return shape. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mglaman
force-pushed
the
audit/1b-include-hardening
branch
from
August 5, 2026 19:13
a178ab7 to
20e6baf
Compare
mglaman
marked this pull request as ready for review
August 5, 2026 19:14
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.
Part 3 of 9 in the legacy-code audit stack (on top of #1026).
What changed
LoadIncludesandModuleLoadIncludewrapped their entire rule body incatch (Throwable), so PHPStan's own internal exceptions were swallowed and reported to users as "file could not be loaded". The catch now wraps only therequire_onceitself, and the intentional load-the-include side effect is documented in place.ModuleLoadIncludewas also missing the non-constant-args guard thatLoadIncludeshas, so a non-literal module name interpolatedfalseinto its error message. The sharedparseLoadIncludeArgs()sentinel return shape is now documented on the base class — the missing annotation is what let the two rules diverge unnoticed.Testing
Existing LoadIncludes/ModuleLoadInclude rule tests cover the reported messages; full suite, self-analysis, and phpcs are green.
🤖 Generated with Claude Code