bug41961.phpt 787 B

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