From: thiago dot henrique dot mata at gmail dot com
Operating system: Windows Xp Professional
PHP version: 5.2.0
PHP Bug Type: Class/Object related
Bug description: Error in acess a private attribute in a extended method
Description:
------------
A extend method cannot acess a private attribute but if this be rewrite
it's does.
Reproduce code:
---------------
<?php
class parentClass{
public function setMyPrivateValues( $arrData ){
foreach( $arrData as $strKey => $mixValue ){ $this->$strKey =
$mixValue;
}
}
}
class childClass extends parentClass{
private $strName;
}
class childClass2 extends childClass{
public function setMyPrivateValues( $arrData ){
foreach( $arrData as $strKey => $mixValue ){ $this->$strKey =
$mixValue;
}
}
}
$arrData = array( 'strName' => 'jonh' );
$objChild2 = new childClass2(); // If i rewrite the method
$objChild2->setMyPrivateValues( $arrData ); // Set a private attribute
$objChild = new childClass(); // If i dont rewrite the method
$objChild->setMyPrivateValues( $arrData ); // Set a private attribute
?>
Expected result:
----------------
both class changed.
Actual result:
--------------
Fatal error: Cannot access private property childClass::$strName in
nameFile.php on line 4
--
Edit bug report at http://bugs.php.net/?id=39532&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39532&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39532&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39532&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39532&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39532&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39532&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39532&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39532&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39532&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39532&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39532&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39532&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39532&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39532&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39532&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39532&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39532&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39532&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39532&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39532&r=mysqlcfg