Skip to content

enum::from() takes BackedEnum types into account - #6790

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
AJenbo:backed-enum
Oct 23, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
AJenbo:backed-enum

Conversation

@AJenbo

@AJenbo AJenbo commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@AJenbo AJenbo changed the title enum::tryFrom() and enum::from() takes BackedEnum types enum::from() takes BackedEnum types into account Oct 23, 2026

@staabm staabm left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a feeling we did a similar thing recently with from or tryFrom, but I cannot find it anymore.

//cc @SanderMuller


LGTM

@ondrejmirtes
ondrejmirtes merged commit 61a0d9f into phpstan:2.3.x Oct 23, 2026
989 of 992 checks passed
@ondrejmirtes

Copy link
Copy Markdown
Member

Thank you!

@AJenbo

AJenbo commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Just helping my self here :)

@SanderMuller

Copy link
Copy Markdown
Contributor

Just helping my self here :)

And others!

@ondrejmirtes

Copy link
Copy Markdown
Member

FYI doing this for bleeding edge only: #6795

Narrowing parameter types falls under "new rules" in my eyes, people might have too-wide types somewhere in a completely harmless situation. We're typically doing the same when updating signatures in functionMap too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IntBackedEnum and StringBackedEnum constructor not taken in to account

4 participants