mirror of
https://github.com/php/php-src.git
synced 2026-03-26 09:12:14 +01:00
No notice is thrown for list() accesses, because we did not come
to an agreement regarding patterns like
while ([$key, $value] = yield $it->next()) { ... }
where silent null access may be desirable.
No effort is made to suppress multiple notices in access chains
likes $x[0][0][0], because the technical complexity this causes
does not seem worthwhile.
RFC: https://wiki.php.net/rfc/notice-for-non-valid-array-container
21 lines
462 B
PHP
21 lines
462 B
PHP
--TEST--
|
|
Bug #31158 (array_splice on $GLOBALS crashes)
|
|
--INI--
|
|
error_reporting = E_ALL
|
|
--FILE--
|
|
<?php
|
|
function __(){
|
|
$GLOBALS['a'] = "bug\n";
|
|
array_splice($GLOBALS,0,count($GLOBALS));
|
|
/* All global variables including $GLOBALS are removed */
|
|
echo $GLOBALS['a'];
|
|
}
|
|
__();
|
|
echo "ok\n";
|
|
?>
|
|
--EXPECTF--
|
|
Notice: Undefined variable: GLOBALS in %sbug31158.php on line 6
|
|
|
|
Notice: Trying to access array offset on value of type null in %sbug31158.php on line 6
|
|
ok
|