Skip to content

Commit f1814e6

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Don't use CE info from pi node for MAY_BE_REF var
2 parents 3fdb1aa + 41f33b9 commit f1814e6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3687,7 +3687,11 @@ static int zend_infer_types_ex(const zend_op_array *op_array, const zend_script
36873687
}
36883688

36893689
UPDATE_SSA_TYPE(tmp, j);
3690-
UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j);
3690+
if (tmp & MAY_BE_REF) {
3691+
UPDATE_SSA_OBJ_TYPE(NULL, 0, j);
3692+
} else {
3693+
UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j);
3694+
}
36913695
} else {
36923696
int first = 1;
36933697
int is_instanceof = 0;

Zend/tests/assign_obj_to_ref_inference.phpt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,27 @@ class Test {
77
public int $x = 42;
88
}
99

10-
function test() {
10+
function test1() {
1111
$r =& $o;
1212
$o = new Test;
1313
$r = new stdClass;
1414
$r->x = 3.141;
1515
var_dump(is_float($o->x));
1616
}
17-
test();
17+
18+
function test2($o) {
19+
$r =& $o;
20+
if ($o instanceof Test) {
21+
$r = new stdClass;
22+
$r->x = 3.141;
23+
var_dump(is_float($o->x));
24+
}
25+
}
26+
27+
test1();
28+
test2(new Test);
1829

1930
?>
2031
--EXPECT--
2132
bool(true)
33+
bool(true)

0 commit comments

Comments
 (0)