File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / traits / inheritance003.phpt
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:32:17 2013 UTC (11 years, 9 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17, HEAD
5.4.17

--TEST--
Trait method overrides base class method and satisfies prototype
--FILE--
<?php
error_reporting(E_ALL);

abstract class Base {
   public abstract function sayHello(array $a);
}

class SubClass extends Base {
   public function sayHello(array $a) {
     echo "World!\n";
   }
}

$s = new SubClass();
$s->sayHello(array());


trait SayWorld {
   public function sayHello(Base $d) {
     echo 'World!';
   }
}

class MyHelloWorld extends Base {
   use SayWorld;
}

$o = new MyHelloWorld();
$o->sayHello(array());

?>
--EXPECTF--	
World!

Fatal error: Declaration of SayWorld::sayHello(Base $d) must be compatible with Base::sayHello(array $a) in %s on line %d

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>