-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Document YodaConditionals you must #1724
Conversation
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.
Yeah! First PR!
<standard> | ||
<![CDATA[ | ||
When doing logical comparisons involving variables, the variable must be placed on the right side. All constants, literals, and function calls must be placed on the left side. If neither side is a variable, the order is unimportant. | ||
|
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.
Just noticed some trailing whitespace here.
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.
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.
Excellent! Thank you.
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 - minor fixes please :-)
<standard> | ||
<![CDATA[ | ||
When doing logical comparisons involving variables, the variable must be placed on the right side. All constants, literals, and function calls must be placed on the left side. If neither side is a variable, the order is unimportant. | ||
|
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.
Related #1722 |
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.
Hi Mika, apologies, I forgot to check for the <em>
tags in my previous review. The <em>
tags allow for highlighting of the specific issue within the code samples when using the MarkDown/HTML generators.
When you update the PR, would you mind rebasing it on the current HEAD of develop
? The move to the WP org has caused some issues with Travis reporting... (no surprise there)
<code_comparison> | ||
<code title="Valid: The variable $the_force is placed on the right"> | ||
<![CDATA[ | ||
if ( true === $the_force ) { |
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.
if ( true === $the_force ) { | |
if ( <em>true === the_force</em> ) { |
</code> | ||
<code title="Invalid: The variable $the_force has been placed on the left"> | ||
<![CDATA[ | ||
if ( $the_force === false ) { |
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.
if ( $the_force === false ) { | |
if ( <em>$the_force === false</em> ) { |
FYI: I've opened a PR in PHPCS upstream to fix the weird word wrapping which is happening with the multi-line |
FYI: upstream PR for the weird line breaks has been merged and will be included in PHPCS 3.5.0. |
I've rebased the PR and added one commit to make the last fixes needed. Let's get this merged! For whomever will merge this: probably squash/merge would be a good idea. |
A basic example of a proper (and improper) Yoda conditional, with links back to full documentation on why.