-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
Use null coalescing operator #2543
Conversation
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.
LGTM, great effort!
did you do this manually? |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
PHPstorm shows possible usage of null coalescing operator ... i've run inspection for only that and changed that half-automated. (Y, i've checked every change) |
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.
i've no way of testing all this so i'll just trust the process :-)
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
This comment has been minimized.
This comment has been minimized.
$this->setAggregator($arr['aggregator'] ?? ($arr['attribute'] ?? null)) | ||
->setValue($arr['value'] ?? ($arr['operator'] ?? null)); | ||
$this->setAggregator($arr['aggregator'] ?? $arr['attribute'] ?? null) | ||
->setValue($arr['value'] ?? $arr['operator'] ?? null); |
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.
IMHO this is hard to understard, extremely short code is already less easy on the brain, but this (to me) it's a no. with the parenthesis was a bit better
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.
imho ... for me its easier to read w/o parenthesis. I can revert it later if you think it was better before.
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.
Ref https://www.php.net/manual/en/migration70.new-features.php, the operator can be chained. With parenthesis, it defeats the feature.
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.
Chaining seems to me a good argument against the additional parentheses.
Description (*)
There were a few comments in PRs to use null coalescing operator ... here we go.
Contribution checklist (*)