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