xref: /PHP-8.2/ext/pcre/tests/bug44925.phpt (revision 2f92957f)
1--TEST--
2Bug #44925 (preg_grep() modifies input array)
3--FILE--
4<?php
5$str1 = 'a';
6$str2 = 'b';
7
8$array=Array("1",2,3,1.1,FALSE,NULL,Array(), $str1, &$str2);
9
10var_dump($array);
11
12var_dump(preg_grep('/do not match/',$array));
13
14$a = preg_grep('/./',$array);
15var_dump($a);
16
17$str1 = 'x';
18$str2 = 'y';
19
20var_dump($a); // check if array is still ok
21
22var_dump($array);
23
24?>
25--EXPECTF--
26array(9) {
27  [0]=>
28  string(1) "1"
29  [1]=>
30  int(2)
31  [2]=>
32  int(3)
33  [3]=>
34  float(1.1)
35  [4]=>
36  bool(false)
37  [5]=>
38  NULL
39  [6]=>
40  array(0) {
41  }
42  [7]=>
43  string(1) "a"
44  [8]=>
45  &string(1) "b"
46}
47
48Warning: Array to string conversion in %s on line %d
49array(0) {
50}
51
52Warning: Array to string conversion in %s on line %d
53array(7) {
54  [0]=>
55  string(1) "1"
56  [1]=>
57  int(2)
58  [2]=>
59  int(3)
60  [3]=>
61  float(1.1)
62  [6]=>
63  array(0) {
64  }
65  [7]=>
66  string(1) "a"
67  [8]=>
68  &string(1) "b"
69}
70array(7) {
71  [0]=>
72  string(1) "1"
73  [1]=>
74  int(2)
75  [2]=>
76  int(3)
77  [3]=>
78  float(1.1)
79  [6]=>
80  array(0) {
81  }
82  [7]=>
83  string(1) "a"
84  [8]=>
85  &string(1) "y"
86}
87array(9) {
88  [0]=>
89  string(1) "1"
90  [1]=>
91  int(2)
92  [2]=>
93  int(3)
94  [3]=>
95  float(1.1)
96  [4]=>
97  bool(false)
98  [5]=>
99  NULL
100  [6]=>
101  array(0) {
102  }
103  [7]=>
104  string(1) "a"
105  [8]=>
106  &string(1) "y"
107}
108