Skip to content

Conversation

@Girgias
Copy link
Member

@Girgias Girgias commented May 22, 2025

Needed for #18260 so that different bound types for implicit and explicitly implemented interfaces are checked correctly due to how the implementation stores the types in the HashTable.

I don't see any particular reason as to why the inheritance of interfaces was delayed, thus moving it early doesn't seem like an issue to me.

@Girgias Girgias force-pushed the inherit-interfaces-early branch from cb173f5 to 91c5a7c Compare January 3, 2026 18:29
@Girgias Girgias requested review from arnaud-lb and iluuu1994 January 4, 2026 00:06
@Girgias Girgias marked this pull request as ready for review January 4, 2026 00:06
@Girgias Girgias requested a review from dstogov as a code owner January 4, 2026 00:06
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything blocking from moving zend_do_inherit_interfaces() at the beginning of do_interface_implementation(), but maybe wait for other reviews.

One potential BC would be that interface_gets_implemented is now called early, but this doesn't appear to be an issue in practice.

@Girgias
Copy link
Member Author

Girgias commented Jan 6, 2026

One potential BC would be that interface_gets_implemented is now called early, but this doesn't appear to be an issue in practice.

The only thing I could see happening is a different compile time error being emitted, but I didn't manage to find such a test case.

@Girgias Girgias requested a review from TimWolla January 11, 2026 21:03
Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't meaningfully comment on the change itself, as I am not familiar with the code.

Comment on lines +1592 to 1595
static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface)
{
do_implement_interface_ex(ce, iface, iface);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the _ex? distinction? The function is static and only used 2 times from what I see.

/* }}} */

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent naming, face vs. iface. I also find the names confusing. With the name do_implement_interface_ex, it's not clear which interface is being implelmented.

{
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? interface_gets_implemented() should be able to validate if an inteface can be implemented, but if we only pass the base_iface, we'll miss validation for the actual inherited interface. E.g. will this break if UnitEnum is added to a class implicitly through an inherited interface?

Is this change needed at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants