Skip to content

Commit f01c842

Browse files
committed
- Update tests to reflect current situation
# I don't feel like discussing this issue anymore - maybe we need to find # a way of returning proxies to get the requested behavior back - i'll give # it a try for PHP 5.2. So long we'll have to stay with the original # decision that we don't support references at all with ArrayAccess.
1 parent 21ce939 commit f01c842

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

tests/classes/array_access_003.phpt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class object implements ArrayAccess {
1212
echo __METHOD__ . "($index)\n";
1313
return array_key_exists($index, $this->a);
1414
}
15-
function &offsetGet($index) {
15+
function offsetGet($index) {
1616
echo __METHOD__ . "($index)\n";
1717
switch($index) {
1818
case 1:
@@ -48,12 +48,9 @@ var_dump($obj[2]);
4848
===DONE===
4949
--EXPECTF--
5050
object::offsetGet(1)
51-
52-
Strict Standards: Only variable references should be returned by reference in %sarray_access_003.php on line %d
5351
string(6) "fooBar"
5452
object::offsetGet(2)
5553
int(1)
5654
object::offsetGet(2)
57-
object::offsetGet(2)
58-
int(2)
59-
===DONE===
55+
56+
Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in %sarray_access_003.php on line %d

tests/classes/array_access_005.phpt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Peoples implements ArrayAccess {
1414
return array_key_exists($this->person, $index);
1515
}
1616

17-
function &offsetGet($index) {
17+
function offsetGet($index) {
1818
return $this->person[$index];
1919
}
2020

@@ -39,20 +39,34 @@ echo "---ArrayOverloading---\n";
3939

4040
$people = new Peoples;
4141

42+
var_dump($people[0]);
4243
var_dump($people[0]['name']);
43-
$people[0]['name'] = $people->person[0]['name'] . 'Foo';
44+
var_dump($people->person[0]['name'] . 'Foo'); // impossible to assign this since we don't return references here
45+
$x = $people[0]; // creates a copy
46+
$x['name'] .= 'Foo';
47+
$people[0] = $x;
48+
var_dump($people[0]);
49+
$people[0]['name'] = 'JoeFoo';
4450
var_dump($people[0]['name']);
45-
$people[0]['name'] .= 'Bar';
51+
$people[0]['name'] = 'JoeFooBar';
4652
var_dump($people[0]['name']);
4753

48-
echo "---Done---\n";
4954
?>
50-
--EXPECT--
55+
===DONE===
56+
--EXPECTF--
5157
string(3) "Joe"
5258
string(6) "JoeFoo"
5359
string(9) "JoeFooBar"
5460
---ArrayOverloading---
61+
array(1) {
62+
["name"]=>
63+
string(3) "Joe"
64+
}
5565
string(3) "Joe"
5666
string(6) "JoeFoo"
57-
string(9) "JoeFooBar"
58-
---Done---
67+
array(1) {
68+
["name"]=>
69+
string(6) "JoeFoo"
70+
}
71+
72+
Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in %sarray_access_005.php on line %d

tests/classes/array_access_008.phpt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Peoples implements ArrayAccess {
1414
return array_key_exists($this->person, $index);
1515
}
1616

17-
function & offsetGet($index) {
17+
function offsetGet($index) {
1818
return $this->person[$index];
1919
}
2020

@@ -39,6 +39,8 @@ echo "===ArrayOverloading===\n";
3939

4040
$people = new Peoples;
4141

42+
var_dump($people[0]['name']);
43+
$people[0]['name'] = 'FooBar';
4244
var_dump($people[0]['name']);
4345
$people[0]['name'] = $people->person[0]['name'] . 'Bar';
4446
var_dump($people[0]['name']);
@@ -47,12 +49,11 @@ var_dump($people[0]['name']);
4749

4850
?>
4951
===DONE===
50-
--EXPECT--
52+
--EXPECTF--
5153
string(3) "Foo"
5254
string(6) "FooBar"
5355
string(9) "FooBarBaz"
5456
===ArrayOverloading===
5557
string(3) "Foo"
56-
string(6) "FooBar"
57-
string(9) "FooBarBaz"
58-
===DONE===
58+
59+
Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in %sarray_access_008.php on line %d

0 commit comments

Comments
 (0)