diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/general_functions/callbacks_001.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/general_functions/callbacks_001.phpt')
-rw-r--r-- | ext/standard/tests/general_functions/callbacks_001.phpt | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/ext/standard/tests/general_functions/callbacks_001.phpt b/ext/standard/tests/general_functions/callbacks_001.phpt new file mode 100644 index 0000000..a58f19d --- /dev/null +++ b/ext/standard/tests/general_functions/callbacks_001.phpt @@ -0,0 +1,108 @@ +--TEST-- +ZE2 Callbacks of static functions +--FILE-- +<?php +class A { + public static function who() { + echo "A\n"; + } + public static function who2() { + echo "A\n"; + } +} + +class B extends A { + public static function who() { + echo "B\n"; + } +} + +class C extends B { + public function call($cb) { + echo join('|', $cb) . "\n"; + call_user_func($cb); + } + public function test() { + $this->call(array('parent', 'who')); + $this->call(array('C', 'parent::who')); + $this->call(array('B', 'parent::who')); + $this->call(array('E', 'parent::who')); + $this->call(array('A', 'who')); + $this->call(array('C', 'who')); + $this->call(array('B', 'who2')); + } +} + +class D { + public static function who() { + echo "D\n"; + } +} + +class E extends D { + public static function who() { + echo "E\n"; + } +} + +$o = new C; +$o->test(); + +class O { + public function who() { + echo "O\n"; + } +} + +class P extends O { + function __toString() { + return '$this'; + } + public function who() { + echo "P\n"; + } + public function call($cb) { + echo join('|', $cb) . "\n"; + call_user_func($cb); + } + public function test() { + $this->call(array('parent', 'who')); + $this->call(array('P', 'parent::who')); + $this->call(array($this, 'O::who')); + $this->call(array($this, 'B::who')); + } +} + +echo "===FOREIGN===\n"; + +$o = new P; +$o->test(); + +?> +===DONE=== +--EXPECTF-- +parent|who +B +C|parent::who +B +B|parent::who +A +E|parent::who +D +A|who +A +C|who +B +B|who2 +A +===FOREIGN=== +parent|who +O +P|parent::who +O +$this|O::who +O +$this|B::who + +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 +===DONE=== |