Skip to content

Commit 9717e9f

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fixed empty array inference
2 parents 332df9b + 5a77870 commit 9717e9f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/Optimizer/zend_inference.c

+6
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,9 @@ static zend_always_inline zend_result _zend_update_type_info(
26742674
}
26752675
}
26762676
if (opline->extended_value == IS_ARRAY) {
2677+
if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL)) {
2678+
tmp |= MAY_BE_ARRAY_EMPTY;
2679+
}
26772680
if (t1 & MAY_BE_ARRAY) {
26782681
tmp |= t1 & (MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF);
26792682
}
@@ -3394,6 +3397,9 @@ static zend_always_inline zend_result _zend_update_type_info(
33943397
arr_type = RES_USE_INFO();
33953398
}
33963399
tmp = MAY_BE_RC1|MAY_BE_ARRAY|arr_type;
3400+
if (opline->opcode == ZEND_INIT_ARRAY && opline->op1_type == IS_UNUSED) {
3401+
tmp |= MAY_BE_ARRAY_EMPTY;
3402+
}
33973403
if (opline->op1_type != IS_UNUSED
33983404
&& (opline->op2_type == IS_UNUSED
33993405
|| (t2 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_RESOURCE|MAY_BE_STRING)))) {

0 commit comments

Comments
 (0)