mirror of
https://github.com/php/php-src.git
synced 2026-04-02 05:32:28 +02:00
Merge branch 'PHP-8.0'
* PHP-8.0: Preserve trait method alias name during preloading
This commit is contained in:
@@ -4147,11 +4147,13 @@ static void preload_fix_trait_methods(zend_class_entry *ce)
|
||||
if (op_array->fn_flags & ZEND_ACC_TRAIT_CLONE) {
|
||||
zend_op_array *orig_op_array = zend_shared_alloc_get_xlat_entry(op_array->opcodes);
|
||||
if (orig_op_array) {
|
||||
zend_string *function_name = op_array->function_name;
|
||||
zend_class_entry *scope = op_array->scope;
|
||||
uint32_t fn_flags = op_array->fn_flags;
|
||||
zend_function *prototype = op_array->prototype;
|
||||
HashTable *ht = op_array->static_variables;
|
||||
*op_array = *orig_op_array;
|
||||
op_array->function_name = function_name;
|
||||
op_array->scope = scope;
|
||||
op_array->fn_flags = fn_flags;
|
||||
op_array->prototype = prototype;
|
||||
|
||||
@@ -45,6 +45,12 @@ class Z {
|
||||
|
||||
class Z2 extends Z {}
|
||||
|
||||
class TraitAliasTest {
|
||||
use T1 {
|
||||
T1::foo as bar;
|
||||
}
|
||||
}
|
||||
|
||||
function get_anon() {
|
||||
return new class {};
|
||||
}
|
||||
|
||||
23
ext/opcache/tests/preload_trait_alias.phpt
Normal file
23
ext/opcache/tests/preload_trait_alias.phpt
Normal file
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Preloading trait uses with aliased names
|
||||
--INI--
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
opcache.preload={PWD}/preload.inc
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once('skipif.inc');
|
||||
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(get_class_methods('TraitAliasTest'));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "bar"
|
||||
[1]=>
|
||||
string(3) "foo"
|
||||
}
|
||||
Reference in New Issue
Block a user