php / php/php-src

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

Open
#16,447 4 comments 0 reactions 0 assignees View on GitHub

@DanielEScherzer is already working on this.

Since Oct 15, 2024.

  • #16448 by @DanielEScherzer — open
Bug Category: Engine
Dominant language
C
Stars
40.4k
Forks
8.2k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PHP enum and interface reproduction shown in the issue, then inspect linked pull request #16448 because the work is already underway. Confirm that an enum implementing an interface with properties produces the expected fatal error rather than an abstract-method diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.