Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions WordPress/Docs/WhiteSpace/OperatorSpacingStandard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,33 @@
<![CDATA[
Always put one space on both sides of logical, comparison and concatenation operators.
Always put one space after an assignment operator.
Most of these can be auto-fixed by PHP_CodeSniffer.
]]>
</standard>



<code_comparison>
<code title="Valid: One space before and after an operator.">
<![CDATA[
if ( $a<em> === </em>$b<em> && </em>$b<em> === </em>$c ) {}
if (<em> ! </em>$var ) {}
if ( $a === $b && $b === $c ) {}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You shouldn't remove emphasis on errors. They serve a purpose (when you use HTML generator type you will see these bolded).

A lot of these fixes aren't valid...

if ( ! $var ) {}
]]>
</code>


<code title="Invalid: Too much/little space.">
<![CDATA[
// Too much space.
if ( $a === $b<em> && </em>$b<em> === </em>$c ) {}
if (<em> ! </em>$var ) {}
// Too much space.
if ( $a === $b && $b === $c ) {}
if ( ! $var ) {}

// Too little space.
if ( $a<em>===</em>$b<em> &&</em>$b<em> ===</em>$c ) {}
if (<em> !</em>$var ) {}
// Too little space.
if ( $a=== $b &&$b ===$c ) {}
if ( ! $var ) {}
]]>
</code>

</code_comparison>
<code_comparison>
<code title="Valid: A new line instead of a space is okay too.">
Expand Down Expand Up @@ -58,4 +65,6 @@ $all <em>=</em>'foobar';
]]>
</code>
</code_comparison>


</documentation>
Loading