|
| 1 | +--TEST-- |
| 2 | +Behaviour of increment/decrement with various container types |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | + |
| 6 | +require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; |
| 7 | + |
| 8 | +foreach ($allContainers as $container) { |
| 9 | + echo zend_test_var_export($container), '[0]', "\n"; |
| 10 | + |
| 11 | + try { |
| 12 | + var_dump($container[0]++); |
| 13 | + } catch (Throwable $e) { |
| 14 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 15 | + } |
| 16 | + try { |
| 17 | + var_dump($container[0]--); |
| 18 | + } catch (Throwable $e) { |
| 19 | + echo $e::class, ': ', $e->getMessage(), PHP_EOL; |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +?> |
| 24 | +--EXPECTF-- |
| 25 | +NULL[0] |
| 26 | + |
| 27 | +Warning: Undefined array key 0 in %s on line %d |
| 28 | +NULL |
| 29 | +int(1) |
| 30 | +false[0] |
| 31 | + |
| 32 | +Deprecated: Automatic conversion of false to array is deprecated in %s on line %d |
| 33 | + |
| 34 | +Warning: Undefined array key 0 in %s on line %d |
| 35 | +NULL |
| 36 | +int(1) |
| 37 | +true[0] |
| 38 | +Error: Cannot use a scalar value as an array |
| 39 | +Error: Cannot use a scalar value as an array |
| 40 | +4[0] |
| 41 | +Error: Cannot use a scalar value as an array |
| 42 | +Error: Cannot use a scalar value as an array |
| 43 | +5.5[0] |
| 44 | +Error: Cannot use a scalar value as an array |
| 45 | +Error: Cannot use a scalar value as an array |
| 46 | +'10'[0] |
| 47 | +Error: Cannot increment/decrement string offsets |
| 48 | +Error: Cannot increment/decrement string offsets |
| 49 | +'25.5'[0] |
| 50 | +Error: Cannot increment/decrement string offsets |
| 51 | +Error: Cannot increment/decrement string offsets |
| 52 | +'string'[0] |
| 53 | +Error: Cannot increment/decrement string offsets |
| 54 | +Error: Cannot increment/decrement string offsets |
| 55 | +[][0] |
| 56 | + |
| 57 | +Warning: Undefined array key 0 in %s on line %d |
| 58 | +NULL |
| 59 | +int(1) |
| 60 | +STDERR[0] |
| 61 | +Error: Cannot use a scalar value as an array |
| 62 | +Error: Cannot use a scalar value as an array |
| 63 | +new stdClass()[0] |
| 64 | +Error: Cannot use object of type stdClass as array |
| 65 | +Error: Cannot use object of type stdClass as array |
| 66 | +new ArrayObject()[0] |
| 67 | +NULL |
| 68 | +int(1) |
| 69 | +new A()[0] |
| 70 | +string(12) "A::offsetGet" |
| 71 | +int(0) |
| 72 | + |
| 73 | +Notice: Indirect modification of overloaded element of A has no effect in %s on line %d |
| 74 | +int(5) |
| 75 | +string(12) "A::offsetGet" |
| 76 | +int(0) |
| 77 | + |
| 78 | +Notice: Indirect modification of overloaded element of A has no effect in %s on line %d |
| 79 | +int(5) |
| 80 | +new B()[0] |
| 81 | +NULL |
| 82 | +int(1) |
| 83 | +new DimensionRead()[0] |
| 84 | +Error: Cannot fetch offset of object of type DimensionRead |
| 85 | +Error: Cannot fetch offset of object of type DimensionRead |
| 86 | +new DimensionFetch()[0] |
| 87 | +string(27) "DimensionFetch::offsetFetch" |
| 88 | +int(0) |
| 89 | +TypeError: Cannot increment DimensionFetch |
| 90 | +string(27) "DimensionFetch::offsetFetch" |
| 91 | +int(0) |
| 92 | +TypeError: Cannot decrement DimensionFetch |
| 93 | +new DimensionWrite()[0] |
| 94 | +Error: Cannot fetch offset of object of type DimensionWrite |
| 95 | +Error: Cannot fetch offset of object of type DimensionWrite |
| 96 | +new DimensionReadWrite()[0] |
| 97 | +Error: Cannot fetch offset of object of type DimensionReadWrite |
| 98 | +Error: Cannot fetch offset of object of type DimensionReadWrite |
| 99 | +new DimensionAppend()[0] |
| 100 | +Error: Cannot fetch offset of object of type DimensionAppend |
| 101 | +Error: Cannot fetch offset of object of type DimensionAppend |
| 102 | +new DimensionFetchAppend()[0] |
| 103 | +Error: Cannot fetch offset of object of type DimensionFetchAppend |
| 104 | +Error: Cannot fetch offset of object of type DimensionFetchAppend |
| 105 | +new DimensionUnset()[0] |
| 106 | +Error: Cannot fetch offset of object of type DimensionUnset |
| 107 | +Error: Cannot fetch offset of object of type DimensionUnset |
0 commit comments