Skip to content

Commit 2e89b73

Browse files
committed
Take a regular array as second parameter in ZEND_CLONE OPcode
1 parent d471704 commit 2e89b73

File tree

3 files changed

+6
-41
lines changed

3 files changed

+6
-41
lines changed

Zend/zend_compile.c

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5406,42 +5406,7 @@ static void zend_compile_clone(znode *result, zend_ast *ast) /* {{{ */
54065406

54075407
znode value_node;
54085408
if (ast->child[1]) {
5409-
ZEND_ASSERT(ast->child[1]->kind == ZEND_AST_ARG_LIST);
5410-
zend_ast_list *args_ast = zend_ast_get_list(ast->child[1]);
5411-
ZEND_ASSERT(args_ast->children > 0);
5412-
5413-
zend_ast *array;
5414-
zend_ast *last;
5415-
5416-
for (uint32_t i = 0; i < args_ast->children; ++i) {
5417-
zend_ast *arg = args_ast->child[i];
5418-
5419-
switch (arg->kind) {
5420-
case ZEND_AST_UNPACK:
5421-
if (args_ast->children != 1) {
5422-
zend_error_noreturn(E_COMPILE_ERROR, "Cannot combine unpacking with other arguments");
5423-
}
5424-
5425-
array = arg->child[0];
5426-
5427-
break;
5428-
case ZEND_AST_NAMED_ARG: {
5429-
zend_ast *elem = zend_ast_create(ZEND_AST_ARRAY_ELEM, arg->child[1], arg->child[0]);
5430-
if (i == 0) {
5431-
array = zend_ast_create_list(args_ast->children, ZEND_AST_ARRAY, elem);
5432-
last = array;
5433-
} else {
5434-
last = zend_ast_list_add(last, elem);
5435-
}
5436-
break;
5437-
}
5438-
default:
5439-
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use unnamed argument");
5440-
break;
5441-
}
5442-
}
5443-
5444-
zend_compile_expr(&value_node, array);
5409+
zend_compile_expr(&value_node, ast->child[1]);
54455410
} else {
54465411
value_node.op_type = IS_UNUSED;
54475412
}

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6059,7 +6059,7 @@ ZEND_VM_COLD_CONST_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY)
60596059
if (OP2_TYPE != IS_UNUSED) {
60606060
zval *properties = GET_OP2_ZVAL_PTR(BP_VAR_R);
60616061
if (Z_TYPE_P(properties) != IS_ARRAY) {
6062-
zend_type_error("Only arrays can be unpacked for clone, %s given", zend_zval_value_name(properties));
6062+
zend_type_error("Updated properties must be of type array, %s given", zend_zval_value_name(properties));
60636063
FREE_OP1();
60646064
FREE_OP2();
60656065
ZVAL_UNDEF(EX_VAR(opline->result.var));

Zend/zend_vm_execute.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)