blob: da88cbf2cbd46817346d516542aab70e94ba23c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
--TEST--
Typed property on by-ref array dimension
--FILE--
<?php
$a = new class implements ArrayAccess {
public int $foo = 1;
function offsetExists($o) { return 1; }
function &offsetGet($o) { return $this->foo; }
function offsetSet($o, $v) { print "offsetSet($v)\n"; }
function offsetUnset($o) { print "offsetUnset() ?!?"; }
};
$a[0] += 1;
var_dump($a->foo);
$a[0] .= "1";
var_dump($a->foo);
$a[0] .= "e50";
var_dump($a->foo);
$a[0]--;
var_dump($a->foo);
--$a[0];
var_dump($a->foo);
$a->foo = PHP_INT_MIN;
try {
$a[0]--;
} catch (Error $e) { echo $e->getMessage(), "\n"; }
echo gettype($a->foo),"\n";
try {
--$a[0];
} catch (Error $e) { echo $e->getMessage(), "\n"; }
echo gettype($a->foo),"\n";
$a->foo = PHP_INT_MAX;
try {
$a[0]++;
} catch (Error $e) { echo $e->getMessage(), "\n"; }
echo gettype($a->foo),"\n";
try {
++$a[0];
} catch (Error $e) { echo $e->getMessage(), "\n"; }
echo gettype($a->foo),"\n";
?>
--EXPECT--
offsetSet(2)
int(1)
offsetSet(11)
int(1)
offsetSet(1e50)
int(1)
int(0)
int(-1)
Cannot decrement a reference held by property class@anonymous::$foo of type int past its minimal value
integer
Cannot decrement a reference held by property class@anonymous::$foo of type int past its minimal value
integer
Cannot increment a reference held by property class@anonymous::$foo of type int past its maximal value
integer
Cannot increment a reference held by property class@anonymous::$foo of type int past its maximal value
integer
|