Fixed bug #72594 (Calling an earlier instance of an included anonymous class fatals)

This commit is contained in:
Xinchen Hui 2016-07-14 13:36:43 +08:00
parent 61a2566dc9
commit 8c5b27e061
3 changed files with 45 additions and 3 deletions

2
NEWS
View File

@ -3,6 +3,8 @@ PHP NEWS
?? ??? 2016 PHP 7.0.10
- Core:
. Fixed bug #72594 (Calling an earlier instance of an included anonymous
class fatals). (Laruence)
. Fixed bug #72581 (previous property undefined in Exception after
deserialization). (Laruence)
. Fixed bug #72496 (Cannot declare public method with signature incompatible

33
Zend/tests/bug72594.phpt Normal file
View File

@ -0,0 +1,33 @@
--TEST--
Bug #72594 (Calling an earlier instance of an included anonymous class fatals)
--INI--
opcache.enable=0
--FILE--
<?php
if (isset($runtime)) {
return new class {
public $bar;
public function bing($foo = null) {
if ($foo) $foo->bing();
}
};
}
$runtime = 1;
$oldFoo = require(__FILE__);
$newFoo = require(__FILE__);
var_dump(get_class_methods($oldFoo));
var_dump(get_object_vars($oldFoo));
$newFoo->bing($oldFoo);
?>
--EXPECTF--
array(1) {
[0]=>
string(4) "bing"
}
array(1) {
["bar"]=>
NULL
}

View File

@ -5283,7 +5283,7 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
opline = get_next_op(CG(active_op_array));
zend_make_var_result(&declare_node, opline);
// TODO.AST drop this
/* TODO.AST drop this */
GET_NODE(&FC(implementing_class), opline->result);
opline->op2_type = IS_CONST;
@ -5299,7 +5299,15 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
opline->op1_type = IS_UNUSED;
zend_hash_update_ptr(CG(class_table), lcname, ce);
if (!zend_hash_exists(CG(class_table), lcname)) {
zend_hash_add_ptr(CG(class_table), lcname, ce);
} else {
/* this anonymous class has been included */
zval zv;
ZVAL_PTR(&zv, ce);
destroy_zend_class(&zv);
return;
}
} else {
zend_string *key;
@ -5586,7 +5594,6 @@ void zend_compile_group_use(zend_ast *ast) /* {{{ */
}
/* }}} */
void zend_compile_const_decl(zend_ast *ast) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);