Bug #73816 [Opn]: Broken eval(anonymous class)
| From: | nicolas dot grekas+php at gmail dot com | Date: | Mon, 26 Dec 2016 12:48:12 +0000 |
| Subject: | Bug #73816 [Opn]: Broken eval(anonymous class) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206211@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73816&edit=1
ID: 73816
User updated by: nicolas dot grekas+php at gmail dot com
Reported by: nicolas dot grekas+php at gmail dot com
Summary: Broken eval(anonymous class)
Status: Open
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.1.0
Block user comment: N
Private report: N
New Comment:
Maybe introduced by the fix for https://bugs.php.net/72594
?
Previous Comments:
------------------------------------------------------------------------
[2016-12-26 12:34:40] nicolas dot grekas+php at gmail dot com
Description:
------------
Calling several times eval() to create different anonymous classes doesn't create new anonymous
classes but always returns the first one.
Used to work until 7.0.10 & 7.1.0 which both have the bug.
See https://3v4l.org/t7c5Z
Test script:
---------------
<?php
function anon()
{
static $i = 0;
return eval(sprintf('return new class { private $prop%s; };', ++$i));
}
var_dump(anon());
var_dump(anon());
Expected result:
----------------
object(class@anonymous)#1 (1) { ["prop1":"class@anonymous":private]=> NULL }
object(class@anonymous)#1 (1) { ["prop2":"class@anonymous":private]=> NULL }
Actual result:
--------------
object(class@anonymous)#1 (1) { ["prop1":"class@anonymous":private]=> NULL }
object(class@anonymous)#1 (1) { ["prop1":"class@anonymous":private]=> NULL }
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73816&edit=1