From: Bertrand dot Willm at laposte dot net
Operating system: Windows XP
PHP version: 5.0.0b1 (beta1)
PHP Bug Type: Class/Object related
Bug description: access to private or protected member throw __get and __set method
Description:
------------
I want to have access to private or protected member throw __get and __set
method to control the access or just to let a read access to this member
(and then __set is not used).
To do that I have to choose an other name for this property.
I can't use the same name as the private member.
PHP could test if there is __get or __set method and use them before
telling ther is an error.
Reproduce code:
---------------
<?php
class CBaseClass {
private $var = 'default';
function __get($name)
{
return $this->var;
}
}
$object = new CBaseClass();
echo $object->var;
?>
Expected result:
----------------
default
Actual result:
--------------
Fatal error: Cannot access private property cbaseclass::$var in
c:\sitesweb\www\test.php5 on line 11
--
Edit bug report at http://bugs.php.net/?id=24808&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24808&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24808&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=24808&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24808&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24808&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24808&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24808&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24808&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24808&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24808&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24808&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24808&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24808&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24808&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24808&r=gnused