mirror of
https://github.com/php/php-src.git
synced 2024-11-30 05:13:56 +08:00
commit
921e1052db
43
Zend/tests/bug66719.phpt
Normal file
43
Zend/tests/bug66719.phpt
Normal file
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
Bug #66719: Weird behaviour when using get_called_class() with call_user_func()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
public static function who()
|
||||
{
|
||||
var_dump(get_called_class());
|
||||
}
|
||||
}
|
||||
class B extends A
|
||||
{
|
||||
public static function who()
|
||||
{
|
||||
parent::who();
|
||||
}
|
||||
}
|
||||
|
||||
class C
|
||||
{
|
||||
public static function test() {
|
||||
B::who();
|
||||
call_user_func(array(A::class, 'who'));
|
||||
call_user_func(array(B::class, 'parent::who'));
|
||||
}
|
||||
}
|
||||
|
||||
B::who();
|
||||
call_user_func(array(A::class, 'who'));
|
||||
call_user_func(array(B::class, 'parent::who'));
|
||||
|
||||
C::test();
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "B"
|
||||
string(1) "A"
|
||||
string(1) "A"
|
||||
string(1) "B"
|
||||
string(1) "A"
|
||||
string(1) "A"
|
@ -3326,6 +3326,9 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
|
||||
if (error) *error = estrdup("cannot access \"self\" when no class scope is active");
|
||||
} else {
|
||||
fcc->called_scope = zend_get_called_scope(frame);
|
||||
if (!fcc->called_scope || !instanceof_function(fcc->called_scope, scope)) {
|
||||
fcc->called_scope = scope;
|
||||
}
|
||||
fcc->calling_scope = scope;
|
||||
if (!fcc->object) {
|
||||
fcc->object = zend_get_this_object(frame);
|
||||
@ -3339,6 +3342,9 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
|
||||
if (error) *error = estrdup("cannot access \"parent\" when current class scope has no parent");
|
||||
} else {
|
||||
fcc->called_scope = zend_get_called_scope(frame);
|
||||
if (!fcc->called_scope || !instanceof_function(fcc->called_scope, scope->parent)) {
|
||||
fcc->called_scope = scope->parent;
|
||||
}
|
||||
fcc->calling_scope = scope->parent;
|
||||
if (!fcc->object) {
|
||||
fcc->object = zend_get_this_object(frame);
|
||||
|
Loading…
Reference in New Issue
Block a user