1--TEST-- 2false containers behaviour with offsets 3--FILE-- 4<?php 5 6require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; 7 8const EXPECTED_OUTPUT_VALID_OFFSETS = <<<OUTPUT 9Read before write: 10 11Warning: Trying to access array offset on false in %s on line 8 12NULL 13Write: 14 15Deprecated: Automatic conversion of false to array is deprecated in %s on line 15 16Read: 17int(5) 18Read-Write: 19isset(): 20bool(true) 21empty(): 22bool(false) 23null coalesce: 24int(25) 25unset(): 26Nested read: 27 28Warning: Undefined array key %s in %s on line 62 29 30Warning: Trying to access array offset on null in %s on line 62 31NULL 32Nested write: 33Nested Read-Write: 34Nested isset(): 35bool(true) 36Nested empty(): 37bool(false) 38Nested null coalesce: 39int(30) 40Nested unset(): 41 42OUTPUT; 43 44$EXPECTED_OUTPUT_VALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_VALID_OFFSETS) . '$/s'; 45 46const EXPECTF_OUTPUT_FLOAT_OFFSETS = <<<OUTPUT 47Read before write: 48 49Warning: Trying to access array offset on false in %s on line 8 50NULL 51Write: 52 53Deprecated: Automatic conversion of false to array is deprecated in %s on line 15 54 55Deprecated: Implicit conversion from float %F to int loses precision in %s on line 15 56Read: 57 58Deprecated: Implicit conversion from float %F to int loses precision in %s on line 22 59int(5) 60Read-Write: 61 62Deprecated: Implicit conversion from float %F to int loses precision in %s on line 29 63isset(): 64 65Deprecated: Implicit conversion from float %F to int loses precision in %s on line 36 66bool(true) 67empty(): 68 69Deprecated: Implicit conversion from float %F to int loses precision in %s on line 42 70bool(false) 71null coalesce: 72 73Deprecated: Implicit conversion from float %F to int loses precision in %s on line 48 74int(25) 75unset(): 76 77Deprecated: Implicit conversion from float %F to int loses precision in %s on line 55 78Nested read: 79 80Deprecated: Implicit conversion from float %F to int loses precision in %s on line 62 81 82Warning: Undefined array key 0 in %s on line 62 83 84Warning: Trying to access array offset on null in %s on line 62 85NULL 86Nested write: 87 88Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69 89 90Deprecated: Implicit conversion from float %F to int loses precision in %s on line 69 91Nested Read-Write: 92 93Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76 94 95Deprecated: Implicit conversion from float %F to int loses precision in %s on line 76 96Nested isset(): 97 98Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83 99 100Deprecated: Implicit conversion from float %F to int loses precision in %s on line 83 101bool(true) 102Nested empty(): 103 104Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89 105 106Deprecated: Implicit conversion from float %F to int loses precision in %s on line 89 107bool(false) 108Nested null coalesce: 109 110Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95 111 112Deprecated: Implicit conversion from float %F to int loses precision in %s on line 95 113int(30) 114Nested unset(): 115 116Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102 117 118Deprecated: Implicit conversion from float %F to int loses precision in %s on line 102 119 120OUTPUT; 121 122$EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTF_OUTPUT_FLOAT_OFFSETS) . '$/s'; 123 124const EXPECTED_OUTPUT_INVALID_OFFSETS = <<<OUTPUT 125Read before write: 126 127Warning: Trying to access array offset on false in %s on line 8 128NULL 129Write: 130 131Deprecated: Automatic conversion of false to array is deprecated in %s on line 15 132Cannot access offset of type %s on array 133Read: 134Cannot access offset of type %s on array 135Read-Write: 136Cannot access offset of type %s on array 137isset(): 138Cannot access offset of type %s in isset or empty 139empty(): 140Cannot access offset of type %s in isset or empty 141null coalesce: 142Cannot access offset of type %s on array 143unset(): 144Cannot unset offset of type %s on array 145Nested read: 146Cannot access offset of type %s on array 147Nested write: 148Cannot access offset of type %s on array 149Nested Read-Write: 150Cannot access offset of type %s on array 151Nested isset(): 152Cannot access offset of type %s on array 153Nested empty(): 154Cannot access offset of type %s on array 155Nested null coalesce: 156Cannot access offset of type %s on array 157Nested unset(): 158Cannot access offset of type %s on array 159 160OUTPUT; 161 162$EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX = '/^' . expectf_to_regex(EXPECTED_OUTPUT_INVALID_OFFSETS) . '$/s'; 163 164const EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS = <<<OUTPUT 165Read before write: 166 167Warning: Trying to access array offset on false in %s on line 8 168NULL 169Write: 170 171Deprecated: Automatic conversion of false to array is deprecated in %s on line 15 172 173Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 15 174Read: 175 176Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 22 177int(5) 178Read-Write: 179 180Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 29 181isset(): 182 183Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 36 184bool(true) 185empty(): 186 187Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 42 188bool(false) 189null coalesce: 190 191Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 48 192int(25) 193unset(): 194 195Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 55 196Nested read: 197 198Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 62 199 200Warning: Undefined array key 3 in %s on line 62 201 202Warning: Trying to access array offset on null in %s on line 62 203NULL 204Nested write: 205 206Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69 207 208Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 69 209Nested Read-Write: 210 211Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76 212 213Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 76 214Nested isset(): 215 216Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83 217 218Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 83 219bool(true) 220Nested empty(): 221 222Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89 223 224Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 89 225bool(false) 226Nested null coalesce: 227 228Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95 229 230Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 95 231int(30) 232Nested unset(): 233 234Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102 235 236Warning: Resource ID#3 used as offset, casting to integer (3) in %s on line 102 237 238OUTPUT; 239 240ob_start(); 241foreach ($offsets as $dimension) { 242 $container = false; 243 $error = 'false[' . zend_test_var_export($dimension) . '] has different outputs' . "\n"; 244 245 include $var_dim_filename; 246 $varOutput = ob_get_contents(); 247 ob_clean(); 248 $varOutput = str_replace( 249 [$var_dim_filename], 250 ['%s'], 251 $varOutput 252 ); 253 254 if ( 255 !preg_match($EXPECTED_OUTPUT_VALID_OFFSETS_REGEX, $varOutput) 256 && !preg_match($EXPECTED_OUTPUT_INVALID_OFFSETS_REGEX, $varOutput) 257 && !preg_match($EXPECTED_OUTPUT_FLOAT_OFFSETS_REGEX, $varOutput) 258 && $varOutput !== EXPECTED_OUTPUT_RESOURCE_STDERR_OFFSETS 259 ) { 260 file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . "debug_false_container_{$failuresNb}.txt", $varOutput); 261 ++$failuresNb; 262 $failures[] = $error; 263 } 264 ++$testCasesTotal; 265} 266ob_end_clean(); 267 268echo "Executed tests\n"; 269if ($failures !== []) { 270 echo "Failures:\n" . implode($failures); 271} 272 273?> 274--EXPECT-- 275Executed tests 276