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