-
-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs/WordPress.WhiteSpace.OperatorSpacing (#1727)
* Create OperatorSpacingStandard.xml Co-Authored-By: Juliette <[email protected]>
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |