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 $this->call(array($this, 'B::who')); 73 } 74} 75 76echo "===FOREIGN===\n"; 77 78$o = new P; 79$o->test(); 80 81?> 82===DONE=== 83--EXPECTF-- 84parent|who 85B 86C|parent::who 87B 88B|parent::who 89A 90E|parent::who 91D 92A|who 93A 94C|who 95B 96B|who2 97A 98===FOREIGN=== 99parent|who 100O 101P|parent::who 102O 103$this|O::who 104O 105$this|B::who 106 107Warning: call_user_func() expects parameter 1 to be a valid callback, class 'P' is not a subclass of 'B' in %s on line %d 108===DONE=== 109