-
Notifications
You must be signed in to change notification settings - Fork 384
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
Use class constants instead of classes as string literals #6545
Conversation
__( 'Embed Handler (%1$s) must extend `%2$s`', 'amp' ), | ||
esc_html( $embed_handler_class ), | ||
'AMP_Embed_Handler' | ||
AMP_Base_Embed_Handler::class |
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.
Bugfix!
__( 'Embed Handler (%1$s) must extend `%2$s`', 'amp' ), | ||
esc_html( $embed_handler_class ), | ||
'AMP_Embed_Handler' | ||
AMP_Base_Embed_Handler::class |
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.
Bugfix!
Plugin builds for 7b85909 are ready 🛎️!
|
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.
Interesting! It's great that you caught those undefined classes before they became reported bugs.
Was there any fancy way you used to find these strings or was it a search/replace?
I used a regex search and replace, essentially: |
I'm not sure how to QA this ticket; if there would be any issues caused by this change, we'd notice this either during running the automated tests or while developing the other stuff. Do we have any manual test scenarios defined somewhere for tickets like this one? I did run smoke tests and didn't notice any issues, so I think we can mark it as QA passed. |
Summary
Since we now require PHP 5.6+, we can make use of the
::class
constant instead of using string literals. This will make it easier to catch bugs (as this ended up doing) and make it easier to do refactorings.Checklist