mirror of
https://github.com/php/php-src.git
synced 2026-03-27 17:52:16 +01:00
Merge branch 'PHP-7.0'
* PHP-7.0: Fixed bug #72594 (Calling an earlier instance of an included anonymous class fatals) Conflicts: Zend/zend_compile.c
This commit is contained in:
33
Zend/tests/bug72594.phpt
Normal file
33
Zend/tests/bug72594.phpt
Normal 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
|
||||
}
|
||||
@@ -5931,7 +5931,15 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
|
||||
opline->opcode = ZEND_DECLARE_ANON_CLASS;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -6218,7 +6226,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);
|
||||
|
||||
Reference in New Issue
Block a user