error_012.phpt 367 B

12345678910111213141516171819202122
  1. --TEST--
  2. Trying to access a protected trait method
  3. --FILE--
  4. <?php
  5. trait foo {
  6. public function test() { return 3; }
  7. }
  8. class bar {
  9. use foo { test as protected; }
  10. }
  11. $x = new bar;
  12. var_dump($x->test());
  13. ?>
  14. --EXPECTF--
  15. Fatal error: Uncaught Error: Call to protected method bar::test() from global scope in %s:%d
  16. Stack trace:
  17. #0 {main}
  18. thrown in %s on line %d