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