Skip to content

Commit

Permalink
Apply changes due to new Psalm rules
Browse files Browse the repository at this point in the history
  • Loading branch information
scheb committed Jan 18, 2024
1 parent 1b74ad2 commit aceb55b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function createAuthenticationRequiredHandler(ContainerBuilder $container,
*/
public function getCsrfTokenManagerId(array $config): string
{
/** @psalm-suppress RiskyTruthyFalsyComparison */
return $config['enable_csrf'] ?? false
? 'scheb_two_factor.csrf_token_manager'
: 'scheb_two_factor.null_csrf_token_manager';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function checkPassport(CheckPassportEvent $event): void
assert($credentialsBadge instanceof TwoFactorCodeCredentials);
$token = $credentialsBadge->getTwoFactorToken();
$providerName = $token->getCurrentTwoFactorProvider();
if (!$providerName) {
if (null === $providerName || !$providerName) {
throw new AuthenticationException('There is no active two-factor provider.');
}

Expand Down
2 changes: 1 addition & 1 deletion src/email/Mailer/SymfonyAuthCodeMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
) {
if (null !== $senderEmail && null !== $senderName) {
$this->senderAddress = new Address($senderEmail, $senderName);
} elseif ($senderEmail) {
} elseif (null !== $senderEmail && $senderEmail) {
$this->senderAddress = $senderEmail;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function createTotpForUser(TwoFactorInterface $user): TOTPInterface
/** @psalm-suppress ArgumentTypeCoercion */
$totp = TOTP::create($secret, 30, 'sha1', $this->digits);

$userAndHost = $user->getGoogleAuthenticatorUsername().($this->server ? '@'.$this->server : '');
$userAndHost = $user->getGoogleAuthenticatorUsername().(null !== $this->server && $this->server ? '@'.$this->server : '');
$totp->setLabel($userAndHost);

if ($this->issuer) {
if (null !== $this->issuer && $this->issuer) {
$totp->setIssuer($this->issuer);
}

Expand Down
4 changes: 2 additions & 2 deletions src/totp/Security/TwoFactor/Provider/Totp/TotpFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public function createTotpForUser(TwoFactorInterface $user): TOTPInterface
$totpConfiguration->getDigits(),
);

$userAndHost = $user->getTotpAuthenticationUsername().($this->server ? '@'.$this->server : '');
$userAndHost = $user->getTotpAuthenticationUsername().(null !== $this->server && $this->server ? '@'.$this->server : '');
$totp->setLabel($userAndHost);

if ($this->issuer) {
if (null !== $this->issuer && $this->issuer) {
$totp->setIssuer($this->issuer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function getTrustedTokenList(): array
private function readTrustedTokenList(): array
{
$cookie = $this->readCookieValue();
if (!$cookie) {
if (null === $cookie || !$cookie) {
return [];
}

Expand Down

0 comments on commit aceb55b

Please sign in to comment.