xref: /PHP-7.2/Zend/tests/bug22725.phpt (revision a8d901a8)
1--TEST--
2Bug #22725 (A derived class can call a parent's protected method that calls a private method)
3--FILE--
4<?php
5class Foo {
6    private function aPrivateMethod() {
7        echo "Foo::aPrivateMethod() called.\n";
8    }
9
10    protected function aProtectedMethod() {
11        echo "Foo::aProtectedMethod() called.\n";
12        $this->aPrivateMethod();
13    }
14}
15
16class Bar extends Foo {
17    public function aPublicMethod() {
18        echo "Bar::aPublicMethod() called.\n";
19        $this->aProtectedMethod();
20    }
21}
22
23$o = new Bar;
24$o->aPublicMethod();
25?>
26--EXPECT--
27Bar::aPublicMethod() called.
28Foo::aProtectedMethod() called.
29Foo::aPrivateMethod() called.
30