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

Docs/WordPress.WhiteSpace.OperatorSpacing #1727

Merged
merged 17 commits into from
May 17, 2022
Merged
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
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>