Skip to content

Commit 610ca73

Browse files
committed
Fix review nits
1 parent 0f2a38e commit 610ca73

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Zend/zend_API.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,24 +1867,24 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c
18671867
zval_ptr_dtor(arg);
18681868
ZVAL_UNDEF(arg);
18691869
return FAILURE;
1870+
}
1871+
1872+
/* Surprisingly, this is the only case where internal classes will allow to pass extra arguments
1873+
* However, if there are named arguments, an Error must be thrown to be consistent with new ClassName() */
1874+
if (UNEXPECTED(named_params != NULL)) {
1875+
/* Throw standard Error */
1876+
zend_string *arg_name = NULL;
1877+
zend_hash_get_current_key(named_params, &arg_name, /* num_index */ NULL);
1878+
ZEND_ASSERT(arg_name != NULL);
1879+
zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name));
1880+
zend_string_release(arg_name);
1881+
/* Do not call destructor, free object, and set arg to IS_UNDEF */
1882+
zend_object_store_ctor_failed(obj);
1883+
zval_ptr_dtor(arg);
1884+
ZVAL_UNDEF(arg);
1885+
return FAILURE;
18701886
} else {
1871-
/* Surprisingly, this is the only case where internal classes will allow to pass extra arguments
1872-
* However, if there are named arguments, an Error must be thrown to be consistent with new ClassName() */
1873-
if (UNEXPECTED(named_params != NULL)) {
1874-
/* Throw standard Error */
1875-
zend_string *arg_name = NULL;
1876-
zend_hash_get_current_key(named_params, &arg_name, /* num_index */ NULL);
1877-
ZEND_ASSERT(arg_name != NULL);
1878-
zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name));
1879-
zend_string_release(arg_name);
1880-
/* Do not call destructor, free object, and set arg to IS_UNDEF */
1881-
zend_object_store_ctor_failed(obj);
1882-
zval_ptr_dtor(arg);
1883-
ZVAL_UNDEF(arg);
1884-
return FAILURE;
1885-
} else {
1886-
return SUCCESS;
1887-
}
1887+
return SUCCESS;
18881888
}
18891889
}
18901890
/* A constructor should not return a value, however if an exception is thrown
@@ -1894,7 +1894,7 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c
18941894
constructor,
18951895
obj,
18961896
class_type,
1897-
/* retval */ &retval,
1897+
&retval,
18981898
param_count,
18991899
params,
19001900
named_params

0 commit comments

Comments
 (0)