Skip to content

Instantly share code, notes, and snippets.

@adsr
Created February 23, 2016 18:30
Show Gist options
  • Select an option

  • Save adsr/c26e8670ad6aef14f641 to your computer and use it in GitHub Desktop.

Select an option

Save adsr/c26e8670ad6aef14f641 to your computer and use it in GitHub Desktop.
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 77ea7d5..5045544 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -1000,20 +1000,34 @@ ZEND_API void zend_do_implement_trait(zend_class_entry *ce, zend_class_entry *tr
if (!ignore) {
if (ce->num_traits >= current_trait_num) {
if (ce->type == ZEND_INTERNAL_CLASS) {
ce->traits = (zend_class_entry **) realloc(ce->traits, sizeof(zend_class_entry *) * (++current_trait_num));
} else {
ce->traits = (zend_class_entry **) erealloc(ce->traits, sizeof(zend_class_entry *) * (++current_trait_num));
}
}
ce->traits[ce->num_traits++] = trait;
}
+
+ if (trait->num_interfaces > 0) {
+ uint32_t total_ifaces = ce->num_interfaces + trait->num_interfaces;
+ uint32_t i;
+ if (ce->type == ZEND_INTERNAL_CLASS) {
+ ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) * total_ifaces);
+ } else {
+ ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *) * total_ifaces);
+ }
+ for (i = 0; i < trait->num_interfaces; ++i) {
+ ce->interfaces[ce->num_interfaces + i] = trait->interfaces[i];
+ }
+ ce->num_interfaces += total_ifaces;
+ }
}
/* }}} */
static zend_bool zend_traits_method_compatibility_check(zend_function *fn, zend_function *other_fn) /* {{{ */
{
uint32_t fn_flags = fn->common.scope->ce_flags;
uint32_t other_flags = other_fn->common.scope->ce_flags;
return zend_do_perform_implementation_check(fn, other_fn)
&& ((other_fn->common.scope->ce_flags & ZEND_ACC_INTERFACE) || zend_do_perform_implementation_check(other_fn, fn))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment