summaryrefslogtreecommitdiff
path: root/Zend/tests/traits/language006.phpt
blob: 6dc6ba9c981395b105a37dbc13323da8c10bf522 (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!