#30889 [Asn->Csd]: Conflict between __get/__set and ++ operator
| From: | dmitry@php.net | Date: | Tue, 26 Apr 2005 13:24:45 +0000 |
| Subject: | #30889 [Asn->Csd]: Conflict between __get/__set and ++ operator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-78231@lists.php.net to get a copy of this message | ||
ID: 30889
Updated by: dmitry@php.net
Reported By: m dot gehin at adan dot asso dot fr
-Status: Assigned
+Status: Closed
Bug Type: Zend Engine 2 problem
Operating System: winxp
PHP Version: 5CVS-2005-03-08
Assigned To: andi
New Comment:
Fixed in CVS HEAD and PHP_5_0
Previous Comments:
------------------------------------------------------------------------
[2005-04-05 21:54:03] tony2001@php.net
Andi, is it supposed to work so or not?
I.e. is it a docu problem or a bug?
------------------------------------------------------------------------
[2005-03-09 19:02:42] m dot gehin at adan dot asso dot fr
Unfortunately this snapshot doesn't solve the problem
Snapshot version :
Sun, 06 Mar 2005 20:50:26 +0100
Version: 5.1.0-dev
Branch: HEAD
Build: Release_TS
------------------------------------------------------------------------
[2005-03-06 18:28:46] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-11-25 00:39:59] m dot gehin at adan dot asso dot fr
Description:
------------
When using the ++ operator on a property that is overloaded, the value
inside the class is incremented *BEFORE* the call to the __set()
method.
Reproduce code:
---------------
class overloaded
{
private $values;
function __construct()
{
$this->values = array('a' => 0);
}
function __set($name, $value)
{
print "<br>set $name = $value ($name was
".$this->values[$name].")";
$this->values[$name] = $value;
}
function __get($name)
{
print "<br>get $name (returns ".$this->values[$name].")";
return $this->values[$name];
}
}
$test = new overloaded();
$test->a++; // __get(), then __set()
Expected result:
----------------
get a (returns 0)
set a = 1 (a was 0)
Actual result:
--------------
get a (returns 0)
set a = 1 (a was 1)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30889&edit=1