Skip to content

Commit bc24c62

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Don't use CE info from pi node for MAY_BE_REF var
2 parents 7be195c + f1814e6 commit bc24c62

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
@@ -3744,7 +3744,11 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend
37443744
}
37453745

37463746
UPDATE_SSA_TYPE(tmp, j);
3747-
UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j);
3747+
if (tmp & MAY_BE_REF) {
3748+
UPDATE_SSA_OBJ_TYPE(NULL, 0, j);
3749+
} else {
3750+
UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j);
3751+
}
37483752
} else {
37493753
int first = 1;
37503754
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)