1--TEST--
2ZE2 Callbacks of static functions
3--FILE--
4<?php
5class A {
6    public static function who() {
7        echo "A\n";
8    }
9    public static function who2() {
10        echo "A\n";
11    }
12}
13
14class B extends A {
15    public static function who() {
16        echo "B\n";
17    }
18}
19
20class C extends B {
21    public function call($cb) {
22        echo join('|', $cb) . "\n";
23        call_user_func($cb);
24    }
25    public function test() {
26        $this->call(array('parent', 'who'));
27        $this->call(array('C', 'parent::who'));
28        $this->call(array('B', 'parent::who'));
29        $this->call(array('E', 'parent::who'));
30        $this->call(array('A', 'who'));
31        $this->call(array('C', 'who'));
32        $this->call(array('B', 'who2'));
33    }
34}
35
36class D {
37    public static function who() {
38        echo "D\n";
39    }
40}
41
42class E extends D {
43    public static function who() {
44        echo "E\n";
45    }
46}
47
48$o = new C;
49$o->test();
50
51class O {
52    public function who() {
53        echo "O\n";
54    }
55}
56
57class P extends O {
58    function __toString() {
59        return '$this';
60    }
61    public function who() {
62        echo "P\n";
63    }
64    public function call($cb) {
65        echo join('|', $cb) . "\n";
66        call_user_func($cb);
67    }
68    public function test() {
69        $this->call(array('parent', 'who'));
70        $this->call(array('P', 'parent::who'));
71        $this->call(array($this, 'O::who'));
72        try {
73            $this->call(array($this, 'B::who'));
74        } catch (TypeError $e) {
75            echo $e->getMessage(), "\n";
76        }
77    }
78}
79
80echo "===FOREIGN===\n";
81
82$o = new P;
83$o->test();
84
85?>
86--EXPECT--
87parent|who
88B
89C|parent::who
90B
91B|parent::who
92A
93E|parent::who
94D
95A|who
96A
97C|who
98B
99B|who2
100A
101===FOREIGN===
102parent|who
103O
104P|parent::who
105O
106$this|O::who
107O
108$this|B::who
109call_user_func(): Argument #1 ($callback) must be a valid callback, class P is not a subclass of B
110