summaryrefslogtreecommitdiff
path: root/tests/classes/private_003b.phpt
blob: 6b231c55758e3cb49a9aadb094225052980f35df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--TEST--
ZE2 A private method cannot be called in a derived class
--FILE--
<?php

class pass {
    private function show() {
        echo "Call show()\n";
    }

    protected function good() {
        $this->show();
    }
}

class fail extends pass {
    public function ok() {
        $this->good();
    }

    public function not_ok() {
        $this->show();
    }
}

$t = new fail();
$t->ok();
$t->not_ok(); // calling a private function

echo "Done\n"; // shouldn't be displayed
?>
--EXPECTF--
Call show()

Fatal error: Uncaught Error: Call to private method pass::show() from scope fail in %s:%d
Stack trace:
#0 %s(%d): fail->not_ok()
#1 {main}
  thrown in %s on line %d