xref: /php-src/Zend/tests/bug41961.phpt (revision 9c144e0d)
1--TEST--
2Bug #41961 (Ensure search for hidden private methods does not stray from class hierarchy)
3--FILE--
4<?php
5X::test();
6
7/** Class X is related to neither ParentClass nor ChildClass. */
8class X {
9  public static function test() {
10    $myChild = new ChildClass;
11    $myChild->secret(); // bug - invokes X::secret() instead of ChildClass::secret()
12  }
13  private function secret() {
14    echo "Called private " . __METHOD__ . "() on an instance of: " . get_class($this) . "\n";
15  }
16}
17
18class ParentClass {
19  private function secret() { }
20}
21
22class ChildClass extends ParentClass {
23  public function secret() {
24    echo "Called public " . __METHOD__ . "() on an instance of: " . get_class($this) . "\n";
25  }
26}
27?>
28--EXPECT--
29Called public ChildClass::secret() on an instance of: ChildClass
30