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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC