Skip to content

Commit

Permalink
Merge branch 'php8Optimisations' of https://github.com/nextcloud/twof…
Browse files Browse the repository at this point in the history
…actor_totp into php8Optimisations
  • Loading branch information
solracsf committed Jan 24, 2025
2 parents ee91271 + 7227a48 commit ddbc73d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
* @return JSONResponse
*/
public function state(): JSONResponse {
$user = $this->userSession->getUser();
$user = $this->userSession?->getUser();

Check failure on line 39 in lib/Controller/SettingsController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TypeDoesNotContainNull

lib/Controller/SettingsController.php:39:11: TypeDoesNotContainNull: OCP\IUserSession does not contain null (see https://psalm.dev/090)

Check failure on line 39 in lib/Controller/SettingsController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCondition

lib/Controller/SettingsController.php:39:11: RedundantCondition: Type OCP\IUserSession for $__tmp_nullsafe__847 is never null (see https://psalm.dev/122)
if (is_null($user)) {
throw new \Exception('user not available');
}
Expand All @@ -53,7 +53,7 @@ public function state(): JSONResponse {
* @param string|null $code for verification
*/
public function enable(int $state, ?string $code = null): JSONResponse {
$user = $this->userSession->getUser();
$user = $this->userSession?->getUser();

Check failure on line 56 in lib/Controller/SettingsController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TypeDoesNotContainNull

lib/Controller/SettingsController.php:56:11: TypeDoesNotContainNull: OCP\IUserSession does not contain null (see https://psalm.dev/090)

Check failure on line 56 in lib/Controller/SettingsController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCondition

lib/Controller/SettingsController.php:56:11: RedundantCondition: Type OCP\IUserSession for $__tmp_nullsafe__1305 is never null (see https://psalm.dev/122)
if (is_null($user)) {
throw new \Exception('user not available');
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public function enable(int $state, ?string $code = null): JSONResponse {
*/
private function getSecretName(): string {
$productName = $this->defaults->getName();
$user = $this->userSession->getUser();
$user = $this->userSession?->getUser();

Check failure on line 97 in lib/Controller/SettingsController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TypeDoesNotContainNull

lib/Controller/SettingsController.php:97:11: TypeDoesNotContainNull: OCP\IUserSession does not contain null (see https://psalm.dev/090)

Check failure on line 97 in lib/Controller/SettingsController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCondition

lib/Controller/SettingsController.php:97:11: RedundantCondition: Type OCP\IUserSession for $__tmp_nullsafe__2503 is never null (see https://psalm.dev/122)
if ($user === null) {
throw new RuntimeException('No user in this context');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Listener/UserDeleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function __construct(
public function handle(Event $event): void {
if ($event instanceof UserDeletedEvent) {
try {
$this->totpSecretMapper->deleteSecretByUserId($event->getUser()->getUID());
$this->totpSecretMapper->deleteSecretByUserId($event->getUser()?->getUID());

Check failure on line 33 in lib/Listener/UserDeleted.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TypeDoesNotContainNull

lib/Listener/UserDeleted.php:33:51: TypeDoesNotContainNull: OCP\IUser does not contain null (see https://psalm.dev/090)

Check failure on line 33 in lib/Listener/UserDeleted.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

RedundantCondition

lib/Listener/UserDeleted.php:33:51: RedundantCondition: Type OCP\IUser for $__tmp_nullsafe__785 is never null (see https://psalm.dev/122)

Check failure on line 33 in lib/Listener/UserDeleted.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

PossiblyNullArgument

lib/Listener/UserDeleted.php:33:51: PossiblyNullArgument: Argument 1 of OCA\TwoFactorTOTP\Db\TotpSecretMapper::deleteSecretByUserId cannot be null, possibly null value provided (see https://psalm.dev/078)
} catch (Exception $e) {
$this->logger->warning($e->getMessage(), ['uid' => $event->getUser()->getUID()]);
$this->logger->warning($e->getMessage(), ['uid' => $event->getUser()?->getUID()]);
}
}
}
Expand Down

0 comments on commit ddbc73d

Please sign in to comment.