Repository navigation
fix(engine): report a class declared by eval() as not found instead of reading its pseudo file - #246
Merged
Merged
Conversation
…f reading its pseudo file
ReflectionEngine::locateClassFile() takes the file of an already declared class
from native reflection. For a class declared by eval() that is a pseudo name
("file.php(12) : eval()'d code"), and parseFile() raised a file_get_contents()
warning before failing. Reflecting a class that inherits methods from such a
parent emitted the warning, which tools that treat warnings as errors (the
Go! AOP cache warm-up) report as a failure. The class is now reported as not
found, so the callers fall back to native reflection without a warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxhC1DaSZY1jAz2XfyjhPa
Member
Author
|
PHPStan analysis - PHP8.4 fails here, but not because of this PR. The only error is Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1DaSZY1jAz2XfyjhPa
lisachenko
marked this pull request as ready for review
November 2, 2026 17:25
This was referenced Nov 2, 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.
Summary
Fixes #244.
ReflectionEngine::locateClassFile()now throws theInvalidArgumentExceptionthat callers already treat as "not found" when an already declared class reports a file name that isn't a real file (file.php(12) : eval()'d code). Before,parseFile()ranfile_get_contents()on that pseudo name and emitted a warning before failing. Reflecting a class that inherits methods from aneval()-declared parent still falls back to the native methods, now without the warning.Targets
4.x;cascade-merge.ymlcarries it intomasterafter the merge.Changes
src/ReflectionEngine.php:is_file()check on the file name from native reflection. Only the branch for already declared classes is affected; the locator branch is unchanged.tests/EvalDeclaredParentTest.phpwith the stubtests/Stub/FileWithEvalDeclaredParent.php(not part ofgetFilesToAnalyze(), it extends a class that only exists after theeval()):locateClassFile()reports aneval()-declared class as not found;getMethods()on a child of aneval()-declared parent emits no warning and still returns the inherited method.Testing
4.xwithout the change and pass with it.vendor/bin/phpunit: OK (13749 tests; the 133 skipped and 2 incomplete are already on4.x).vendor/bin/phpstan analyse src: 1 error, which4.xalready has without this change:Traits/ReflectionClassLikeTrait.php:1303, "Strict comparison using === between (int|string) and null will always evaluate to false".Generated by Claude Code