Remove dead code and fix exception messages in legacy rules - #1042
Merged
Conversation
This was referenced Sep 8, 2026
- Extension::parseInfo(): add the missing closing quote in the exception message. - EntityFieldsViaMagicReflectionExtension: throw PHPStan's ShouldNotHappenException instead of a bare LogicException so the failure surfaces as an internal error with context. - PluginManagerSetsCacheBackendRule: return no errors instead of throwing when outside a class, and delete the $cacheKey block whose result was never read. - DiscouragedFunctionsRule: drop 'eval'. It is a language construct and never parses as a function call, so the entry could never match. No user-facing behavior changes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mglaman
force-pushed
the
audit/1c2-legacy-cleanups
branch
from
September 8, 2026 18:14
ad6480b to
60f2868
Compare
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 4 of 9 in the legacy-code audit stack (on top of #1034). Dead code and exception-message cleanups surfaced by auditing the oldest code (2018–2019). No user-facing behavior changes and no release note needed.
What changed
Extension::parseInfo(): add the missing closing quote in the "Cannot read" exception message.EntityFieldsViaMagicReflectionExtension: throw PHPStan'sShouldNotHappenExceptioninstead of a bareLogicExceptionso the failure surfaces as an internal error with context.PluginManagerSetsCacheBackendRule: return no errors instead of throwing when outside a class, and delete the$cacheKeyblock. That block computed the constant strings of the cache key argument and then did nothing with them;$hasCacheBackendSetwas already true before itscontinue, so it was unreachable in effect.DiscouragedFunctionsRule: drop'eval'. It is a language construct, not a function, so it parses asExpr\Eval_and never reached this rule'sFuncCallcheck.Out of scope
PluginManagerSetsCacheBackendRuleshould require a literal cache key. The dead block looks like an abandoned attempt at that. This PR only removes the unreachable code and does not decide it.evalat all. That needs a rule onExpr\Eval_, tracked separately if wanted.Testing
Full suite, self-analysis, and phpcs are green.
🤖 Generated with Claude Code