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