You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP Fatal error: Class E contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (I::a) in Command line code on line 1
But I expected this output instead:
PHP Fatal error: Enum E contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (I::a) in Command line code on line 1
Patch:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 3ef291c315..04d5728ef1 100644
--- a/Zend/zend_API.c+++ b/Zend/zend_API.c@@ -4789,6 +4789,8 @@ ZEND_API ZEND_COLD const char *zend_get_object_type(const zend_class_entry *ce)
return "trait";
} else if (ce->ce_flags & ZEND_ACC_INTERFACE) {
return "interface";
+ } else if (ce->ce_flags & ZEND_ACC_ENUM) {+ return "enum";
} else {
return "class";
}
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 82af3d8afa..002da24383 100644
--- a/Zend/zend_inheritance.c+++ b/Zend/zend_inheritance.c@@ -2324,9 +2324,13 @@ void zend_verify_abstract_class(zend_class_entry *ce) /* {{{ */
} ZEND_HASH_FOREACH_END();
if (ai.cnt) {
+ char* kind = strdup(zend_get_object_type(ce));+ kind[0] = toupper(kind[0]);+
zend_error_noreturn(E_ERROR, !is_explicit_abstract
- ? "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")"- : "Class %s must implement %d abstract private method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",+ ? "%s %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")"+ : "%s %s must implement %d abstract private method%s (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",+ kind,
ZSTR_VAL(ce->name), ai.cnt,
ai.cnt > 1 ? "s" : "",
DISPLAY_ABSTRACT_FN(0),
PHP Version
8.1.*
Operating System
Irrelevant
The text was updated successfully, but these errors were encountered:
We've explicitly decided not to adjust error messages in fear of opening a can of worms. I'm ok with this change but there are likely other places where the same thing applies.
I missed that zend_get_object_type was a new thing 👍
It's not 😄 I'll check how many other places exists where class could be replaced with enum.
Description
The following code:
Resulted in this output:
But I expected this output instead:
Patch:
PHP Version
8.1.*
Operating System
Irrelevant
The text was updated successfully, but these errors were encountered: