@@ -1846,25 +1846,7 @@ ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type) /*
18461846
18471847ZEND_API zend_result object_init_with_constructor (zval * arg , zend_class_entry * class_type , uint32_t param_count , zval * params , HashTable * named_params ) /* {{{ */
18481848{
1849- zend_function * constructor = class_type -> constructor ;
1850- if (UNEXPECTED (constructor == NULL )) {
1851- const zend_attribute * non_instantiable_class = zend_get_attribute_str (class_type -> attributes , ZEND_STRL ("noninstantiableclass" ));
1852- ZEND_ASSERT (non_instantiable_class );
1853- zend_string * msg = Z_STR (non_instantiable_class -> args [0 ].value );
1854- zend_throw_error (NULL , "%s" , ZSTR_VAL (msg ));
1855- ZVAL_UNDEF (arg );
1856- return FAILURE ;
1857- }
1858-
1859- if (UNEXPECTED (!(constructor -> common .fn_flags & ZEND_ACC_PUBLIC ))) {
1860- /* Use zend_bad_constructor_call() somehow? */
1861- zend_throw_error (
1862- NULL ,
1863- "Call to %s %s::%s() from global scope" ,
1864- zend_visibility_string (class_type -> constructor -> common .fn_flags ),
1865- ZSTR_VAL (class_type -> constructor -> common .scope -> name ),
1866- ZSTR_VAL (class_type -> constructor -> common .function_name )
1867- );
1849+ if (UNEXPECTED (!zend_check_class_is_instantiable_or_throw (class_type ))) {
18681850 ZVAL_UNDEF (arg );
18691851 return FAILURE ;
18701852 }
@@ -1876,8 +1858,9 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c
18761858 }
18771859 zend_object * obj = Z_OBJ_P (arg );
18781860
1879- /* Fake constructor means we don't need to call the constructor actually */
1880- if (zend_is_pass_function (constructor )) {
1861+ zend_function * constructor = class_type -> constructor ;
1862+ /* No constructor, so no need to call it */
1863+ if (constructor == NULL ) {
18811864 /* Surprisingly, this is the only case where internal classes will allow to pass extra arguments
18821865 * However, if there are named arguments (and it is not empty),
18831866 * an Error must be thrown to be consistent with new ClassName() */
@@ -3523,11 +3506,6 @@ static zend_class_entry *do_register_internal_class(const zend_class_entry *orig
35233506 if (class_entry -> info .internal .builtin_functions ) {
35243507 zend_register_functions (class_entry , class_entry -> info .internal .builtin_functions , & class_entry -> function_table , EG (current_module )-> type );
35253508 }
3526-
3527- /* Assign the pass function as a default constructor */
3528- if (class_entry -> constructor == NULL ) {
3529- class_entry -> constructor = (zend_function * ) & zend_pass_function ;
3530- }
35313509
35323510 lowercase_name = zend_string_tolower_ex (orig_class_entry -> name , EG (current_module )-> type == MODULE_PERSISTENT );
35333511 lowercase_name = zend_new_interned_string (lowercase_name );
0 commit comments