--- /dev/null
-Undefined variable: test
+ --TEST--
+ Converting undefined index/offset notice to exception
+ --FILE--
+ <?php
+
+ set_error_handler(function($_, $msg) {
+ throw new Exception($msg);
+ });
+
+ $test = [];
+ try {
+ $test[0] .= "xyz";
+ } catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+ }
+ var_dump($test);
+
+ try {
+ $test["key"] .= "xyz";
+ } catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+ }
+ var_dump($test);
+
+ unset($test);
+ try {
+ $GLOBALS["test"] .= "xyz";
+ } catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+ }
+ try {
+ var_dump($test);
+ } catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+ }
+
+ ?>
+ --EXPECT--
+ Undefined offset: 0
+ array(0) {
+ }
+ Undefined index: key
+ array(0) {
+ }
+ Undefined index: test
++Undefined variable $test
} else {
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type EXECUTE_DATA_CC);
if (UNEXPECTED(!retval)) {
- ZVAL_UNDEF(result);
- ZVAL_ERROR(result);
++ /* This may fail without throwing if the array was modified while throwing an
++ * undefined index error. */
++ ZVAL_NULL(result);
return;
}
}