From:             stefaan at netlog dot com
Operating system: OSX, Ubuntu
PHP version:      5.4.20
Package:          Class/Object related
Bug Type:         Bug
Bug description:parent::X() triggers child's __call('X'), instead of parent's 
__call('X')

Description:
------------
In the code example below the parent::getX() call in BB::getX() resolves
to CCC:__call('X') instead of to A:__call('X'), which I would expect.
It seems weird that "parent" in BB:getX() resolves to CCC, which is not
the parent of BB (it's vice versa) nor CCC.


I get this behavior on PHP 5.3.26, but also PHP 5.4.20

Test script:
---------------
class A {
    public function whoami() { return 'A'; }
    public function __call($method, array $args) {
        return 'A::__call::' . $method;
    }
}
class BB extends A
{
    public function whoami() { return 'BB'; }
    public function getX() {
        return 'BB::getX (FYI: parent is ' . parent::whoami(). ') -> ' .
parent::getX() ;
    }
}
class CCC extends BB {
    public function whoami() { return 'CCC'; }
    public function __call($method, array $args) {
        return 'CCC::__call::' . $method . ' -> ' .
parent::__call($method, $args);
    }
}
$c = new CCC();
echo $c->getX() . "\n";


Expected result:
----------------
BB::getX (FYI: parent is A) -> A::__call::getX

Actual result:
--------------
BB::getX (FYI: parent is A) -> CCC::__call::getX -> A::__call::getX

-- 
Edit bug report at https://bugs.php.net/bug.php?id=65828&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65828&r=trysnapshot54
Try a snapshot (PHP 5.5):   
https://bugs.php.net/fix.php?id=65828&r=trysnapshot55
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65828&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65828&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65828&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65828&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65828&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65828&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65828&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65828&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65828&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65828&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65828&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65828&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65828&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65828&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65828&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65828&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65828&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65828&r=mysqlcfg

Reply via email to