mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
ee510eed68
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.
62 lines
1.2 KiB
PHP
62 lines
1.2 KiB
PHP
--TEST--
|
|
Bug #45186 (__call depends on __callstatic in class scope)
|
|
--FILE--
|
|
<?php
|
|
|
|
class bar {
|
|
public function __call($a, $b) {
|
|
print "__call:\n";
|
|
var_dump($a);
|
|
}
|
|
static public function __callstatic($a, $b) {
|
|
print "__callstatic:\n";
|
|
var_dump($a);
|
|
}
|
|
public function test() {
|
|
self::ABC();
|
|
bar::ABC();
|
|
call_user_func(array('BAR', 'xyz'));
|
|
call_user_func('BAR::www');
|
|
call_user_func(array('self', 'y'));
|
|
call_user_func('self::y');
|
|
}
|
|
static function x() {
|
|
print "ok\n";
|
|
}
|
|
}
|
|
|
|
$x = new bar;
|
|
|
|
$x->test();
|
|
|
|
call_user_func(array('BAR','x'));
|
|
call_user_func('BAR::www');
|
|
try {
|
|
call_user_func('self::y');
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
__call:
|
|
string(3) "ABC"
|
|
__call:
|
|
string(3) "ABC"
|
|
__call:
|
|
string(3) "xyz"
|
|
__call:
|
|
string(3) "www"
|
|
|
|
Deprecated: Use of "self" in callables is deprecated in %s on line %d
|
|
__call:
|
|
string(1) "y"
|
|
|
|
Deprecated: Use of "self" in callables is deprecated in %s on line %d
|
|
__call:
|
|
string(1) "y"
|
|
ok
|
|
__callstatic:
|
|
string(3) "www"
|
|
call_user_func(): Argument #1 ($callback) must be a valid callback, cannot access "self" when no class scope is active
|