Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Wrong error message if Enum doesn't correctly implement an interface #7792

Closed
@KalleZ

Description

@KalleZ

Description

The following code:

<?phpinterface A {publicfunctiona():void;}enum Bimplements A {}

Resulted in this output:

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.cindex 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.cindex 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp