|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63901 Expose eval'd code with reflection
Submitted: 2013-01-04 13:39 UTC Modified: 2013-01-05 04:12 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: franssen dot roland at gmail dot com Assigned:
Status: Open Package: Reflection related
PHP Version: 5.4.10 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: franssen dot roland at gmail dot com
New email:
PHP Version: OS:


 [2013-01-04 13:39 UTC] franssen dot roland at gmail dot com
There should be a way to check if reflected code (object, function, etc.) is from a result of eval or not.

For example;
$o = eval('class Foo { } return new Foo;');
$r = new ReflectionObject($o);
if($r->isUserDefined()) {
    $file = $r->getFilename();
    // do something with $file

We cannot assume $file will contain a valid file path as it returns something like "/file.php:(2) eval()'d code" (rather than false imho).

Adding ReflectionObject::isSynthetic() or isEval() would be a nice feature. Please consider to return false in getFilename() for eval'd as well so "getFilename() !== false" indicates a true user defined object.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 08:01:29 2024 UTC