ID:               31109
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rampant at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: WinXP
 PHP Version:      5.0.1
 New Comment:

Duplicate of #28444, as was pointed by Dennis.


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

[2004-12-16 12:46:27] dennis at inmarket dot lviv dot ua

This is bug #28444

------------------------------------------------------------------------

[2004-12-16 06:27:13] rampant at gmail dot com

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

Reply via email to