Skip to content

Commit a49a309

Browse files
committed
Fix FETCH_OBJ_IS type inference
Even if the property is typed, null is still a valid return value in the BP_VAR_IS case. Other cases will throw instead.
1 parent 015cafa commit a49a309

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,6 +3452,10 @@ static zend_always_inline int _zend_update_type_info(
34523452
tmp &= ~MAY_BE_RC1;
34533453
}
34543454
}
3455+
if (opline->opcode == ZEND_FETCH_OBJ_IS) {
3456+
/* IS check may return null for uninitialized typed property. */
3457+
tmp |= MAY_BE_NULL;
3458+
}
34553459
}
34563460
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
34573461
if (ce) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
FETCH_OBJ_IS on typed object property
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
11+
class Test {
12+
public stdClass $data;
13+
}
14+
15+
function test() {
16+
$test = new Test;
17+
var_dump(isset($test->data[0]));
18+
}
19+
20+
test();
21+
22+
?>
23+
--EXPECT--
24+
bool(false)

0 commit comments

Comments
 (0)