File tree 9 files changed +34
-26
lines changed
9 files changed +34
-26
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class obj implements ArrayAccess {
32
32
33
33
$ o = new obj ;
34
34
$ o ['x ' ] = 1 ;
35
- ++$ o ['x ' ];
35
+ $ ref = &$ o ['x ' ];
36
+ $ ref ++;
36
37
echo $ o ['x ' ], "\n" ;
37
38
?>
38
39
--EXPECT--
Original file line number Diff line number Diff line change 32
32
}
33
33
?>
34
34
--EXPECT--
35
- Cannot increment array
36
- Cannot decrement array
35
+ Cannot increment/decrement object offsets
36
+ Cannot increment/ decrement object offsets
Original file line number Diff line number Diff line change @@ -300,11 +300,7 @@ caught Exception 13
300
300
301
301
Deprecated: Creation of dynamic property class@anonymous::$foo is deprecated in %s on line %d
302
302
caught Exception 14
303
-
304
- Notice: Indirect modification of overloaded element of ArrayAccess@anonymous has no effect in %s on line %d
305
303
caught Exception 15
306
-
307
- Notice: Indirect modification of overloaded element of ArrayAccess@anonymous has no effect in %s on line %d
308
304
caught Exception 16
309
305
caught Exception 17
310
306
caught Exception 18
Original file line number Diff line number Diff line change @@ -21,10 +21,15 @@ var_dump($a->foo);
21
21
$ a [0 ] .= "e50 " ;
22
22
var_dump ($ a ->foo );
23
23
24
- $ a [0 ]--;
24
+ try {
25
+ $ a [0 ]--;
26
+ } catch (Error $ e ) { echo $ e ->getMessage (), "\n" ; }
25
27
var_dump ($ a ->foo );
26
28
27
- --$ a [0 ];
29
+ try {
30
+ --$ a [0 ];
31
+ } catch (Error $ e ) { echo $ e ->getMessage (), "\n" ; }
32
+
28
33
var_dump ($ a ->foo );
29
34
30
35
$ a ->foo = PHP_INT_MIN ;
@@ -59,13 +64,15 @@ offsetSet(11)
59
64
int(1)
60
65
offsetSet(1e50)
61
66
int(1)
62
- int(0)
63
- int(-1)
64
- Cannot decrement a reference held by property ArrayAccess@anonymous::$foo of type int past its minimal value
67
+ Cannot increment/decrement object offsets
68
+ int(1)
69
+ Cannot increment/decrement object offsets
70
+ int(1)
71
+ Cannot increment/decrement object offsets
65
72
integer
66
- Cannot decrement a reference held by property ArrayAccess@anonymous::$foo of type int past its minimal value
73
+ Cannot increment/ decrement object offsets
67
74
integer
68
- Cannot increment a reference held by property ArrayAccess@anonymous::$foo of type int past its maximal value
75
+ Cannot increment/decrement object offsets
69
76
integer
70
- Cannot increment a reference held by property ArrayAccess@anonymous::$foo of type int past its maximal value
77
+ Cannot increment/decrement object offsets
71
78
integer
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ echo "\nIndirect modification:\n";
53
53
$ map [$ obj ] = [];
54
54
$ map [$ obj ][] = 42 ;
55
55
$ map [$ obj2 ] = 41 ;
56
- $ map [$ obj2 ]++;
56
+ try {
57
+ $ map [$ obj2 ]++;
58
+ } catch (Error $ e ) {
59
+ echo $ e ->getMessage (), "\n" ;
60
+ }
57
61
var_dump ($ map );
58
62
59
63
echo "\nMethods: \n" ;
@@ -143,6 +147,7 @@ bool(false)
143
147
Object stdClass#2 not contained in WeakMap
144
148
145
149
Indirect modification:
150
+ Cannot increment/decrement object offsets
146
151
object(WeakMap)#1 (2) {
147
152
[0]=>
148
153
array(2) {
@@ -165,7 +170,7 @@ object(WeakMap)#1 (2) {
165
170
int(2)
166
171
}
167
172
["value"]=>
168
- & int(42 )
173
+ int(41 )
169
174
}
170
175
}
171
176
Original file line number Diff line number Diff line change @@ -5,11 +5,10 @@ Bug #70852 Segfault getting NULL offset of an ArrayObject
5
5
$ y = new ArrayObject ();
6
6
7
7
var_dump ($ y [NULL ]);
8
- var_dump ($ y [NULL ]++);
8
+ $ ref =& $ y [NULL ];
9
+ var_dump ($ ref );
9
10
?>
10
11
--EXPECTF--
11
12
Warning: Undefined array key "" in %s on line %d
12
13
NULL
13
-
14
- Warning: Undefined offset in %s on line %d
15
14
NULL
Original file line number Diff line number Diff line change 1
1
--TEST--
2
- SPL: FixedArray: Trying to access inexistent item
2
+ SPL: FixedArray: Trying to access nonexistent item
3
3
--FILE--
4
4
<?php
5
5
12
12
13
13
?>
14
14
--EXPECT--
15
- OutOfBoundsException: Index invalid or out of range
15
+ Error: Cannot increment/decrement object offsets
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ $obj = new ObjectOne;
41
41
42
42
var_dump ($ obj [1 ]);
43
43
var_dump ($ obj [2 ]);
44
- $ obj [2 ]++;
44
+ $ ref =& $ obj [2 ];
45
+ $ ref ++;
45
46
var_dump ($ obj [2 ]);
46
47
47
48
?>
@@ -50,7 +51,6 @@ ObjectOne::offsetGet(1)
50
51
string(6) "fooBar"
51
52
ObjectOne::offsetGet(2)
52
53
int(1)
53
- ObjectOne::offsetExists(2)
54
54
ObjectOne::offsetGet(2)
55
55
56
56
Notice: Indirect modification of overloaded element of ObjectOne has no effect in %sarray_access_003.php on line 39
Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ $obj = new ObjectOne;
39
39
40
40
var_dump ($ obj [1 ]);
41
41
var_dump ($ obj [2 ]);
42
- $ obj [2 ]++;
42
+ $ ref =& $ obj [2 ];
43
+ $ ref ++;
43
44
var_dump ($ obj [2 ]);
44
45
45
46
?>
@@ -48,7 +49,6 @@ ObjectOne::offsetGet(1)
48
49
string(6) "fooBar"
49
50
ObjectOne::offsetGet(2)
50
51
int(1)
51
- ObjectOne::offsetExists(2)
52
52
ObjectOne::offsetGet(2)
53
53
54
54
Notice: Indirect modification of overloaded element of ObjectOne has no effect in %sarray_access_004.php on line 39
You can’t perform that action at this time.
0 commit comments