|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-09-12 11:02 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Description: ------------ calling overridden methods from a base class seems inconsistent, when the overridden method is private in the parent class and public in the child class. i do not know which one is the intended mode to work with, but one of them is inconsistent. * the child method gets called when the child declares it protected * the parent method gets called when it's declared public. one of these shouldn't be. Reproduce code: --------------- class A { public function __construct() { $this -> foo(); } private function foo() { echo __METHOD__ . "\r\n"; } } class B extends A { public function foo() { echo __METHOD__ . "\r\n"; } } class C extends A { protected function foo() { echo __METHOD__ . "\r\n"; } } $a = new A(); $b = new B(); $c = new C(); Expected result: ---------------- either ==== A::foo A::foo A::foo ==== or ==== A::foo B::foo C::foo ==== ... i, personally, would prefer the second result. Actual result: -------------- A::foo A::foo C::foo