Skip to content

Commit

Permalink
Don't use CE for by-ref arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Apr 15, 2022
1 parent 41f33b9 commit 5d07257
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Zend/tests/assign_obj_to_ref_inference.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ function test2($o) {
}
}

function test3(Test &$o) {
$GLOBALS['r'] = new stdClass;
$GLOBALS['r']->x = 3.141;
var_dump(is_float($o->x));
}

test1();
test2(new Test);
$r = new Test;
test3($r);

?>
--EXPECT--
bool(true)
bool(true)
bool(true)
1 change: 1 addition & 0 deletions ext/opcache/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -2936,6 +2936,7 @@ static zend_always_inline int _zend_update_type_info(
tmp = zend_fetch_arg_info_type(script, arg_info, &ce);
if (ZEND_ARG_SEND_MODE(arg_info)) {
tmp |= MAY_BE_REF;
ce = NULL;
}

if (opline->opcode == ZEND_RECV_VARIADIC) {
Expand Down

0 comments on commit 5d07257

Please sign in to comment.