ID:               38772
 Updated by:       [EMAIL PROTECTED]
 Reported By:      axo at axolander dot de
-Status:           Open
+Status:           Closed
 Bug Type:         Class/Object related
 Operating System: fedora core
 PHP Version:      5.1.6
-Assigned To:      
+Assigned To:      dmitry
 New Comment:

Fixed in CVS HEAD and PHP_5_2


Previous Comments:
------------------------------------------------------------------------

[2006-09-10 19:51:31] axo at axolander dot de

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



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38772&edit=1

Reply via email to