From:             davcha at nordnet dot fr
Operating system: Windows XP SP2
PHP version:      5.2.1
PHP Bug Type:     Feature/Change Request
Bug description:  Derived class cant call its private method from the context 
of its base class

Description:
------------
A derived class 'SubClass' cannot call a private method declared into
'SubClass' from the context of its parent class 'BaseClass'.

However, even if the private method is called from 'BaseClass', dumping
the variable $this shows the current class type is 'SubClass'.

Reproduce code:
---------------
<?php
class BaseClass {
        public function A($f){
                var_dump($this);
                $this->$f();
        }
}

class SubClass extends BaseClass {
        private function B(){
                echo 'hello, i dont show !';
        }
}

$b = new SubClass();
$b->A('B');
?>

Expected result:
----------------
object(SubClass)#1 (0) { } hello, i dont show !

Actual result:
--------------
object(SubClass)#1 (0) { }
Fatal error: Call to private method SubClass::B() from context 'BaseClass'
in C:\httpd\htdocs\pwidgets\test2.php on line 5


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

Reply via email to