Skip to content

Commit a96e15c

Browse files
committed
simplify property override check
1 parent 2f6eb37 commit a96e15c

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

Zend/zend_inheritance.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,9 +1567,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
15671567
ZSTR_VAL(parent_info->ce->name));
15681568
}
15691569

1570-
if (child_info->flags & ZEND_ACC_OVERRIDE) {
1571-
child_info->flags &= ~ZEND_ACC_OVERRIDE;
1572-
}
1570+
child_info->flags &= ~ZEND_ACC_OVERRIDE;
15731571
}
15741572
} else {
15751573
zend_function **hooks = parent_info->hooks;
@@ -2308,7 +2306,7 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
23082306
void zend_inheritance_check_override(const zend_class_entry *ce)
23092307
{
23102308
zend_function *f;
2311-
zend_property_info *p;
2309+
zend_property_info *prop;
23122310

23132311
if (ce->ce_flags & ZEND_ACC_TRAIT) {
23142312
return;
@@ -2325,34 +2323,29 @@ void zend_inheritance_check_override(const zend_class_entry *ce)
23252323
}
23262324
} ZEND_HASH_FOREACH_END();
23272325

2328-
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, p) {
2329-
if (p->flags & ZEND_ACC_OVERRIDE) {
2326+
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop) {
2327+
if (prop->flags & ZEND_ACC_OVERRIDE) {
23302328
zend_error_noreturn(
23312329
E_COMPILE_ERROR,
23322330
"%s::$%s has #[\\Override] attribute, but no matching parent property exists",
2333-
ZSTR_VAL(ce->name), zend_get_unmangled_property_name(p->name));
2331+
ZSTR_VAL(ce->name), zend_get_unmangled_property_name(prop->name));
23342332
}
2335-
} ZEND_HASH_FOREACH_END();
23362333

2337-
if (ce->num_hooked_props) {
2338-
zend_property_info *prop;
2339-
ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop) {
2340-
if (!prop->hooks) {
2341-
continue;
2342-
}
2343-
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
2344-
f = prop->hooks[i];
2345-
if (f && f->common.fn_flags & ZEND_ACC_OVERRIDE) {
2346-
ZEND_ASSERT(f->type != ZEND_INTERNAL_FUNCTION);
2334+
if (!prop->hooks) {
2335+
continue;
2336+
}
2337+
for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) {
2338+
f = prop->hooks[i];
2339+
if (f && f->common.fn_flags & ZEND_ACC_OVERRIDE) {
2340+
ZEND_ASSERT(f->type != ZEND_INTERNAL_FUNCTION);
23472341

2348-
zend_error_at_noreturn(
2349-
E_COMPILE_ERROR, f->op_array.filename, f->op_array.line_start,
2350-
"%s::%s() has #[\\Override] attribute, but no matching parent method exists",
2351-
ZEND_FN_SCOPE_NAME(f), ZSTR_VAL(f->common.function_name));
2352-
}
2342+
zend_error_at_noreturn(
2343+
E_COMPILE_ERROR, f->op_array.filename, f->op_array.line_start,
2344+
"%s::%s() has #[\\Override] attribute, but no matching parent method exists",
2345+
ZEND_FN_SCOPE_NAME(f), ZSTR_VAL(f->common.function_name));
23532346
}
2354-
} ZEND_HASH_FOREACH_END();
2355-
}
2347+
}
2348+
} ZEND_HASH_FOREACH_END();
23562349
}
23572350

23582351

0 commit comments

Comments
 (0)