xref: /PHP-8.2/Zend/tests/bug30889.phpt (revision b64823de)
1--TEST--
2Bug #30889 (Conflict between __get/__set and ++ operator)
3--FILE--
4<?php
5class overloaded
6{
7  private $values;
8  function __construct()
9  {
10    $this->values = array('a' => 0);
11  }
12  function __set($name, $value)
13  {
14    print "set $name = $value ($name was ".$this->values[$name].")\n";
15    $this->values[$name] = $value;
16  }
17  function __get($name)
18  {
19    print "get $name (returns ".$this->values[$name].")\n";
20    return $this->values[$name];
21  }
22}
23$test = new overloaded();
24$test->a++;     // __get(), then __set()
25++$test->a;
26?>
27--EXPECT--
28get a (returns 0)
29set a = 1 (a was 0)
30get a (returns 1)
31set a = 2 (a was 1)
32