blob: 5a32359bb553fabf422dfde8282029af916973ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
--TEST--
Express requirements of a trait by abstract methods.
--FILE--
<?php
error_reporting(E_ALL);
trait Hello {
public function sayHelloWorld() {
echo 'Hello'.$this->getWorld();
}
abstract public function getWorld();
}
class MyHelloWorld {
private $world;
use Hello;
public function getWorld() {
return $this->world;
}
public function setWorld($val) {
$this->world = $val;
}
}
$o = new MyHelloWorld();
$o->setWorld(' World!');
$o->sayHelloWorld();
?>
--EXPECTF--
Hello World!
|