|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-25 20:24 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2021-07-25 20:24 UTC] requinix@php.net
[2021-07-26 01:15 UTC] raincomplain at outlook dot com
-Status: Feedback
+Status: Open
[2021-07-26 01:15 UTC] raincomplain at outlook dot com
[2021-07-26 02:39 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2021-07-26 02:39 UTC] requinix@php.net
[2021-07-26 03:20 UTC] raincomplain at outlook dot com
-Status: Feedback
+Status: Closed
[2021-07-26 03:20 UTC] raincomplain at outlook dot com
[2021-07-26 03:22 UTC] requinix@php.net
-Status: Closed
+Status: Not a bug
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 21:00:01 2025 UTC |
Description: ------------ Both Pure Enums and Backed Enums implement an internal interface named UnitEnum. UnitEnum includes a static method cases(). So manually defining cases() method on an Enum results in a fatal error as expected(as clarified in enum RFC). However, it seems it's allowed to define cases() in a trait, resulting in cases() being a requirment in the exhibiting enum with somewhat a confused error which makes no sense!. I think we should clarify with a proper error message that abstract cases() is not allowed too. Non-abstract cases() is totally fine since the enum implementation will take precedance over trait so no error message is needed here. Test script: --------------- enum Size: int { use Test; } trait Test { abstract static private function cases(): int; } Expected result: ---------------- PHP Fatal error: Abstract Size::cases() is already implemented Actual result: -------------- PHP Fatal error: Declaration of Size::cases(): array must be compatible with Test::cases(): int in /var/www/html/index.php on line 0