]> granicus.if.org Git - php/commitdiff
Remove ZEND_ACC_IMPLEMENT_INTERFACES flag
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 6 Feb 2020 09:51:45 +0000 (10:51 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 6 Feb 2020 09:53:12 +0000 (10:53 +0100)
This is equivalent to checking ce->num_interfaces. The only subtle
moment is during inheritance, where num_interface may change when
parent interfaces are inherited. The check in zend_do_link_class
thus uses "interfaces", not "ce->num_interfaces".

Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_inheritance.c

index ecf7ce1686f00e42b538767ab6c850f3e27d4760..b915b7f8d69db61933c530a6294e03d9ebe8647f 100644 (file)
@@ -6523,7 +6523,6 @@ void zend_compile_implements(zend_ast *ast) /* {{{ */
                interface_names[i].lc_name = zend_string_tolower(interface_names[i].name);
        }
 
-       ce->ce_flags |= ZEND_ACC_IMPLEMENT_INTERFACES;
        ce->num_interfaces = list->children;
        ce->interface_names = interface_names;
 }
@@ -6664,7 +6663,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
 
        if (toplevel
                /* We currently don't early-bind classes that implement interfaces or use traits */
-        && !(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) && !ce->num_traits
+        && !ce->num_interfaces && !ce->num_traits
         && !(CG(compiler_options) & ZEND_COMPILE_PRELOAD)) {
                if (extends_ast) {
                        zend_class_entry *parent_ce = zend_lookup_class_ex(
@@ -6725,7 +6724,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
                if (extends_ast && toplevel
                         && (CG(compiler_options) & ZEND_COMPILE_DELAYED_BINDING)
                                /* We currently don't early-bind classes that implement interfaces or use traits */
-                        && !(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) && !ce->num_traits
+                        && !ce->num_interfaces && !ce->num_traits
                ) {
                        CG(active_op_array)->fn_flags |= ZEND_ACC_EARLY_BINDING;
                        opline->opcode = ZEND_DECLARE_CLASS_DELAYED;
index 97488a5e93329f59f3500a11cc98a6bb44b5913a..6c438b6902b59538413fb5d83100c45564b7993a 100644 (file)
@@ -229,7 +229,7 @@ typedef struct _zend_oparray_context {
 /* op_array or class is preloaded                         |     |     |     */
 #define ZEND_ACC_PRELOADED               (1 << 10) /*  X  |  X  |     |     */
 /*                                                        |     |     |     */
-/* Class Flags (unused: 13, 15, 24...)                    |     |     |     */
+/* Class Flags (unused: 13, 14, 15, 24...)                |     |     |     */
 /* ===========                                            |     |     |     */
 /*                                                        |     |     |     */
 /* Special class types                                    |     |     |     */
@@ -251,9 +251,6 @@ typedef struct _zend_oparray_context {
 /* Class constants updated                                |     |     |     */
 #define ZEND_ACC_CONSTANTS_UPDATED       (1 << 12) /*  X  |     |     |     */
 /*                                                        |     |     |     */
-/* Class implements interface(s)                          |     |     |     */
-#define ZEND_ACC_IMPLEMENT_INTERFACES    (1 << 14) /*  X  |     |     |     */
-/*                                                        |     |     |     */
 /* User class has methods with static variables           |     |     |     */
 #define ZEND_HAS_STATIC_IN_METHODS       (1 << 16) /*  X  |     |     |     */
 /*                                                        |     |     |     */
index a381fced2db9e0cbef17d30de503ac3ef772c545..5abe1c55d4a0c490514329215ad11db907c92283 100644 (file)
@@ -1161,7 +1161,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par
 
        /* Inherit interfaces */
        if (parent_ce->num_interfaces) {
-               if (!(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES)) {
+               if (!ce->num_interfaces) {
                        zend_do_inherit_interfaces(ce, parent_ce);
                } else {
                        uint32_t i;
@@ -2463,7 +2463,7 @@ ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_nam
        if (ce->num_traits) {
                zend_do_bind_traits(ce);
        }
-       if (ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) {
+       if (interfaces) {
                zend_do_implement_interfaces(ce, interfaces);
        }
        if ((ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) == ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) {