Skip to content

Commit

Permalink
Docs/WordPress.WhiteSpace.OperatorSpacing (#1727)
Browse files Browse the repository at this point in the history
* Create OperatorSpacingStandard.xml

Co-Authored-By: Juliette <[email protected]>
  • Loading branch information
ckanitz and jrfnl authored May 17, 2022
1 parent 222251d commit 7d8c9fe
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions WordPress/Docs/WhiteSpace/OperatorSpacingStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<documentation title="Operator Spacing">
<standard>
<![CDATA[
Always put one space on both sides of logical, comparison and concatenation operators.
Always put one space after an assignment operator.
]]>
</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 ) {}
]]>
</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 little space.
if ( $a<em>===</em>$b<em> &&</em>$b<em> ===</em>$c ) {}
if (<em> !</em>$var ) {}
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: a new line instead of a space is okay too.">
<![CDATA[
if ( $a === $b<em>
&& </em>$b === $c
) {}
]]>
</code>
<code title="Invalid: too much space after operator on new line.">
<![CDATA[
if ( $a === $b<em>
&& </em>$b === $c
) {}
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: one space after assignment operator.">
<![CDATA[
$a <em>= </em>'foo';
$all <em>= </em>'foobar';
]]>
</code>
<code title="Invalid: too much/little space after assignment operator.">
<![CDATA[
$a <em>= </em>'foo';
$all <em>=</em>'foobar';
]]>
</code>
</code_comparison>
</documentation>

0 comments on commit 7d8c9fe

Please sign in to comment.