Skip to content

Commit

Permalink
Merge pull request #458 from rodrigoprimo/disallow-yoda-condition-dro…
Browse files Browse the repository at this point in the history
…p-null-coalescing-operator

Generic/DisallowYodaConditions: `??` should not trigger the sniff
  • Loading branch information
jrfnl authored Apr 22, 2024
2 parents 8d2363d + e4d3743 commit 5f38ce0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class DisallowYodaConditionsSniff implements Sniff
*/
public function register()
{
return Tokens::$comparisonTokens;
$tokens = Tokens::$comparisonTokens;
unset($tokens[T_COALESCE]);

return $tokens;

}//end register()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,5 @@ echo match ($text) {
'foo' => 10 === $y,
10 === $y => 'bar',
};

1 ?? $nullCoalescingShouldNotTriggerSniff;

0 comments on commit 5f38ce0

Please sign in to comment.