1--TEST-- 2Appending containers via a fetch operation $c[][5] = $v; 3--FILE-- 4<?php 5 6require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; 7 8foreach ($containers as $container) { 9 echo zend_test_var_export($container), " container:\n"; 10 try { 11 $container[][5] = 'value'; 12 var_dump($container); 13 } catch (\Throwable $e) { 14 echo $e::class, ': ', $e->getMessage(), "\n"; 15 } 16} 17 18?> 19--EXPECTF-- 20NULL container: 21array(1) { 22 [0]=> 23 array(1) { 24 [5]=> 25 string(5) "value" 26 } 27} 28false container: 29 30Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 31array(1) { 32 [0]=> 33 array(1) { 34 [5]=> 35 string(5) "value" 36 } 37} 38true container: 39Error: Cannot use a scalar value as an array 404 container: 41Error: Cannot use a scalar value as an array 425.5 container: 43Error: Cannot use a scalar value as an array 44'10' container: 45Error: [] operator not supported for strings 46'25.5' container: 47Error: [] operator not supported for strings 48'string' container: 49Error: [] operator not supported for strings 50[] container: 51array(1) { 52 [0]=> 53 array(1) { 54 [5]=> 55 string(5) "value" 56 } 57} 58STDERR container: 59Error: Cannot use a scalar value as an array 60new stdClass() container: 61Error: Cannot use object of type stdClass as array 62new ArrayObject() container: 63 64Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line %d 65object(ArrayObject)#2 (1) { 66 ["storage":"ArrayObject":private]=> 67 array(0) { 68 } 69} 70new A() container: 71string(12) "A::offsetGet" 72NULL 73 74Notice: Indirect modification of overloaded element of A has no effect in %s on line %d 75Error: Cannot use a scalar value as an array 76new B() container: 77 78Notice: Indirect modification of overloaded element of B has no effect in %s on line %d 79ArgumentCountError: B::offsetGet(): Argument #1 ($offset) not passed 80