summaryrefslogtreecommitdiff
path: root/tests/classes/inheritance_007.phpt
blob: 9115dc00e81e34741532690433deaae304c94c3d (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
40
41
42
43
44
45
46
47
48
49
50
51
--TEST--
Ensure private methods with the same name are not checked for inheritance rules - final
--FILE--
<?php
class A {
    function callYourPrivates() {
        $this->normalPrivate();
        $this->finalPrivate();
    }
    function notOverridden_callYourPrivates() {
        $this->normalPrivate();
        $this->finalPrivate();
    }
    private function normalPrivate() {
        echo __METHOD__ . PHP_EOL;
    }
    final private function finalPrivate() {
        echo __METHOD__ . PHP_EOL;
    }
}
class B extends A {
    function callYourPrivates() {
        $this->normalPrivate();
        $this->finalPrivate();
    }
    private function normalPrivate() {
        echo __METHOD__ . PHP_EOL;
    }
    final private function finalPrivate() {
        echo __METHOD__ . PHP_EOL;
    }
}
$a = new A();
$a->callYourPrivates();
$a->notOverridden_callYourPrivates();
$b = new B();
$b->callYourPrivates();
$b->notOverridden_callYourPrivates();
?>
--EXPECTF--
Warning: Private methods cannot be final as they are never overridden by other classes %s

Warning: Private methods cannot be final as they are never overridden by other classes %s
A::normalPrivate
A::finalPrivate
A::normalPrivate
A::finalPrivate
B::normalPrivate
B::finalPrivate
A::normalPrivate
A::finalPrivate