Annotation of embedaddon/php/Zend/tests/traits/inheritance003.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Trait method overrides base class method and satisfies prototype
3: --FILE--
4: <?php
5: error_reporting(E_ALL);
6:
7: abstract class Base {
8: public abstract function sayHello(array $a);
9: }
10:
11: class SubClass extends Base {
12: public function sayHello(array $a) {
13: echo "World!\n";
14: }
15: }
16:
17: $s = new SubClass();
18: $s->sayHello(array());
19:
20:
21: trait SayWorld {
22: public function sayHello(Base $d) {
23: echo 'World!';
24: }
25: }
26:
27: class MyHelloWorld extends Base {
28: use SayWorld;
29: }
30:
31: $o = new MyHelloWorld();
32: $o->sayHello(array());
33:
34: ?>
35: --EXPECTF--
36: World!
37:
38: Fatal error: Declaration of MyHelloWorld::sayHello() must be compatible with Base::sayHello(array $a) in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>