-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: documentation for AssignmentInTernaryCondition sniff
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
WordPress/Docs/CodeAnalysis/AssignmentInTernaryConditionStandard.xml
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,19 @@ | ||
<documentation title="Assignment In Ternary Condition"> | ||
<standard> | ||
<![CDATA[ | ||
Checks that variable assignment does not occur in conditional statement of ternary. Condition must be in parentheses to be checked; Ternaries lacking parentheses around condition are skipped. If incorrect will throw: "Variable assignment found within a condition. Did you mean to do a comparison?" | ||
]]> | ||
</standard> | ||
<code_comparison> | ||
<code title="Valid: Variable assigned with comparison in parentheses."> | ||
<![CDATA[ | ||
echo $mode = ( <em>$a == 'a'</em> ) ? 'b' : 'c'; | ||
]]> | ||
</code> | ||
<code title="Invalid: Parentheses used but variable assignment instead of comparison."> | ||
<![CDATA[ | ||
echo $mode = ( <em>$a = 'a'</em> ) ? 'b' : 'c'; | ||
]]> | ||
</code> | ||
</code_comparison> | ||
</documentation> |