Skip to content
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

False positive Generic.ControlStructures.DisallowYodaConditions #2962

Closed
jrfnl opened this issue May 16, 2020 · 3 comments
Closed

False positive Generic.ControlStructures.DisallowYodaConditions #2962

jrfnl opened this issue May 16, 2020 · 3 comments

Comments

@jrfnl
Copy link
Contributor

jrfnl commented May 16, 2020

The Generic.ControlStructures.DisallowYodaConditions reports a Usage of Yoda conditions is not allowed; switch the expression order error for the below code, which IMO is incorrect (the error, not the code).

$var = ( (string) function_call( 'text' ) ) === '0';
@umherirrender
Copy link

Another one:

					return ( $group && $pos ) ?
						( $pos % $group ) === 0 && ( $pos < 0 === $group < 0 ) :
						!$pos;

It seems that a boolean condition with two < 0 is not handled correctly by the sniff.

Work around: Add () around each part of the condition

@jlherren
Copy link

jlherren commented Oct 1, 2021

I'm also experiencing this, here's a very short example:

$a = 1 * (1 + 1) !== 0;

@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#19

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants