From: rampant at gmail dot com
Operating system: WinXP
PHP version: 5.0.1
PHP Bug Type: Class/Object related
Bug description: cannot pass result of __get by reference
Description:
------------
>From outside a class, accessing a variable via a __get is identical to
accessing one via a public member:
$publ->varr
vs.
$gets->varr
When trying to pass by reference, I would expect the corresponding __set
to be called when the value originaly came from a __get. Instead, there is
a Fatal error.
Reproduce code:
---------------
class PublicVar {
public $varr;
}
class GetSetter {
protected $data = array();
function __get($key) {
return $this->data[$key];
}
function __set($key, $value) {
$this->data[$key] = $value;
}
}
function set_by_ref(&$variable) {
$variable = 'has been set, ';
}
$publ = new PublicVar();
set_by_ref($publ->varr);
echo $publ->varr;
$gets = new GetSetter();
set_by_ref($gets->varr);
echo $gets->varr;
Expected result:
----------------
has been set, has been set,
Actual result:
--------------
has been set
Fatal error: Cannot access undefined property for object with overloaded
property access in C:\eclipse\workspace\tmote\tmp_byref.php on line 27
--
Edit bug report at http://bugs.php.net/?id=31109&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31109&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31109&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31109&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31109&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31109&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31109&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31109&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31109&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31109&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31109&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31109&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31109&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31109&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31109&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31109&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31109&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31109&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31109&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31109&r=mysqlcfg