You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reflecting a class with an eval()-declared parent emits a file_get_contents() warning #244
When a parsed class inherits methods from an already declared parent, ReflectionClassLikeTrait::wrapInheritedMethod() tries to convert the native inherited methods into parsed ones with ReflectionEngine::parseClass(). ReflectionEngine::locateClassFile() takes the file of a declared class from native reflection. For a class declared by eval() that is a pseudo name such as /path/to/file.php(12) : eval()'d code, and parseFile() then calls file_get_contents() on it:
PHP Warning: file_get_contents(/path/to/probe.php(3) : eval()'d code): Failed to open stream: No such file or directory
in src/ReflectionEngine.php:277
parseFile() throws a ReflectionException right after, which wrapInheritedMethod() catches, so the native method is used as intended. But the warning escapes. Tools that turn warnings into errors fail on it: the Go! AOP cache warm-up reports the file as not woven (found while working on goaop/goaop-symfony-bundle#17).
Reproduction on 4.x:
eval('namespace EvalProbe; class EvalParent { public function inherited(): int { return 1; } }');
// Child.php: namespace EvalProbe; class Child extends EvalParent { public function own(): void {} }$file = newGo\ParserReflection\ReflectionFile(__DIR__ . '/Child.php');
$class = $file->getFileNamespace('EvalProbe')->getClass('EvalProbe\Child');
$class->getMethods(); // warning from file_get_contents()
Proposed fix
In locateClassFile(), when a declared class reports a file name that is not a real file, throw the InvalidArgumentException that callers already treat as "not found", without reading the file. The callers then fall back to native reflection silently. Fix on 4.x; it flows into master through the cascade merge.
Fixed by #246, merged into 4.x and carried into master by the cascade PR #249. GitHub didn't close this automatically because #246 targeted 4.x, not the default branch.
Activity
lisachenko commentedon Nov 2, 2026
Fixed by #246, merged into
4.xand carried intomasterby the cascade PR #249. GitHub didn't close this automatically because #246 targeted4.x, not the default branch.Generated by Claude Code