@@ -1790,13 +1790,17 @@ ZEND_API void object_properties_load(zend_object *object, const HashTable *prope
17901790 * class and all props being public. If only a subset is given or the class
17911791 * has protected members then you need to merge the properties separately by
17921792 * calling zend_merge_properties(). */
1793- static zend_always_inline zend_result _object_and_properties_init (zval * arg , zend_class_entry * class_type , HashTable * properties ) /* {{{ */
1793+ static zend_always_inline zend_result _object_and_properties_init (zval * arg , zend_class_entry * class_type , HashTable * properties , bool known_instantiable ) /* {{{ */
17941794{
1795- if (UNEXPECTED (class_type -> ce_flags & ZEND_ACC_UNINSTANTIABLE )) {
1796- zend_cannot_instantiate_class (class_type , NULL );
1797- ZVAL_NULL (arg );
1798- Z_OBJ_P (arg ) = NULL ;
1799- return FAILURE ;
1795+ if (!known_instantiable ) {
1796+ if (UNEXPECTED (class_type -> ce_flags & ZEND_ACC_UNINSTANTIABLE )) {
1797+ zend_cannot_instantiate_class (class_type , NULL );
1798+ ZVAL_NULL (arg );
1799+ Z_OBJ_P (arg ) = NULL ;
1800+ return FAILURE ;
1801+ }
1802+ } else {
1803+ ZEND_ASSERT ((class_type -> ce_flags & ZEND_ACC_UNINSTANTIABLE ) == 0 );
18001804 }
18011805
18021806 if (UNEXPECTED (!(class_type -> ce_flags & ZEND_ACC_CONSTANTS_UPDATED ))) {
@@ -1825,24 +1829,29 @@ static zend_always_inline zend_result _object_and_properties_init(zval *arg, zen
18251829
18261830ZEND_API zend_result object_and_properties_init (zval * arg , zend_class_entry * class_type , HashTable * properties ) /* {{{ */
18271831{
1828- return _object_and_properties_init (arg , class_type , properties );
1832+ return _object_and_properties_init (arg , class_type , properties , false );
18291833}
18301834/* }}} */
18311835
18321836ZEND_API zend_result object_init_ex (zval * arg , zend_class_entry * class_type ) /* {{{ */
18331837{
1834- return _object_and_properties_init (arg , class_type , NULL );
1838+ return _object_and_properties_init (arg , class_type , NULL , false );
18351839}
18361840/* }}} */
18371841
1842+ ZEND_API zend_result object_init_instantiable_class (zval * arg , zend_class_entry * class_type ) /* {{{ */
1843+ {
1844+ return _object_and_properties_init (arg , class_type , NULL , true);
1845+ }
1846+
18381847ZEND_API zend_result object_init_with_constructor (zval * arg , zend_class_entry * class_type , uint32_t param_count , zval * params , HashTable * named_params ) /* {{{ */
18391848{
18401849 if (UNEXPECTED (!zend_check_class_is_instantiable_or_throw (class_type , zend_get_executed_scope ()))) {
18411850 ZVAL_UNDEF (arg );
18421851 return FAILURE ;
18431852 }
18441853
1845- zend_result status = _object_and_properties_init (arg , class_type , NULL );
1854+ zend_result status = _object_and_properties_init (arg , class_type , NULL , true );
18461855 if (UNEXPECTED (status == FAILURE )) {
18471856 ZVAL_UNDEF (arg );
18481857 return FAILURE ;
0 commit comments