From: Marcus Boerger Date: Tue, 5 Feb 2008 18:56:40 +0000 (+0000) Subject: - Add new test X-Git-Tag: RELEASE_2_0_0a1~606 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee507a2d0598bedeec8ad4a0a5009663b110f4ac;p=php - Add new test --- 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 0000000000..852bb46ecf --- /dev/null +++ b/ext/standard/tests/general_functions/callbacks_001.phpt @@ -0,0 +1,112 @@ +--TEST-- +ZE2 Callbacks of static functions +--FILE-- +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 + +Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method O::who() should not be called statically, assuming $this from compatible context P in %s on line %d +O +P|parent::who + +Strict Standards: call_user_func() expects parameter 1 to be a valid callback, non-static method O::who() should not be called statically, assuming $this from compatible context P in %s on line %d +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===