if (IS_BOT(new)) {
SCP_DEBUG("Lowering var %d to BOT\n", var);
- } else {
+ } else if (!IS_PARTIAL_ARRAY(new) && !IS_PARTIAL_OBJECT(new)) {
SCP_DEBUG("Lowering var %d to %Z\n", var, new);
}
return;
}
+ /* PARTIAL_ARRAY is lower than IS_ARRAY */
+ if (Z_TYPE_P(value) == IS_ARRAY && IS_PARTIAL_ARRAY(new)) {
+ zval_ptr_dtor_nogc(value);
+ ZVAL_COPY(value, new);
+ scdf_add_to_worklist(scdf, var);
+ return;
+ }
+
#if ZEND_DEBUG
ZEND_ASSERT(IS_PARTIAL_ARRAY(new) || IS_PARTIAL_OBJECT(new) || zend_is_identical(value, new));
#endif
if (!op2 && IS_PARTIAL_ARRAY(&zv)) {
/* We can't add NEXT element into partial array (skip it) */
SET_RESULT(result, data);
- SET_RESULT(result, &zv);
+ SET_RESULT(op1, &zv);
} else if (ct_eval_assign_dim(&zv, data, op2) == SUCCESS) {
SET_RESULT(result, data);
SET_RESULT(op1, &zv);
if (!Z_DELREF(ctx->values[i])) {
zend_array_destroy(Z_ARR(ctx->values[i]));
}
- Z_TYPE_INFO(ctx->values[i]) = BOT;
+ MAKE_BOT(&ctx->values[i]);
if ((var->use_chain < 0 && var->phi_use_chain == NULL) || var->no_val) {
removed_ops += try_remove_definition(ctx, i, var, NULL);
}
--- /dev/null
+--TEST--
+SCCP 013: Conditional Constant Propagation of non-escaping array elements on PHI
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function loadEntities($entity_information) {
+ $entity_types = [];
+ foreach ($entity_information as $info) {
+ $entity_types[$info] = 1;
+ }
+ var_dump((bool)($entity_types[$info]));
+}
+
+loadEntities(array("first", "second"));
+--EXPECT--
+bool(true)