Consolidate UNSET_DIM handling for string offset error

The immediate error here is the nested indexing in write context,
the fact that it's ultimately wrapped in an unset() doesn't matter.
Same as $str[0][0] += 1 will throw "Cannot use string offset as an
array", so should this case.
This commit is contained in:
Nikita Popov 2021-10-20 13:05:38 +02:00
parent ca7a11c9cf
commit a38bad87d5
3 changed files with 3 additions and 5 deletions

View file

@ -30,6 +30,6 @@ try {
?>
--EXPECT--
string(36) "Cannot use string offset as an array"
string(27) "Cannot unset string offsets"
string(36) "Cannot use string offset as an array"
string(47) "Cannot create references to/from string offsets"
string(41) "Cannot increment/decrement string offsets"

View file

@ -109,5 +109,5 @@ Deprecated: Automatic conversion of false to array is deprecated in %s
Cannot unset offset in a non-array variable
Cannot unset offset in a non-array variable
Cannot unset offset in a non-array variable
Cannot unset string offsets
Cannot use string offset as an array
Cannot use object of type stdClass as array

View file

@ -1573,6 +1573,7 @@ ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void)
case ZEND_FETCH_LIST_W:
case ZEND_ASSIGN_DIM:
case ZEND_ASSIGN_DIM_OP:
case ZEND_UNSET_DIM:
msg = "Cannot use string offset as an array";
break;
case ZEND_PRE_INC:
@ -1594,9 +1595,6 @@ ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void)
case ZEND_FE_RESET_RW:
msg = "Cannot create references to/from string offsets";
break;
case ZEND_UNSET_DIM:
msg = "Cannot unset string offsets";
break;
EMPTY_SWITCH_DEFAULT_CASE();
}
break;