@@ -1580,17 +1580,21 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
15801580}
15811581/* }}} */
15821582
1583- static inline void do_implement_interface (zend_class_entry * ce , zend_class_entry * iface ) /* {{{ */
1583+ static inline void do_implement_interface_ex (zend_class_entry * ce , zend_class_entry * inherited_face , zend_class_entry * base_iface )
15841584{
1585- if (!(ce -> ce_flags & ZEND_ACC_INTERFACE ) && iface -> interface_gets_implemented && iface -> interface_gets_implemented (iface , ce ) == FAILURE ) {
1586- zend_error_noreturn (E_CORE_ERROR , "%s %s could not implement interface %s" , zend_get_object_type_uc (ce ), ZSTR_VAL (ce -> name ), ZSTR_VAL (iface -> name ));
1585+ if (!(ce -> ce_flags & ZEND_ACC_INTERFACE ) && inherited_face -> interface_gets_implemented && inherited_face -> interface_gets_implemented (base_iface , ce ) == FAILURE ) {
1586+ zend_error_noreturn (E_CORE_ERROR , "%s %s could not implement interface %s" , zend_get_object_type_uc (ce ), ZSTR_VAL (ce -> name ), ZSTR_VAL (base_iface -> name ));
15871587 }
15881588 /* This should be prevented by the class lookup logic. */
1589- ZEND_ASSERT (ce != iface );
1589+ ZEND_ASSERT (ce != base_iface );
1590+ }
1591+
1592+ static inline void do_implement_interface (zend_class_entry * ce , zend_class_entry * iface )
1593+ {
1594+ do_implement_interface_ex (ce , iface , iface );
15901595}
1591- /* }}} */
15921596
1593- static void zend_do_inherit_interfaces (zend_class_entry * ce , const zend_class_entry * iface ) /* {{{ */
1597+ static void zend_do_inherit_interfaces (zend_class_entry * ce , zend_class_entry * iface ) /* {{{ */
15941598{
15951599 /* expects interface to be contained in ce's interface list already */
15961600 uint32_t i , ce_num , if_num = iface -> num_interfaces ;
@@ -1619,7 +1623,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
16191623
16201624 /* and now call the implementing handlers */
16211625 while (ce_num < ce -> num_interfaces ) {
1622- do_implement_interface (ce , ce -> interfaces [ce_num ++ ]);
1626+ do_implement_interface_ex (ce , ce -> interfaces [ce_num ++ ], iface );
16231627 }
16241628}
16251629/* }}} */
@@ -2169,6 +2173,10 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
21692173 zend_class_constant * c ;
21702174 uint32_t flags = ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY ;
21712175
2176+ if (iface -> num_interfaces ) {
2177+ zend_do_inherit_interfaces (ce , iface );
2178+ }
2179+
21722180 if (!(ce -> ce_flags & ZEND_ACC_INTERFACE )) {
21732181 /* We are not setting the prototype of overridden interface methods because of abstract
21742182 * constructors. See Zend/tests/interface_constructor_prototype_001.phpt. */
@@ -2200,9 +2208,6 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
22002208 } ZEND_HASH_FOREACH_END ();
22012209
22022210 do_implement_interface (ce , iface );
2203- if (iface -> num_interfaces ) {
2204- zend_do_inherit_interfaces (ce , iface );
2205- }
22062211}
22072212/* }}} */
22082213
0 commit comments