-
Notifications
You must be signed in to change notification settings - Fork 54
Add operand in ternary operators rule #39
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
Add operand in ternary operators rule #39
Conversation
|
@dmitrydymarchuk This is already handled by https://github.com/slevomat/coding-standard#slevomatcodingstandardcontrolstructuresdisallowshortternaryoperator-. Also, using the short ternary operator |
15aa3fa to
0edc460
Compare
|
@carusogabriel PHPStan can be used without PHP CodeSniffer. I think phpstan-strict-rules should return error for shorthand operator in this case. |
ondrejmirtes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I agree with this part If and else parts of ternary operator are equal (%s). but not with Ternary operator is not needed.. PHPStan isn't a codestyle tool so this requirement is too opinionated.
ecb1ffa to
cf13bd7
Compare
cf13bd7 to
198546b
Compare
This part was removed |
|
Thank you! |
|
Hi, unfortunately I had to revert this rule (03807e3). It finds false positives in cases like: function (\stdClass $a, \stdClass $b): void {
rand(0, 1) ? [$a] : [$b];
};Unfortunately |
Find unnecessary ternary operators, when if and else part are equal or if and else part could be replaced by condition casted to bool.