Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

Hi @Ocramius

We encountered an issue in PHPStan when someone analyse some (invalid) PHP code with an invalid backed enum with a case without value, PHPStan is crashing (phpstan/phpstan#7927).

Our strategy would be to introduce a ReflectionEnumCase::hasValueExpression method (basically a is valid enum case). And before adding it to the Phpstan/BetterReflection fork, I wanted to know if you would be interested/ok having this method in BetterReflection because it might have some other interest.

I tried added a test case to show the situation.

Feel free to close this PR if the method doesn't interest you.
Thanks !

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's just make sure we expand a bit on what the intended method use-case is, in the docblock

{
}

enum InvalidEnum: int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be moved somewhere where it won't be analysed 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@VincentLanglet
Copy link
Contributor Author

LGTM, let's just make sure we expand a bit on what the intended method use-case is, in the docblock

I tried to add some explanations in the phpDoc

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 thanks @VincentLanglet

@Ocramius Ocramius changed the title Add ReflectionEnumCase::hasValueExpression Add ReflectionEnumCase#hasValueExpression() Sep 19, 2025
@Ocramius Ocramius merged commit d9f0f93 into Roave:6.64.x Sep 19, 2025
37 checks passed
@Ocramius Ocramius self-assigned this Sep 19, 2025
@Ocramius Ocramius added this to the 6.64.0 milestone Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants