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

[TypeInfo] Prevent interfaces extending BackedEnum to be treated as BackedEnums#61543

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@ettoredn
Copy link
Contributor

@ettorednettoredn commentedAug 27, 2025
edited
Loading

QA
Branch?7.3
Bug fix?yes
New feature?no
Deprecations?no
Issues
LicenseMIT

Given

interface DummyBackedEnumInterface extends \BackedEnum{}

TypeFactoryTrait.php::enum():249 throws exceptionClass "DummyBackedEnumInterface" is not an enum trying to get the backing type, which is not defined.

    public static function enum(string $className, ?BuiltinType $backingType = null): EnumType    {        if (is_subclass_of($className, \BackedEnum::class)) {            if (null === $backingType) {                $reflectionBackingType = (new \ReflectionEnum($className))->getBackingType(); // <-- throws                 $typeIdentifier = TypeIdentifier::INT->value === (string) $reflectionBackingType ? TypeIdentifier::INT : TypeIdentifier::STRING;                $backingType = new BuiltinType($typeIdentifier);            }            return new BackedEnumType($className, $backingType);        }        return new EnumType($className);    }

This PR is meant as a fix. Upgrading to 7.3 broke my project because of this issue.

The open problem is how TypeInfo should handle BackedEnums that have no backing type defined. Besides interfaces, I'm not aware of any other way this can happen.

An alternative would be to extendBackedEnumType to support undefined backing type.

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

ettoredn reacted with thumbs up emoji

@ettorednettoredn marked this pull request as ready for reviewAugust 27, 2025 20:25
@carsonbotcarsonbot added this to the7.3 milestoneAug 27, 2025
@ettorednettorednforce-pushed thefix/typeinfo-backedenum-interface branch from0539a1e toe1b4b24CompareAugust 27, 2025 20:40
@nicolas-grekasnicolas-grekasforce-pushed thefix/typeinfo-backedenum-interface branch frome1b4b24 tofe49578CompareAugust 28, 2025 09:38
@nicolas-grekas
Copy link
Member

Thank you@ettoredn.

ettoredn reacted with thumbs up emojiettoredn reacted with rocket emoji

@nicolas-grekasnicolas-grekas merged commit62eb019 intosymfony:7.3Aug 28, 2025
8 of 11 checks passed
@ettoredn
Copy link
ContributorAuthor

Hi@nicolas-grekas, thanks for merging the PR. Should the change be included in the CHANGELOG-7.3.md?

@mtarld
Copy link
Contributor

As it's a bug fix, it's not needed@ettoredn 🙂

ettoredn reacted with thumbs up emoji

@fabpotfabpot mentioned this pull requestAug 29, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

7.3

Development

Successfully merging this pull request may close these issues.

4 participants

@ettoredn@carsonbot@nicolas-grekas@mtarld

[8]ページ先頭

©2009-2025 Movatter.jp