@@ -1713,17 +1713,21 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
17131713}
17141714/* }}} */
17151715
1716- static inline void do_implement_interface (zend_class_entry * ce , zend_class_entry * iface ) /* {{{ */
1716+ static inline void do_implement_interface_ex (zend_class_entry * ce , zend_class_entry * inherited_face , zend_class_entry * base_iface )
17171717{
1718- if (!(ce -> ce_flags & ZEND_ACC_INTERFACE ) && iface -> interface_gets_implemented && iface -> interface_gets_implemented (iface , ce ) == FAILURE ) {
1719- 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 ));
1718+ if (!(ce -> ce_flags & ZEND_ACC_INTERFACE ) && inherited_face -> interface_gets_implemented && inherited_face -> interface_gets_implemented (base_iface , ce ) == FAILURE ) {
1719+ 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 ));
17201720 }
17211721 /* This should be prevented by the class lookup logic. */
1722- ZEND_ASSERT (ce != iface );
1722+ ZEND_ASSERT (ce != base_iface );
1723+ }
1724+
1725+ static inline void do_implement_interface (zend_class_entry * ce , zend_class_entry * iface )
1726+ {
1727+ do_implement_interface_ex (ce , iface , iface );
17231728}
1724- /* }}} */
17251729
1726- static void zend_do_inherit_interfaces (zend_class_entry * ce , const zend_class_entry * iface ) /* {{{ */
1730+ static void zend_do_inherit_interfaces (zend_class_entry * ce , zend_class_entry * iface ) /* {{{ */
17271731{
17281732 /* expects interface to be contained in ce's interface list already */
17291733 uint32_t i , ce_num , if_num = iface -> num_interfaces ;
@@ -1753,7 +1757,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
17531757
17541758 /* and now call the implementing handlers */
17551759 while (ce_num < ce -> num_interfaces ) {
1756- do_implement_interface (ce , ce -> interfaces [ce_num ++ ]);
1760+ do_implement_interface_ex (ce , ce -> interfaces [ce_num ++ ], iface );
17571761 }
17581762}
17591763/* }}} */
@@ -2410,6 +2414,10 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
24102414 zend_class_constant * c ;
24112415 uint32_t flags = ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY ;
24122416
2417+ if (iface -> num_interfaces ) {
2418+ zend_do_inherit_interfaces (ce , iface );
2419+ }
2420+
24132421 if (!(ce -> ce_flags & ZEND_ACC_INTERFACE )) {
24142422 /* We are not setting the prototype of overridden interface methods because of abstract
24152423 * constructors. See Zend/tests/interface_constructor_prototype_001.phpt. */
@@ -2526,9 +2534,6 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry *
25262534 } ZEND_HASH_FOREACH_END ();
25272535
25282536 do_implement_interface (ce , iface );
2529- if (iface -> num_interfaces ) {
2530- zend_do_inherit_interfaces (ce , iface );
2531- }
25322537}
25332538/* }}} */
25342539
0 commit comments