Skip to content

Commit

Permalink
Add: documentation for AssignmentInTernaryCondition sniff
Browse files Browse the repository at this point in the history
  • Loading branch information
Nic-Sevic committed Sep 17, 2024
1 parent 7f76630 commit f7975dc
Showing 1 changed file with 19 additions and 0 deletions.
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>

0 comments on commit f7975dc

Please sign in to comment.