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
Replace is_a
calls in core with instanceof
#4935
Conversation
5786196
to
3928338
Compare
@@ -140,7 +140,7 @@ function twentyseventeen_edit_link() { | |||
* @param int $id Front page section to display. | |||
*/ | |||
function twentyseventeen_front_page_section( $partial = null, $id = 0 ) { | |||
if ( is_a( $partial, 'WP_Customize_Partial' ) ) { | |||
if ( $partial instanceof \WP_Customize_Partial ) { |
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.
I think we shouldn't do the modifications for the bundled themes in this ticket.
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.
May I ask why that is? It is part of WordPress core, and because this is not an API change, I think changing parts of core that people might extend or reuse is still fine.
If the changes were to be merged with changes in the themes, that makes we have zero is_a
calls.
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.
@Ayesh Themes often support a wider range of WP versions/PHP versions, so we need to be wary of making changes to them which could cause cross-version compatibility issues, though I don't see how this change would cause such an issue as instanceof
is available with the above syntax since PHP 5.0.
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.
Yes, apart from that, also I wanted to keep this ticket for only the changes in the core, we can do these changes in another ticket for the Bundled Themes using the Bundled Themes component, for help in tracking.
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.
FWIW, bundled theme files are often included in general optimizations like this, so I think it's fine to keep this change here, no need for a separate PR 👍
Replaces all `is_a` function calls with `instanceof` keyword, which in theory should be faster, and provides more code clarity. The replacements use extra braces to enhance the clarity although they are technically not necessary.
3928338
to
6163c4e
Compare
Replace `is_a` with `instanceof` in `wp-includes/http.php` Co-authored-by: Rajinsharwar <rajinsharwar@gmail.com>
Added one instance of missing Thank you @jrfnl @SergeyBiryukov @Rajinsharwar. |
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.
Thanks @Ayesh for the PR. The changes look good to me.
Thanks for the PR! Merged in r56352. |
Replaces all
is_a
function calls withinstanceof
keyword, which in theory should be faster, and provides more code clarity. The replacements use extra braces to enhance the clarity although they are technically not necessary.Trac ticket: https://core.trac.wordpress.org/ticket/58943#ticket
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.