abstract-methods04.phpt 566 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Abstract Trait Methods should behave like common abstract methods and
  3. implementstion may be provided by other traits. Sorting order shouldn't influence result.
  4. --FILE--
  5. <?php
  6. error_reporting(E_ALL);
  7. trait THello {
  8. public abstract function hello();
  9. }
  10. trait THelloImpl {
  11. public function hello() {
  12. echo 'Hello';
  13. }
  14. }
  15. class TraitsTest1 {
  16. use THello;
  17. use THelloImpl;
  18. }
  19. $test = new TraitsTest1();
  20. $test->hello();
  21. class TraitsTest2 {
  22. use THelloImpl;
  23. use THello;
  24. }
  25. $test = new TraitsTest2();
  26. $test->hello();
  27. ?>
  28. --EXPECT--
  29. HelloHello