|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30889 Conflict between __get/__set and ++ operator
Submitted: 2004-11-25 00:39 UTC Modified: 2005-04-26 15:24 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: m dot gehin at adan dot asso dot fr Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-03-08 OS: winxp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: m dot gehin at adan dot asso dot fr
New email:
PHP Version: OS:


 [2004-11-25 00:39 UTC] m dot gehin at adan dot asso dot fr
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)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-06 18:28 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-03-09 19:02 UTC] 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-04-05 21:54 UTC]
Andi, is it supposed to work so or not?
I.e. is it a docu problem or a bug?
 [2005-04-26 15:24 UTC]
Fixed in CVS HEAD and PHP_5_0
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Mar 03 09:01:23 2021 UTC