#38176 [NEW]: overloading is ignored when using reference

From: Date: Fri, 21 Jul 2006 15:04:56 +0000
Subject: #38176 [NEW]: overloading is ignored when using reference
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-99713@lists.php.net to get a copy of this message
From: pedro dot leite dot rocha at gmail dot com Operating system: Linux 2.6.15-26-686 PHP version: 5.1.4 PHP Bug Type: Class/Object related Bug description: overloading is ignored when using reference Description: ------------ When using overloading with the special function __set, and passing the value by reference, the overload is ignored, and a new attribute for the class object is created. I'm not sure if this is a bug, but I couldn't find anything like it in the documentation, or in the bug list. Appreciate the help. []'s Reproduce code: --------------- class A { private $v; function __construct() { echo "constructing...\n"; } function __set($key, $value) { echo "setting ".$key."\n"; $this->v[$key] = $value; } } $foo = "bar"; $a = new A; echo "without reference:\n"; $a->user = $foo; echo "with reference:\n"; $a->user =& $foo; var_dump($a); Expected result: ---------------- constructing... without reference: setting user with reference: object(A)#1 (2) { ["v:private"]=> array(1) { ["user"]=> &string(3) "bar" } } Actual result: -------------- constructing... without reference: setting user with reference: object(A)#1 (2) { ["v:private"]=> array(1) { ["user"]=> string(3) "bar" } ["user"]=> &string(3) "bar" } -- Edit bug report at http://bugs.php.net/?id=38176&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38176&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38176&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38176&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38176&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38176&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38176&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38176&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38176&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38176&r=support Expected behavior: http://bugs.php.net/fix.php?id=38176&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38176&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38176&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38176&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38176&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38176&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38176&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38176&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38176&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38176&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38176&r=mysqlcfg

« previous php.bugs (#99713) next »