language008a.phpt 465 B

1234567891011121314151617181920212223242526
  1. --TEST--
  2. Visibility can be changed with the as aliasing construct as well.
  3. --FILE--
  4. <?php
  5. error_reporting(E_ALL);
  6. trait HelloWorld {
  7. public function sayHello() {
  8. echo 'Hello World!';
  9. }
  10. }
  11. class MyClass {
  12. use HelloWorld { sayHello as protected; }
  13. }
  14. $o = new MyClass;
  15. $o->sayHello();
  16. ?>
  17. --EXPECTF--
  18. Fatal error: Uncaught Error: Call to protected method MyClass::sayHello() from global scope in %s:%d
  19. Stack trace:
  20. #0 {main}
  21. thrown in %s on line %d