-
Notifications
You must be signed in to change notification settings - Fork 160
[New Rule] Use Yoda Conditions #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Even though I personally favor yoda style comparison, I think a rule for this would be too restrictive. |
I agree with @Vinai here. It is more about personal preferences not about the code style. I do understand you intention, but we don't want to enforce developers to use yoda conditions and limit somehow their personal preferences. Sorry, going to close this PR. |
* Fix DirectThrowSniff false positive * fix custom exception gives false positive with DirectThrowSniff * fix coding standard * Apply suggestions from code review Co-authored-by: Sergio Vera <[email protected]> * Fix error Co-authored-by: MeenakshiSundaram <[email protected]> Co-authored-by: Sergio Vera <[email protected]>
Rule
Use Yoda Conditions to avoid assignments inside a condition statement.
Reason
With Yoda Conditions it is not possible to assign a variable inside a condition statement, which improves the code quality because it prevents possible assignment errors.
Implementation
Some other Frameworks, such as Symfony, are using Yoda Conditions and have checks for them.
The text was updated successfully, but these errors were encountered: