@@ -179,7 +179,7 @@ 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 && UNEXPECTED (parent -> constructor -> common .fn_flags & ZEND_ACC_FINAL )) {
183183 zend_error_noreturn (E_ERROR , "Cannot override final %s::%s() with %s::%s()" ,
184184 ZSTR_VAL (parent -> name ), ZSTR_VAL (parent -> constructor -> common .function_name ),
185185 ZSTR_VAL (ce -> name ), ZSTR_VAL (ce -> constructor -> common .function_name ));
@@ -810,6 +810,15 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(z
810810 uint32_t parent_flags = parent -> common .fn_flags ;
811811 zend_function * proto ;
812812
813+ if (UNEXPECTED ((parent_flags & ZEND_ACC_PRIVATE ) && !(parent_flags & ZEND_ACC_ABSTRACT ) && !(parent_flags & ZEND_ACC_CTOR ))) {
814+ if (!check_only ) {
815+ child -> common .fn_flags |= ZEND_ACC_CHANGED ;
816+ child -> common .prototype = NULL ;
817+ }
818+ /* The parent method is private and not an abstract so we don't need to check any inheritance rules */
819+ return INHERITANCE_SUCCESS ;
820+ }
821+
813822 if (!checked && UNEXPECTED (parent_flags & ZEND_ACC_FINAL )) {
814823 if (check_only ) {
815824 return INHERITANCE_ERROR ;
@@ -851,10 +860,6 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(z
851860 child -> common .fn_flags |= ZEND_ACC_CHANGED ;
852861 }
853862
854- if ((parent_flags & ZEND_ACC_PRIVATE ) && !(parent_flags & ZEND_ACC_ABSTRACT )) {
855- return INHERITANCE_SUCCESS ;
856- }
857-
858863 proto = parent -> common .prototype ?
859864 parent -> common .prototype : parent ;
860865
0 commit comments