mirror of
https://github.com/php/php-src.git
synced 2024-10-16 22:12:33 +00:00
b501570ab0
#Getting accustomed to the infrastructure. #Any comments are welcome, especially with regard to syntax and keywords.
39 lines
664 B
PHP
39 lines
664 B
PHP
--TEST--
|
|
Trait method overriddes 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 MyHelloWorld::sayHello() must be compatible with that of Base::sayHello() in %s on line %d
|