xref: /php-src/ext/standard/tests/array/gh16957.phpt (revision f1fc4e8f)
1--TEST--
2GH-16957 (Assertion failure in array_shift with self-referencing array)
3--FILE--
4<?php
5$new_array = array(&$new_array, 1, 'two');
6var_dump($shifted = array_shift($new_array));
7var_dump($new_array);
8var_dump($new_array === $shifted);
9
10$new_array2 = array(&$new_array2, 2 => 1, 300 => 'two');
11var_dump($shifted = array_shift($new_array2));
12var_dump($new_array2);
13var_dump($new_array2 === $shifted);
14?>
15--EXPECT--
16array(2) {
17  [0]=>
18  int(1)
19  [1]=>
20  string(3) "two"
21}
22array(2) {
23  [0]=>
24  int(1)
25  [1]=>
26  string(3) "two"
27}
28bool(true)
29array(2) {
30  [0]=>
31  int(1)
32  [1]=>
33  string(3) "two"
34}
35array(2) {
36  [0]=>
37  int(1)
38  [1]=>
39  string(3) "two"
40}
41bool(true)
42