Add opcodes to zend_wrong_string_offset()

This commit is contained in:
Nikita Popov 2016-07-10 15:13:21 +02:00
parent 445cb529b2
commit 5f6effed43
3 changed files with 30 additions and 0 deletions

View 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

View file

@ -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:

View file

@ -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: