-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
refactor: Use the elvis operator + fix: Handle null checks with the ?? operator #48042
Conversation
Signed-off-by: Christoph Wurst <[email protected]>
@@ -646,8 +646,7 @@ | |||
try { | |||
$accountProperty = $account->getProperty($property); | |||
$currentValue = $accountProperty->getValue(); | |||
$scope = ($accountProperty->getScope() ? $accountProperty->getScope() | |||
: $defaultScopes[$property]); | |||
$scope = ($accountProperty->getScope() ?: $defaultScopes[$property]); |
Check notice
Code scanning / Psalm
RedundantConditionGivenDocblockType Note
@@ -121,7 +121,7 @@ | |||
$this->config->setUserValue($this->userId, Application::APP_ID, 'lon', strval($lon)); | |||
// resolve and store formatted address | |||
$address = $this->resolveLocation($lat, $lon); | |||
$address = $address ? $address : $this->l10n->t('Unknown address'); | |||
$address = $address ?: $this->l10n->t('Unknown address'); |
Check notice
Code scanning / Psalm
RiskyTruthyFalsyComparison Note
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.
🧹
lib/private/Log/LogDetails.php
Outdated
@@ -37,7 +37,7 @@ public function logDetails(string $app, $message, int $level): array { | |||
$url = ($request->getRequestUri() !== '') ? $request->getRequestUri() : '--'; | |||
$method = is_string($request->getMethod()) ? $request->getMethod() : '--'; | |||
if ($this->config->getValue('installed', false)) { | |||
$user = \OC_User::getUser() ? \OC_User::getUser() : '--'; | |||
$user = \OC_User::getUser() ?: '--'; |
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.
Uid "0" would also evaluate to '--'
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.
Yes, same as with the ternary operator
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.
Fixed :)
Signed-off-by: Christoph Wurst <[email protected]>
Summary
Makes code easier to read.
TODO
Checklist