Skip to content

Files

Latest commit

 

History

History
19 lines (10 loc) · 851 Bytes

SlevomatCodingStandard.ControlStructures.RequireYodaComparison.md

File metadata and controls

19 lines (10 loc) · 851 Bytes

Pattern: Missing 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