language014.phpt 508 B

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Aliasing leading to conflict should result in error message
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL);
  6. trait Hello {
  7. public function hello() {
  8. echo 'Hello';
  9. }
  10. }
  11. trait World {
  12. public function world() {
  13. echo ' World!';
  14. }
  15. }
  16. class MyClass {
  17. use Hello, World { world as hello; }
  18. }
  19. $o = new MyClass();
  20. $o->hello();
  21. $o->world();
  22. ?>
  23. --EXPECTF--
  24. Fatal error: Trait method World::world has not been applied as MyClass::hello, because of collision with Hello::hello in %s on line %d