Skip to content

Files

Latest commit

 

History

History
19 lines (10 loc) · 845 Bytes

SlevomatCodingStandard.ControlStructures.DisallowYodaComparison.md

File metadata and controls

19 lines (10 loc) · 845 Bytes

Pattern: Use of Yoda comparison

Issue: -

Description

Yoda conditions decrease code comprehensibility and readability by switching operands around comparison operators forcing the reader to read the code in an unnatural way.

Rule provides the following settings:

  • alwaysVariableOnRight (defaults to false): moves variables always to right.

DisallowYodaComparison looks for and fixes such comparisons not only in if statements but in the whole code.

However, if you prefer Yoda conditions, you can use RequireYodaComparison.

Further Reading