From:             axo at axolander dot de
Operating system: fedora core
PHP version:      5.1.6
PHP Bug Type:     Class/Object related
Bug description:  inconsistent overriding of methods in different visibility 
contexts

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 bug report at http://bugs.php.net/?id=38772&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38772&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38772&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38772&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38772&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38772&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38772&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38772&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38772&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38772&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38772&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38772&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38772&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38772&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38772&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38772&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38772&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38772&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38772&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38772&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38772&r=mysqlcfg

Reply via email to