From: m dot gehin at adan dot asso dot fr
Operating system: winxp
PHP version: 5.0.2
PHP Bug Type: Class/Object related
Bug description: Conflict between __get/__set and ++ operator
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 bug report at http://bugs.php.net/?id=30889&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30889&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=30889&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=30889&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30889&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30889&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30889&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30889&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30889&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30889&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30889&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=30889&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=30889&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30889&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30889&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30889&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30889&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30889&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30889&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30889&r=mysqlcfg