php.net |  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
Votes:1
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
There should be a way to check if reflected code (object, function, etc.) is from a result of eval or not.

For example;
<?php
$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.


Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 04 05:01:28 2024 UTC