Skip to content

Commit a38bad8

Browse files
committed
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.
1 parent ca7a11c commit a38bad8

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

Zend/tests/bug70089.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ try {
3030
?>
3131
--EXPECT--
3232
string(36) "Cannot use string offset as an array"
33-
string(27) "Cannot unset string offsets"
33+
string(36) "Cannot use string offset as an array"
3434
string(47) "Cannot create references to/from string offsets"
3535
string(41) "Cannot increment/decrement string offsets"

Zend/tests/unset_non_array.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@ Deprecated: Automatic conversion of false to array is deprecated in %s
109109
Cannot unset offset in a non-array variable
110110
Cannot unset offset in a non-array variable
111111
Cannot unset offset in a non-array variable
112-
Cannot unset string offsets
112+
Cannot use string offset as an array
113113
Cannot use object of type stdClass as array

Zend/zend_execute.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void)
15731573
case ZEND_FETCH_LIST_W:
15741574
case ZEND_ASSIGN_DIM:
15751575
case ZEND_ASSIGN_DIM_OP:
1576+
case ZEND_UNSET_DIM:
15761577
msg = "Cannot use string offset as an array";
15771578
break;
15781579
case ZEND_PRE_INC:
@@ -1594,9 +1595,6 @@ ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void)
15941595
case ZEND_FE_RESET_RW:
15951596
msg = "Cannot create references to/from string offsets";
15961597
break;
1597-
case ZEND_UNSET_DIM:
1598-
msg = "Cannot unset string offsets";
1599-
break;
16001598
EMPTY_SWITCH_DEFAULT_CASE();
16011599
}
16021600
break;

0 commit comments

Comments
 (0)