xref: /PHP-8.1/Zend/tests/traits/language007.phpt (revision f8d79582)
1--TEST--
2Traits can fulfill the requirements of abstract base classes.
3--FILE--
4<?php
5error_reporting(E_ALL);
6
7abstract class Base {
8  abstract function sayWorld();
9}
10
11trait Hello {
12   public function sayHello() {
13     echo 'Hello';
14   }
15   public function sayWorld() {
16     echo ' World!';
17   }
18 }
19
20class MyHelloWorld extends Base {
21    use Hello;
22}
23
24$o = new MyHelloWorld();
25$o->sayHello();
26$o->sayWorld();
27
28?>
29--EXPECT--
30Hello World!
31