|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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: Mon Jun 24 00:01:30 2024 UTC