Skip to content

Commit f57f092

Browse files
committed
Remove ZEND_ACC_IMPLEMENTS_TRAITS flag
This is equivalent to checking ce->num_traits.
1 parent 4f5f72c commit f57f092

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

Zend/zend_compile.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6471,7 +6471,6 @@ void zend_compile_use_trait(zend_ast *ast) /* {{{ */
64716471
zend_class_entry *ce = CG(active_class_entry);
64726472
uint32_t i;
64736473

6474-
ce->ce_flags |= ZEND_ACC_IMPLEMENT_TRAITS;
64756474
ce->trait_names = erealloc(ce->trait_names, sizeof(zend_class_name) * (ce->num_traits + traits->children));
64766475

64776476
for (i = 0; i < traits->children; ++i) {
@@ -6665,7 +6664,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
66656664

66666665
if (toplevel
66676666
/* We currently don't early-bind classes that implement interfaces or use traits */
6668-
&& !(ce->ce_flags & (ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))
6667+
&& !(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) && !ce->num_traits
66696668
&& !(CG(compiler_options) & ZEND_COMPILE_PRELOAD)) {
66706669
if (extends_ast) {
66716670
zend_class_entry *parent_ce = zend_lookup_class_ex(
@@ -6726,7 +6725,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
67266725
if (extends_ast && toplevel
67276726
&& (CG(compiler_options) & ZEND_COMPILE_DELAYED_BINDING)
67286727
/* We currently don't early-bind classes that implement interfaces or use traits */
6729-
&& !(ce->ce_flags & (ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))
6728+
&& !(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) && !ce->num_traits
67306729
) {
67316730
CG(active_op_array)->fn_flags |= ZEND_ACC_EARLY_BINDING;
67326731
opline->opcode = ZEND_DECLARE_CLASS_DELAYED;

Zend/zend_compile.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ typedef struct _zend_oparray_context {
229229
/* op_array or class is preloaded | | | */
230230
#define ZEND_ACC_PRELOADED (1 << 10) /* X | X | | */
231231
/* | | | */
232-
/* Class Flags (unused: 13, 24...) | | | */
232+
/* Class Flags (unused: 13, 15, 24...) | | | */
233233
/* =========== | | | */
234234
/* | | | */
235235
/* Special class types | | | */
@@ -254,9 +254,6 @@ typedef struct _zend_oparray_context {
254254
/* Class implements interface(s) | | | */
255255
#define ZEND_ACC_IMPLEMENT_INTERFACES (1 << 14) /* X | | | */
256256
/* | | | */
257-
/* Class uses trait(s) | | | */
258-
#define ZEND_ACC_IMPLEMENT_TRAITS (1 << 15) /* X | | | */
259-
/* | | | */
260257
/* User class has methods with static variables | | | */
261258
#define ZEND_HAS_STATIC_IN_METHODS (1 << 16) /* X | | | */
262259
/* | | | */

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_nam
24602460
}
24612461
zend_do_inheritance(ce, parent);
24622462
}
2463-
if (ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS) {
2463+
if (ce->num_traits) {
24642464
zend_do_bind_traits(ce);
24652465
}
24662466
if (ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) {

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,14 +4150,14 @@ static int preload_optimize(zend_persistent_script *script)
41504150
}
41514151

41524152
ZEND_HASH_FOREACH_PTR(&script->script.class_table, ce) {
4153-
if (ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS) {
4153+
if (ce->num_traits) {
41544154
preload_fix_trait_methods(ce);
41554155
}
41564156
} ZEND_HASH_FOREACH_END();
41574157

41584158
ZEND_HASH_FOREACH_PTR(preload_scripts, script) {
41594159
ZEND_HASH_FOREACH_PTR(&script->script.class_table, ce) {
4160-
if (ce->ce_flags & ZEND_ACC_IMPLEMENT_TRAITS) {
4160+
if (ce->num_traits) {
41614161
preload_fix_trait_methods(ce);
41624162
}
41634163
} ZEND_HASH_FOREACH_END();

0 commit comments

Comments
 (0)