xref: /php-src/tests/classes/protected_001.phpt (revision d30cd7d7)
1--TEST--
2ZE2 A protected method can only be called inside the class
3--FILE--
4<?php
5
6class pass {
7    protected static function fail() {
8        echo "Call fail()\n";
9    }
10
11    public static function good() {
12        pass::fail();
13    }
14}
15
16pass::good();
17pass::fail();// must fail because we are calling from outside of class pass
18
19echo "Done\n"; // shouldn't be displayed
20?>
21--EXPECTF--
22Call fail()
23
24Fatal error: Uncaught Error: Call to protected method pass::fail() from global scope in %s:%d
25Stack trace:
26#0 {main}
27  thrown in %s on line %d
28