ID:               39532
 Updated by:       [EMAIL PROTECTED]
 Reported By:      thiago dot henrique dot mata at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Windows Xp Professional
 PHP Version:      5.2.0
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php




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

[2006-11-16 13:04:06] thiago dot henrique dot mata at gmail dot com

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 this bug report at http://bugs.php.net/?id=39532&edit=1

Reply via email to