Skip to content
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

Merged
merged 4 commits into from
May 16, 2022
Merged

Document YodaConditionals you must #1724

merged 4 commits into from
May 16, 2022

Conversation

Ipstenu
Copy link
Contributor

@Ipstenu Ipstenu commented Jun 20, 2019

A basic example of a proper (and improper) Yoda conditional, with links back to full documentation on why.

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! First PR!

WordPress/Docs/PHP/YodaConditionsStandard.xml Outdated Show resolved Hide resolved
WordPress/Docs/PHP/YodaConditionsStandard.xml Outdated Show resolved Hide resolved
WordPress/Docs/PHP/YodaConditionsStandard.xml Outdated Show resolved Hide resolved
<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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still seems to be whitespace present here.

Screenshot 2019-06-20 at 13 30 09

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thank you.

Copy link
Member

@GaryJones GaryJones left a 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 :-)

WordPress/Docs/PHP/YodaConditionsStandard.xml Outdated Show resolved Hide resolved
<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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still seems to be whitespace present here.

Screenshot 2019-06-20 at 13 30 09

@jrfnl
Copy link
Member

jrfnl commented Jun 20, 2019

Related #1722

Copy link
Member

@jrfnl jrfnl left a 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 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( $the_force === false ) {
if ( <em>$the_force === false</em> ) {

@jrfnl
Copy link
Member

jrfnl commented Jun 27, 2019

FYI: I've opened a PR in PHPCS upstream to fix the weird word wrapping which is happening with the multi-line standard block: squizlabs/PHP_CodeSniffer#2541

@jrfnl jrfnl removed this from the 2.x Next milestone Jul 10, 2019
@jrfnl
Copy link
Member

jrfnl commented Sep 20, 2019

FYI: upstream PR for the weird line breaks has been merged and will be included in PHPCS 3.5.0.

@jrfnl
Copy link
Member

jrfnl commented May 16, 2022

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.

@jrfnl jrfnl added this to the 3.0.0 milestone May 16, 2022
@dingo-d dingo-d merged commit 222251d into WordPress:develop May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants