xref: /PHP-8.0/Zend/tests/bug45186.phpt (revision 840e441d)
1--TEST--
2Bug #45186 (__call depends on __callstatic in class scope)
3--FILE--
4<?php
5
6class bar  {
7    public function __call($a, $b) {
8        print "__call:\n";
9        var_dump($a);
10    }
11    static public function __callstatic($a, $b) {
12        print "__callstatic:\n";
13        var_dump($a);
14    }
15    public function test() {
16        self::ABC();
17        bar::ABC();
18        call_user_func(array('BAR', 'xyz'));
19        call_user_func('BAR::www');
20        call_user_func(array('self', 'y'));
21        call_user_func('self::y');
22    }
23    static function x() {
24        print "ok\n";
25    }
26}
27
28$x = new bar;
29
30$x->test();
31
32call_user_func(array('BAR','x'));
33call_user_func('BAR::www');
34try {
35    call_user_func('self::y');
36} catch (TypeError $e) {
37    echo $e->getMessage(), "\n";
38}
39
40?>
41--EXPECT--
42__call:
43string(3) "ABC"
44__call:
45string(3) "ABC"
46__call:
47string(3) "xyz"
48__call:
49string(3) "www"
50__call:
51string(1) "y"
52__call:
53string(1) "y"
54ok
55__callstatic:
56string(3) "www"
57call_user_func(): Argument #1 ($callback) must be a valid callback, cannot access "self" when no class scope is active
58