-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Enum error message consistency #9350
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
Enum error message consistency #9350
Conversation
… missing magic method tests
…ame in quotes, and updated tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest looks like a clear improvement. 👍
@ollieread Btw you can add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest looks good, and I appreciate the effort to keep these messages consistent :)
@@ -0,0 +1,15 @@ | |||
--TEST-- | |||
Enum __clone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Enum __clone | |
Enums cannot include the __clone magic method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the tests could profit from this change
Thanks, and I'm happy to help. As an aside, if you know any other bits that could do with some improvement to consistency, I'm happy to look at them. |
This PR addresses the points raised in #9262 by doing the following:
Updating magic method exception messages
Previously the error message:
Was only used for:
__sleep
__wakeup
__set_state
All of which I believe are "technically" not magic methods, whereas all of the other true magic methods gave the error message:
This PR updates it so that all true magic methods also give the following error:
Normalising double quote usage in error messages
Enum error messages were inconsistent in their usage of double quotes with an enum name, as well as with values.
This PR changes the following error messages:
Properties
Is now
Backing
Is now
In the spirit of keeping this consistent, double quotes have been added to the value when the backing type is int.
Added missing tests
I've also added tests for all of the magic methods that weren't previously covered.
Stringable
Nothing was done with the Stringable interface, as originally planned, because the usage of
__toString
was always caught before the interface.