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