Skip to content

Commit 23291d2

Browse files
committed
zend_vm_def: Handle references for ZEND_TYPE_ASSERT
1 parent aac6ad3 commit 23291d2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Zend/zend_vm_def.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8869,6 +8869,12 @@ ZEND_VM_HOT_HANDLER(211, ZEND_TYPE_ASSERT, CONST, ANY, NUM)
88698869
uint8_t expected_type = opline->extended_value & 0xff;
88708870
/* Simple types can be checked directly. */
88718871
if (UNEXPECTED(actual_type != expected_type)) {
8872+
zend_reference *ref = NULL;
8873+
if (Z_ISREF_P(value)) {
8874+
value = Z_REFVAL_P(value);
8875+
ref = Z_REF_P(value);
8876+
}
8877+
88728878
zend_function *fbc;
88738879
{
88748880
zval *fname = (zval*)RT_CONSTANT(opline, opline->op1);
@@ -8879,7 +8885,7 @@ ZEND_VM_HOT_HANDLER(211, ZEND_TYPE_ASSERT, CONST, ANY, NUM)
88798885
uint16_t argno = opline->extended_value >> 16;
88808886
zend_arg_info *arginfo = &fbc->common.arg_info[argno - 1];
88818887

8882-
if (!zend_check_user_type_slow(&arginfo->type, value, /* ref */ NULL, /* is_return_type */ false)) {
8888+
if (!zend_check_user_type_slow(&arginfo->type, value, ref, /* is_return_type */ false)) {
88838889
const char *param_name = get_function_arg_name(fbc, argno);
88848890
zend_string *expected = zend_type_to_string(arginfo->type);
88858891
zend_type_error("%s(): Argument #%d%s%s%s must be of type %s, %s given", ZSTR_VAL(fbc->common.function_name), argno, param_name ? " ($" : "", param_name ? param_name : "", param_name ? ")" : "", ZSTR_VAL(expected), zend_zval_value_name(value));

Zend/zend_vm_execute.h

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)