1--TEST-- 2Internal handlers 3--EXTENSIONS-- 4zend_test 5--FILE-- 6<?php 7 8require_once __DIR__ . DIRECTORY_SEPARATOR . 'test_offset_helpers.inc'; 9 10echo 'read op', PHP_EOL; 11$o = new DimensionHandlersNoArrayAccess(); 12$r = $o['foo']; 13exportObject($o); 14 15echo 'write op', PHP_EOL; 16$o = new DimensionHandlersNoArrayAccess(); 17$o['foo'] = true; 18exportObject($o); 19 20echo 'read-write op', PHP_EOL; 21$o = new DimensionHandlersNoArrayAccess(); 22$o['foo'] += 10; 23exportObject($o); 24 25echo 'isset op', PHP_EOL; 26$o = new DimensionHandlersNoArrayAccess(); 27$r = isset($o['foo']); 28exportObject($o); 29 30echo 'empty op', PHP_EOL; 31$o = new DimensionHandlersNoArrayAccess(); 32$r = empty($o['foo']); 33exportObject($o); 34 35echo 'null coalescing op', PHP_EOL; 36$o = new DimensionHandlersNoArrayAccess(); 37$r = $o['foo'] ?? 'default'; 38exportObject($o); 39 40echo 'appending op', PHP_EOL; 41$o = new DimensionHandlersNoArrayAccess(); 42$o[] = true; 43exportObject($o); 44 45echo 'unset op', PHP_EOL; 46$o = new DimensionHandlersNoArrayAccess(); 47unset($o['foo']); 48exportObject($o); 49 50echo 'nested read', PHP_EOL; 51$o = new DimensionHandlersNoArrayAccess(); 52$r = $o['foo']['bar']; 53exportObject($o); 54 55// Illegal 56//echo 'nested read: appending then read', PHP_EOL; 57//$o = new DimensionHandlersNoArrayAccess(); 58//try { 59// $r = $o[]['bar']; 60//} catch (\Throwable $e) { 61// echo $e::class, ': ', $e->getMessage(), PHP_EOL; 62//} 63 64echo 'nested write', PHP_EOL; 65$o = new DimensionHandlersNoArrayAccess(); 66try { 67 $o['foo']['bar'] = true; 68} catch (\Throwable $e) { 69 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 70} 71exportObject($o); 72 73echo 'nested write: appending then write', PHP_EOL; 74$o = new DimensionHandlersNoArrayAccess(); 75try { 76 $o[]['bar'] = true; 77} catch (\Throwable $e) { 78 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 79} 80exportObject($o); 81 82echo 'nested read-write', PHP_EOL; 83$o = new DimensionHandlersNoArrayAccess(); 84try { 85 $o['foo']['bar'] += 10; 86} catch (\Throwable $e) { 87 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 88} 89exportObject($o); 90 91echo 'nested read-write: appending then write', PHP_EOL; 92$o = new DimensionHandlersNoArrayAccess(); 93try { 94 $o[]['bar'] += 10; 95} catch (\Throwable $e) { 96 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 97} 98exportObject($o); 99 100echo 'nested isset', PHP_EOL; 101$o = new DimensionHandlersNoArrayAccess(); 102try { 103 $r = isset($o['foo']['bar']); 104} catch (\Throwable $e) { 105 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 106} 107exportObject($o); 108 109// Illegal 110//echo 'nested isset: appending then read', PHP_EOL; 111//try { 112// $o = new DimensionHandlersNoArrayAccess(); 113// $r = isset($o[]['bar']); 114//} catch (\Throwable $e) { 115// echo $e::class, ': ', $e->getMessage(), PHP_EOL; 116//} 117//exportObject($o); 118 119echo 'nested empty', PHP_EOL; 120$o = new DimensionHandlersNoArrayAccess(); 121try { 122 $r = empty($o['foo']['bar']); 123} catch (\Throwable $e) { 124 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 125} 126exportObject($o); 127 128// Illegal 129//echo 'nested empty: appending then read', PHP_EOL; 130//try { 131// $o = new DimensionHandlersNoArrayAccess(); 132// $r = empty($o[]['bar']); 133//} catch (\Throwable $e) { 134// echo $e::class, ': ', $e->getMessage(), PHP_EOL; 135//} 136//exportObject($o); 137 138echo 'nested null coalescing', PHP_EOL; 139$o = new DimensionHandlersNoArrayAccess(); 140try { 141 $r = $o['foo']['bar'] ?? 'default'; 142} catch (\Throwable $e) { 143 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 144} 145exportObject($o); 146 147// Illegal 148//echo 'nested null coalescing: appending then read', PHP_EOL; 149//try { 150// $o = new DimensionHandlersNoArrayAccess(); 151// $r = $o[]['bar'] ?? 'default'; 152//} catch (\Throwable $e) { 153// echo $e::class, ': ', $e->getMessage(), PHP_EOL; 154//} 155//exportObject($o); 156 157echo 'nested appending', PHP_EOL; 158$o = new DimensionHandlersNoArrayAccess(); 159try { 160 $o['foo'][] = true; 161} catch (\Throwable $e) { 162 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 163} 164exportObject($o); 165 166echo 'nested appending: appending then append', PHP_EOL; 167$o = new DimensionHandlersNoArrayAccess(); 168try { 169 $o[][] = true; 170} catch (\Throwable $e) { 171 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 172} 173exportObject($o); 174 175echo 'nested unset', PHP_EOL; 176$o = new DimensionHandlersNoArrayAccess(); 177try { 178 unset($o['foo']['bar']); 179} catch (\Throwable $e) { 180 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 181} 182exportObject($o); 183 184// Illegal 185//echo 'nested unset: appending then read', PHP_EOL; 186//try { 187// $o = new DimensionHandlersNoArrayAccess(); 188// unset($o[]['bar']); 189//} catch (\Throwable $e) { 190// echo $e::class, ': ', $e->getMessage(), PHP_EOL; 191//} 192//exportObject($o); 193 194echo 'reference fetching', PHP_EOL; 195$o = new DimensionHandlersNoArrayAccess(); 196try { 197 $r = &$o['foo']; 198} catch (\Throwable $e) { 199 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 200} 201exportObject($o); 202 203echo 'nested reference fetching', PHP_EOL; 204$o = new DimensionHandlersNoArrayAccess(); 205try { 206 $r = &$o['foo']['bar']; 207} catch (\Throwable $e) { 208 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 209} 210exportObject($o); 211 212echo 'reference fetch-append', PHP_EOL; 213$o = new DimensionHandlersNoArrayAccess(); 214try { 215 $r = &$o[]; 216} catch (\Throwable $e) { 217 echo $e::class, ': ', $e->getMessage(), PHP_EOL; 218} 219exportObject($o); 220 221?> 222--EXPECTF-- 223read op 224DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_R, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 225write op 226DimensionHandlersNoArrayAccess, read: false, write: true, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 227read-write op 228DimensionHandlersNoArrayAccess, read: true, write: true, has: false, unset: false, readType: BP_VAR_R, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 229isset op 230DimensionHandlersNoArrayAccess, read: false, write: false, has: true, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: 0, offset: 'foo' 231empty op 232DimensionHandlersNoArrayAccess, read: false, write: false, has: true, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: 1, offset: 'foo' 233null coalescing op 234DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 235appending op 236DimensionHandlersNoArrayAccess, read: false, write: true, has: false, unset: false, readType: uninitialized, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized 237unset op 238DimensionHandlersNoArrayAccess, read: false, write: false, has: false, unset: true, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 239nested read 240 241Warning: Trying to access array offset on true in %s on line %d 242DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_R, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 243nested write 244 245Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 246Error: Cannot use a scalar value as an array 247DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 248nested write: appending then write 249 250Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 251Error: Cannot use a scalar value as an array 252DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized 253nested read-write 254 255Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 256Error: Cannot use a scalar value as an array 257DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_RW, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 258nested read-write: appending then write 259 260Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 261Error: Cannot use a scalar value as an array 262DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_RW, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized 263nested isset 264DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 265nested empty 266DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 267nested null coalescing 268DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 269nested appending 270 271Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 272Error: Cannot use a scalar value as an array 273DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 274nested appending: appending then append 275 276Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 277Error: Cannot use a scalar value as an array 278DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized 279nested unset 280 281Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 282Error: Cannot unset offset in a non-array variable 283DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_UNSET, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 284reference fetching 285 286Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 287DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 288nested reference fetching 289 290Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 291Error: Cannot use a scalar value as an array 292DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo' 293reference fetch-append 294 295Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d 296DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized 297