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--EXPECTF-- 87parent|who 88 89Deprecated: Use of "parent" in callables is deprecated in %s on line %d 90B 91C|parent::who 92 93Deprecated: Callables of the form ["C", "parent::who"] are deprecated in %s on line %d 94B 95B|parent::who 96 97Deprecated: Callables of the form ["B", "parent::who"] are deprecated in %s on line %d 98A 99E|parent::who 100 101Deprecated: Callables of the form ["E", "parent::who"] are deprecated in %s on line %d 102D 103A|who 104A 105C|who 106B 107B|who2 108A 109===FOREIGN=== 110parent|who 111 112Deprecated: Use of "parent" in callables is deprecated in %s on line %d 113O 114P|parent::who 115 116Deprecated: Callables of the form ["P", "parent::who"] are deprecated in %s on line %d 117O 118$this|O::who 119 120Deprecated: Callables of the form ["P", "O::who"] are deprecated in %s on line %d 121O 122$this|B::who 123call_user_func(): Argument #1 ($callback) must be a valid callback, class P is not a subclass of B 124