Annotation of embedaddon/php/ext/standard/tests/general_functions/callbacks_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ZE2 Callbacks of static functions
! 3: --FILE--
! 4: <?php
! 5: class A {
! 6: public static function who() {
! 7: echo "A\n";
! 8: }
! 9: public static function who2() {
! 10: echo "A\n";
! 11: }
! 12: }
! 13:
! 14: class B extends A {
! 15: public static function who() {
! 16: echo "B\n";
! 17: }
! 18: }
! 19:
! 20: class 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:
! 36: class D {
! 37: public static function who() {
! 38: echo "D\n";
! 39: }
! 40: }
! 41:
! 42: class E extends D {
! 43: public static function who() {
! 44: echo "E\n";
! 45: }
! 46: }
! 47:
! 48: $o = new C;
! 49: $o->test();
! 50:
! 51: class O {
! 52: public function who() {
! 53: echo "O\n";
! 54: }
! 55: }
! 56:
! 57: class 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:
! 76: echo "===FOREIGN===\n";
! 77:
! 78: $o = new P;
! 79: $o->test();
! 80:
! 81: ?>
! 82: ===DONE===
! 83: --EXPECTF--
! 84: parent|who
! 85: B
! 86: C|parent::who
! 87: B
! 88: B|parent::who
! 89: A
! 90: E|parent::who
! 91: D
! 92: A|who
! 93: A
! 94: C|who
! 95: B
! 96: B|who2
! 97: A
! 98: ===FOREIGN===
! 99: parent|who
! 100: O
! 101: P|parent::who
! 102: O
! 103: $this|O::who
! 104: O
! 105: $this|B::who
! 106:
! 107: Warning: 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===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>