xref: /PHP-8.0/tests/classes/protected_002.phpt (revision d30cd7d7)
1--TEST--
2ZE2 A protected method cannot be called in another class
3--FILE--
4<?php
5
6class pass {
7    protected static function show() {
8        echo "Call pass::show()\n";
9    }
10
11    public static function do_show() {
12        pass::show();
13    }
14}
15
16pass::do_show();
17
18class fail {
19    public static function show() {
20        echo "Call fail::show()\n";
21        pass::show();
22    }
23}
24
25fail::show();
26
27echo "Done\n"; // shouldn't be displayed
28?>
29--EXPECTF--
30Call pass::show()
31Call fail::show()
32
33Fatal error: Uncaught Error: Call to protected method pass::show() from scope fail in %s:%d
34Stack trace:
35#0 %s(%d): fail::show()
36#1 {main}
37  thrown in %s on line %d
38