mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Add opcodes to zend_wrong_string_offset()
This commit is contained in:
parent
445cb529b2
commit
5f6effed43
3 changed files with 30 additions and 0 deletions
27
Zend/tests/string_offset_errors.phpt
Normal file
27
Zend/tests/string_offset_errors.phpt
Normal file
|
@ -0,0 +1,27 @@
|
|||
--TEST--
|
||||
Some string offset errors
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function &test() : string {
|
||||
$str = "foo";
|
||||
return $str[0];
|
||||
}
|
||||
|
||||
try {
|
||||
test();
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
$str = "foo";
|
||||
$str[0] =& $str[1];
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Cannot return string offsets by reference
|
||||
Cannot create references to/from string offsets
|
|
@ -1262,9 +1262,11 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(void)
|
|||
case ZEND_ASSIGN_REF:
|
||||
case ZEND_ADD_ARRAY_ELEMENT:
|
||||
case ZEND_INIT_ARRAY:
|
||||
case ZEND_MAKE_REF:
|
||||
msg = "Cannot create references to/from string offsets";
|
||||
break;
|
||||
case ZEND_RETURN_BY_REF:
|
||||
case ZEND_VERIFY_RETURN_TYPE:
|
||||
msg = "Cannot return string offsets by reference";
|
||||
break;
|
||||
case ZEND_UNSET_DIM:
|
||||
|
|
|
@ -3229,6 +3229,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
|
|||
case ZEND_ADD_ARRAY_ELEMENT:
|
||||
case ZEND_RETURN_BY_REF:
|
||||
case ZEND_VERIFY_RETURN_TYPE:
|
||||
case ZEND_MAKE_REF:
|
||||
tmp |= MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
|
||||
break;
|
||||
case ZEND_PRE_INC:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue