Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enums should not be allowed to implement interfaces with properties in 8.4 #16447

Open
vudaltsov opened this issue Oct 15, 2024 · 2 comments
Open

Comments

@vudaltsov
Copy link
Contributor

Description

The following code:

interface I
{
    public string $x { get; }
}

enum E implements I
{
}

Resulted in this output:

PHP Fatal error:  Enum E must implement 1 abstract private method (I::$x::get)

But I expected this output instead:

PHP Fatal error:  Enum E cannot implement interfaces with properties

PHP Version

PHP 8.4.0-dev (cli) (built: Sep 24 2024 14:38:59) (NTS)

Operating System

MacOS

@vudaltsov
Copy link
Contributor Author

By the way, why I::$x::get is called "private" in the error?

@DanielEScherzer
Copy link
Contributor

"private" was fixed in master but not 8.4, see #15995
I'll work on a patch for better enum error messages

DanielEScherzer added a commit to DanielEScherzer/php-src that referenced this issue Oct 15, 2024
…perties

Enums cannot have properties, and so can not be made to satisfy the interface
at all; show a clearer error message than the suggestion to implement the
hooked properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants