1--TEST-- 2JIT ASSIGN_DIM: 002 3--INI-- 4opcache.enable=1 5opcache.enable_cli=1 6opcache.file_update_protection=0 7--EXTENSIONS-- 8opcache 9--FILE-- 10<?php 11function foo() { 12 $var[] = 1; 13 var_dump($var); 14} 15foo(); 16 17function foo1() { 18 $var1[] = true; 19 var_dump($var1); 20} 21foo1(); 22 23function foo2() { 24 $var2[] = array(); 25 var_dump($var2); 26} 27foo2(); 28 29function foo3() { 30 $array = array(PHP_INT_MAX => "dummy"); 31 try { 32 $array[] = array(); 33 } catch (Error $e) { 34 echo $e->getMessage(), "\n"; 35 } 36 37 $array = new ArrayObject(); 38 $array[index()] = 1; 39 $array[offset()] = 2; 40 41 var_dump($array); 42} 43foo3(); 44 45function index() { 46 return 2; 47} 48 49function offset() { 50 return "a"; 51} 52 53function foo4() { 54 $array = array(); 55 $array[] = array(); 56 $array[0][] = 1; 57 $array[0][1] = 1; 58 var_dump($array); 59 60 try { 61 $array[function() {}] = 2; 62 } catch (Error $e) { 63 echo $e->getMessage(), "\n"; 64 } 65 var_dump($array); 66 67 $array2[][] = 3; 68 var_dump($array); 69} 70foo4(); 71 72function foo5() { 73 $a = 1; 74 try { 75 $a[2] = 1; 76 } catch (Error $e) { 77 echo $e->getMessage(), "\n"; 78 } 79 return $a; 80} 81var_dump(foo5()); 82 83function false_to_array($a) { 84 var_dump($a[2] = 1); 85 return $a; 86} 87function false_to_array_append($a) { 88 var_dump($a[] = 1); 89 return $a; 90} 91function false_to_array_invalid_index($a) { 92 var_dump($a[[]] = 1); 93 return $a; 94} 95function false_to_array_nested($a) { 96 var_dump($a[2][3] = 1); 97 return $a; 98} 99function false_to_array_nested_append($a) { 100 var_dump($a[][] = 1); 101 return $a; 102} 103function false_to_array_nested_invalid_index($a) { 104 var_dump($a[[]][0] = 1); 105 return $a; 106} 107var_dump(false_to_array(false)); 108var_dump(false_to_array_append(false)); 109try { 110 var_dump(false_to_array_invalid_index(false)); 111} catch (Error $e) { 112 echo $e->getMessage(), "\n"; 113} 114var_dump(false_to_array_nested(false)); 115var_dump(false_to_array_nested_append(false)); 116try { 117 var_dump(false_to_array_nested_invalid_index(false)); 118} catch (Error $e) { 119 echo $e->getMessage(), "\n"; 120} 121 122function array_access_undef() { 123 $ao = new ArrayObject; 124 $ao[0] = $undef; 125 var_dump($ao[0]); 126} 127 128array_access_undef(); 129?> 130--EXPECTF-- 131array(1) { 132 [0]=> 133 int(1) 134} 135array(1) { 136 [0]=> 137 bool(true) 138} 139array(1) { 140 [0]=> 141 array(0) { 142 } 143} 144Cannot add element to the array as the next element is already occupied 145object(ArrayObject)#%d (1) { 146 ["storage":"ArrayObject":private]=> 147 array(2) { 148 [2]=> 149 int(1) 150 ["a"]=> 151 int(2) 152 } 153} 154array(1) { 155 [0]=> 156 array(2) { 157 [0]=> 158 int(1) 159 [1]=> 160 int(1) 161 } 162} 163Cannot access offset of type Closure on array 164array(1) { 165 [0]=> 166 array(2) { 167 [0]=> 168 int(1) 169 [1]=> 170 int(1) 171 } 172} 173array(1) { 174 [0]=> 175 array(2) { 176 [0]=> 177 int(1) 178 [1]=> 179 int(1) 180 } 181} 182Cannot use a scalar value as an array 183int(1) 184 185Deprecated: Automatic conversion of false to array is deprecated in %s 186int(1) 187array(1) { 188 [2]=> 189 int(1) 190} 191 192Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 193int(1) 194array(1) { 195 [0]=> 196 int(1) 197} 198 199Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 200Cannot access offset of type array on array 201 202Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 203int(1) 204array(1) { 205 [2]=> 206 array(1) { 207 [3]=> 208 int(1) 209 } 210} 211 212Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 213int(1) 214array(1) { 215 [0]=> 216 array(1) { 217 [0]=> 218 int(1) 219 } 220} 221 222Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 223Cannot access offset of type array on array 224 225Warning: Undefined variable $undef in %s on line %d 226NULL 227