@@ -179,7 +179,9 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */
179179 }
180180
181181 if (ce -> constructor ) {
182- if (parent -> constructor && UNEXPECTED (parent -> constructor -> common .fn_flags & ZEND_ACC_FINAL )) {
182+ if (parent -> constructor
183+ && !(parent -> constructor -> common .fn_flags & ZEND_ACC_PRIVATE )
184+ && UNEXPECTED (parent -> constructor -> common .fn_flags & ZEND_ACC_FINAL )) {
183185 zend_error_noreturn (E_ERROR , "Cannot override final %s::%s() with %s::%s()" ,
184186 ZSTR_VAL (parent -> name ), ZSTR_VAL (parent -> constructor -> common .function_name ),
185187 ZSTR_VAL (ce -> name ), ZSTR_VAL (ce -> constructor -> common .function_name ));
@@ -810,6 +812,15 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(z
810812 uint32_t parent_flags = parent -> common .fn_flags ;
811813 zend_function * proto ;
812814
815+ if (UNEXPECTED ((parent_flags & ZEND_ACC_PRIVATE ) && !(parent_flags & ZEND_ACC_ABSTRACT ))) {
816+ if (!check_only ) {
817+ child -> common .fn_flags |= ZEND_ACC_CHANGED ;
818+ child -> common .prototype = NULL ;
819+ }
820+ /* The parent method is private and not an abstract so we don't need to check any inheritance rules */
821+ return INHERITANCE_SUCCESS ;
822+ }
823+
813824 if (!checked && UNEXPECTED (parent_flags & ZEND_ACC_FINAL )) {
814825 if (check_only ) {
815826 return INHERITANCE_ERROR ;
@@ -851,10 +862,6 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(z
851862 child -> common .fn_flags |= ZEND_ACC_CHANGED ;
852863 }
853864
854- if ((parent_flags & ZEND_ACC_PRIVATE ) && !(parent_flags & ZEND_ACC_ABSTRACT )) {
855- return INHERITANCE_SUCCESS ;
856- }
857-
858865 proto = parent -> common .prototype ?
859866 parent -> common .prototype : parent ;
860867
0 commit comments