diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 8a85d12fdae79..e971b3ba2e9f8 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2674,6 +2674,9 @@ static zend_always_inline zend_result _zend_update_type_info( } } if (opline->extended_value == IS_ARRAY) { + if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL)) { + tmp |= MAY_BE_ARRAY_EMPTY; + } if (t1 & MAY_BE_ARRAY) { tmp |= t1 & (MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF); } @@ -3394,6 +3397,9 @@ static zend_always_inline zend_result _zend_update_type_info( arr_type = RES_USE_INFO(); } tmp = MAY_BE_RC1|MAY_BE_ARRAY|arr_type; + if (opline->opcode == ZEND_INIT_ARRAY && opline->op1_type == IS_UNUSED) { + tmp |= MAY_BE_ARRAY_EMPTY; + } if (opline->op1_type != IS_UNUSED && (opline->op2_type == IS_UNUSED || (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)))) {