-
Notifications
You must be signed in to change notification settings - Fork 8k
Zend: Inherit interfaces early #18622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1580,17 +1580,21 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke | |
| } | ||
| /* }}} */ | ||
|
|
||
| static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */ | ||
| static inline void do_implement_interface_ex(zend_class_entry *ce, zend_class_entry *inherited_face, zend_class_entry *base_iface) | ||
| { | ||
| if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented && iface->interface_gets_implemented(iface, ce) == FAILURE) { | ||
| 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)); | ||
| if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && inherited_face->interface_gets_implemented && inherited_face->interface_gets_implemented(base_iface, ce) == FAILURE) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct? Is this change needed at all? |
||
| 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)); | ||
| } | ||
| /* This should be prevented by the class lookup logic. */ | ||
| ZEND_ASSERT(ce != iface); | ||
| ZEND_ASSERT(ce != base_iface); | ||
| } | ||
|
|
||
| static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface) | ||
| { | ||
| do_implement_interface_ex(ce, iface, iface); | ||
| } | ||
|
Comment on lines
+1592
to
1595
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need the |
||
| /* }}} */ | ||
|
|
||
| static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_entry *iface) /* {{{ */ | ||
| static void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry *iface) /* {{{ */ | ||
| { | ||
| /* expects interface to be contained in ce's interface list already */ | ||
| 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 | |
|
|
||
| /* and now call the implementing handlers */ | ||
| while (ce_num < ce->num_interfaces) { | ||
| do_implement_interface(ce, ce->interfaces[ce_num++]); | ||
| do_implement_interface_ex(ce, ce->interfaces[ce_num++], iface); | ||
| } | ||
| } | ||
| /* }}} */ | ||
|
|
@@ -2169,6 +2173,10 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry * | |
| zend_class_constant *c; | ||
| uint32_t flags = ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY; | ||
|
|
||
| if (iface->num_interfaces) { | ||
| zend_do_inherit_interfaces(ce, iface); | ||
| } | ||
|
|
||
| if (!(ce->ce_flags & ZEND_ACC_INTERFACE)) { | ||
| /* We are not setting the prototype of overridden interface methods because of abstract | ||
| * 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 * | |
| } ZEND_HASH_FOREACH_END(); | ||
|
|
||
| do_implement_interface(ce, iface); | ||
| if (iface->num_interfaces) { | ||
| zend_do_inherit_interfaces(ce, iface); | ||
| } | ||
| } | ||
| /* }}} */ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent naming,
facevs.iface. I also find the names confusing. With the namedo_implement_interface_ex, it's not clear which interface is being implelmented.