php-src/Zend/tests/bug66719.phpt
Nikita Popov ee510eed68 Deprecate partially supported callables
This deprecates all callables that are accepted by
call_user_func($callable) but not by $callable(). In particular:

    "self::method"
    "parent::method"
    "static::method"
    ["self", "method"]
    ["parent", "method"]
    ["static", "method"]
    ["Foo", "Bar::method"]
    [new Foo, "Bar::method"]

RFC: https://wiki.php.net/rfc/deprecate_partially_supported_callables

Closes GH-7446.
2021-10-22 10:15:24 +02:00

48 lines
854 B
PHP

--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();
?>
--EXPECTF--
string(1) "B"
string(1) "A"
Deprecated: Callables of the form ["B", "parent::who"] are deprecated in %s on line %d
string(1) "A"
string(1) "B"
string(1) "A"
Deprecated: Callables of the form ["B", "parent::who"] are deprecated in %s on line %d
string(1) "A"