1--TEST-- 2Appending containers 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[] = 'value'; 12 var_dump($container); 13 } catch (\Throwable $e) { 14 echo $e->getMessage(), "\n"; 15 } 16} 17 18?> 19--EXPECTF-- 20NULL container: 21array(1) { 22 [0]=> 23 string(5) "value" 24} 25false container: 26 27Deprecated: Automatic conversion of false to array is deprecated in %s on line %d 28array(1) { 29 [0]=> 30 string(5) "value" 31} 32true container: 33Cannot use a scalar value as an array 344 container: 35Cannot use a scalar value as an array 365.5 container: 37Cannot use a scalar value as an array 38'10' container: 39[] operator not supported for strings 40'25.5' container: 41[] operator not supported for strings 42'string' container: 43[] operator not supported for strings 44[] container: 45array(1) { 46 [0]=> 47 string(5) "value" 48} 49STDERR container: 50Cannot use a scalar value as an array 51new stdClass() container: 52Cannot use object of type stdClass as array 53new ArrayObject() container: 54object(ArrayObject)#2 (1) { 55 ["storage":"ArrayObject":private]=> 56 array(1) { 57 [0]=> 58 string(5) "value" 59 } 60} 61new A() container: 62string(12) "A::offsetSet" 63NULL 64string(5) "value" 65object(A)#3 (0) { 66} 67new B() container: 68string(12) "B::offsetSet" 69NULL 70string(5) "value" 71object(B)#4 (1) { 72 ["storage":"ArrayObject":private]=> 73 array(0) { 74 } 75} 76