[wp-trac] [WordPress Trac] #43755: CS: Fix violations for wp-includes/canonical.php
WordPress Trac
noreply at wordpress.org
Wed Jan 16 04:13:11 UTC 2019
#43755: CS: Fix violations for wp-includes/canonical.php
-------------------------------------+-------------------------------
Reporter: jipmoors | Owner: netweb
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 5.2
Component: Canonical | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-refresh | Focuses: coding-standards
-------------------------------------+-------------------------------
Changes (by pento):
* keywords: has-patch => has-patch needs-refresh
* milestone: 5.1 => 5.2
Comment:
This is going to need some careful review. A couple of notes from my brief
read through:
When moving an assignment out of a conditional block, it should be moved
to before the conditional, unless there are significant performance
reasons to move it inside.
eg:
{{{#!php
if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) {
// ...
}
}}}
would become:
{{{#!php
$id = get_query_var( 'p' );
if ( $id && is_feed() ) {
// ...
}
}}}
There's no need to add an `empty()` call where there wasn't one before.
Similarly, there's no need to add extra type checks. If the value returned
by `get_permalink()` is truth-y, you can assume it's a string.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43755#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list