Skip to content

Commit a3e29ba

Browse files
committed
Prefer using declaring class rather than direct parent in error
Point to the class that actually declares the property, which is not necessarily the same as the direct parent class.
1 parent b0c920f commit a3e29ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Zend/zend_inheritance.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,12 +974,12 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
974974
if (!(parent_info->flags & ZEND_ACC_PRIVATE)) {
975975
if (UNEXPECTED((parent_info->flags & ZEND_ACC_STATIC) != (child_info->flags & ZEND_ACC_STATIC))) {
976976
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s%s::$%s as %s%s::$%s",
977-
(parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(ce->parent->name), ZSTR_VAL(key),
977+
(parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(parent_info->ce->name), ZSTR_VAL(key),
978978
(child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ZSTR_VAL(ce->name), ZSTR_VAL(key));
979979
}
980980

981981
if (UNEXPECTED((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK))) {
982-
zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ZSTR_VAL(ce->name), ZSTR_VAL(key), zend_visibility_string(parent_info->flags), ZSTR_VAL(ce->parent->name), (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
982+
zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ZSTR_VAL(ce->name), ZSTR_VAL(key), zend_visibility_string(parent_info->flags), ZSTR_VAL(parent_info->ce->name), (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
983983
} else if ((child_info->flags & ZEND_ACC_STATIC) == 0) {
984984
int parent_num = OBJ_PROP_TO_NUM(parent_info->offset);
985985
int child_num = OBJ_PROP_TO_NUM(child_info->offset);
@@ -1004,7 +1004,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
10041004
"Type of %s::$%s must not be defined (as in class %s)",
10051005
ZSTR_VAL(ce->name),
10061006
ZSTR_VAL(key),
1007-
ZSTR_VAL(ce->parent->name));
1007+
ZSTR_VAL(parent_info->ce->name));
10081008
}
10091009
}
10101010
} else {
@@ -1072,7 +1072,7 @@ static void do_inherit_class_constant(zend_string *name, zend_class_constant *pa
10721072
c = (zend_class_constant*)Z_PTR_P(zv);
10731073
if (UNEXPECTED((Z_ACCESS_FLAGS(c->value) & ZEND_ACC_PPP_MASK) > (Z_ACCESS_FLAGS(parent_const->value) & ZEND_ACC_PPP_MASK))) {
10741074
zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::%s must be %s (as in class %s)%s",
1075-
ZSTR_VAL(ce->name), ZSTR_VAL(name), zend_visibility_string(Z_ACCESS_FLAGS(parent_const->value)), ZSTR_VAL(ce->parent->name), (Z_ACCESS_FLAGS(parent_const->value) & ZEND_ACC_PUBLIC) ? "" : " or weaker");
1075+
ZSTR_VAL(ce->name), ZSTR_VAL(name), zend_visibility_string(Z_ACCESS_FLAGS(parent_const->value)), ZSTR_VAL(parent_const->ce->name), (Z_ACCESS_FLAGS(parent_const->value) & ZEND_ACC_PUBLIC) ? "" : " or weaker");
10761076
}
10771077
} else if (!(Z_ACCESS_FLAGS(parent_const->value) & ZEND_ACC_PRIVATE)) {
10781078
if (Z_TYPE(parent_const->value) == IS_CONSTANT_AST) {

0 commit comments

Comments
 (0)