Skip to content

Commit 7495f7b

Browse files
committed
Fix qa errors
1 parent 464ffb2 commit 7495f7b

5 files changed

Lines changed: 24 additions & 42 deletions

File tree

ci/qa/phpstan-baseline.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -607,18 +607,6 @@
607607
'count' => 1,
608608
'path' => __DIR__ . '/../../src/Surfnet/StepupRa/RaBundle/Exception/AssertionFailedException.php',
609609
];
610-
$ignoreErrors[] = [
611-
'message' => '#^Method Surfnet\\\\StepupRa\\\\RaBundle\\\\Exception\\\\AssertionFailedException\\:\\:getPropertyPath\\(\\) has no return type specified\\.$#',
612-
'identifier' => 'missingType.return',
613-
'count' => 1,
614-
'path' => __DIR__ . '/../../src/Surfnet/StepupRa/RaBundle/Exception/AssertionFailedException.php',
615-
];
616-
$ignoreErrors[] = [
617-
'message' => '#^Method Surfnet\\\\StepupRa\\\\RaBundle\\\\Exception\\\\AssertionFailedException\\:\\:getValue\\(\\) has no return type specified\\.$#',
618-
'identifier' => 'missingType.return',
619-
'count' => 1,
620-
'path' => __DIR__ . '/../../src/Surfnet/StepupRa/RaBundle/Exception/AssertionFailedException.php',
621-
];
622610
$ignoreErrors[] = [
623611
'message' => '#^Method Surfnet\\\\StepupRa\\\\RaBundle\\\\Form\\\\Extension\\\\RaRoleChoiceList\\:\\:buildChoices\\(\\) return type has no value type specified in iterable type array\\.$#',
624612
'identifier' => 'missingType.iterableValue',
@@ -679,12 +667,6 @@
679667
'count' => 1,
680668
'path' => __DIR__ . '/../../src/Surfnet/StepupRa/RaBundle/Security/AuthenticatedIdentity.php',
681669
];
682-
$ignoreErrors[] = [
683-
'message' => '#^Method Surfnet\\\\StepupRa\\\\RaBundle\\\\Security\\\\AuthenticatedIdentity\\:\\:eraseCredentials\\(\\) return type has no value type specified in iterable type array\\.$#',
684-
'identifier' => 'missingType.iterableValue',
685-
'count' => 1,
686-
'path' => __DIR__ . '/../../src/Surfnet/StepupRa/RaBundle/Security/AuthenticatedIdentity.php',
687-
];
688670
$ignoreErrors[] = [
689671
'message' => '#^Method Surfnet\\\\StepupRa\\\\RaBundle\\\\Security\\\\Authentication\\\\AuthenticatedSessionStateHandler\\:\\:setCurrentRequestUri\\(\\) has no return type specified\\.$#',
690672
'identifier' => 'missingType.return',

src/Surfnet/StepupRa/RaBundle/Logger/ProcedureAwareLogger.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace Surfnet\StepupRa\RaBundle\Logger;
2020

2121
use Psr\Log\LoggerInterface;
22+
use Stringable;
2223
use Surfnet\StepupRa\RaBundle\Exception\RuntimeException;
2324

2425
/**
@@ -40,47 +41,47 @@ public function forProcedure(string $procedure): ProcedureAwareLogger
4041
return $logger;
4142
}
4243

43-
public function emergency($message, array $context = []): void
44+
public function emergency(string|Stringable $message, array $context = []): void
4445
{
4546
$this->logger->emergency($message, $this->enrichContext($context));
4647
}
4748

48-
public function alert($message, array $context = []): void
49+
public function alert(string|Stringable $message, array $context = []): void
4950
{
5051
$this->logger->alert($message, $this->enrichContext($context));
5152
}
5253

53-
public function critical($message, array $context = []): void
54+
public function critical(string|Stringable $message, array $context = []): void
5455
{
5556
$this->logger->critical($message, $this->enrichContext($context));
5657
}
5758

58-
public function error($message, array $context = []): void
59+
public function error(string|Stringable $message, array $context = []): void
5960
{
6061
$this->logger->error($message, $this->enrichContext($context));
6162
}
6263

63-
public function warning($message, array $context = []): void
64+
public function warning(string|Stringable $message, array $context = []): void
6465
{
6566
$this->logger->warning($message, $this->enrichContext($context));
6667
}
6768

68-
public function notice($message, array $context = []): void
69+
public function notice(string|Stringable $message, array $context = []): void
6970
{
7071
$this->logger->notice($message, $this->enrichContext($context));
7172
}
7273

73-
public function info($message, array $context = []): void
74+
public function info(string|Stringable $message, array $context = []): void
7475
{
7576
$this->logger->info($message, $this->enrichContext($context));
7677
}
7778

78-
public function debug($message, array $context = []): void
79+
public function debug(string|Stringable $message, array $context = []): void
7980
{
8081
$this->logger->debug($message, $this->enrichContext($context));
8182
}
8283

83-
public function log($level, $message, array $context = []): void
84+
public function log($level, string|Stringable $message, array $context = []): void
8485
{
8586
$this->logger->log($level, $message, $this->enrichContext($context));
8687
}

src/Surfnet/StepupRa/RaBundle/Security/AuthenticatedIdentity.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
namespace Surfnet\StepupRa\RaBundle\Security;
2222

23+
use LogicException;
2324
use Surfnet\StepupBundle\Value\Loa;
2425
use Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity;
2526
use Symfony\Component\Security\Core\User\UserInterface;
@@ -95,9 +96,8 @@ public function getSalt(): ?string
9596
/**
9697
* @inheritDoc
9798
*/
98-
public function eraseCredentials(): array
99+
public function eraseCredentials(): void
99100
{
100-
return [];
101101
}
102102

103103
/**
@@ -111,6 +111,12 @@ public function getOriginalIdentity(): Identity
111111
public function getUserIdentifier(): string
112112
{
113113
$parts = explode(':', $this->originalIdentity->nameId);
114-
return end($parts);
114+
$identifier = end($parts);
115+
116+
if ($identifier === false || $identifier === '') {
117+
throw new LogicException('Cannot determine user identifier from nameId');
118+
}
119+
120+
return $identifier;
115121
}
116122
}

src/Surfnet/StepupRa/RaBundle/Security/Authentication/Handler/FailureHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
4949
$exception->getMessageKey(),
5050
$exception->getMessage(),
5151
);
52-
$this->logger->notice($message);
52+
$this->logger?->notice($message);
5353
// The exception controller is used to show the failed authentication
5454
return $this->exceptionController->show($request, $exception);
5555
}

src/Surfnet/StepupRa/RaBundle/Twig/Extensions/Extension/SecondFactorType.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
namespace Surfnet\StepupRa\RaBundle\Twig\Extensions\Extension;
2020

2121
use Surfnet\StepupBundle\Service\SecondFactorTypeTranslationService;
22-
use Twig\Extension\AbstractExtension;
23-
use Twig\TwigFilter;
22+
use Twig\Attribute\AsTwigFilter;
2423

25-
final class SecondFactorType extends AbstractExtension
24+
final readonly class SecondFactorType
2625
{
2726
public function __construct(
28-
private readonly SecondFactorTypeTranslationService $translator,
27+
private SecondFactorTypeTranslationService $translator,
2928
) {
3029
}
3130

@@ -34,13 +33,7 @@ public function getName(): string
3433
return 'ra.twig.second_factor_type';
3534
}
3635

37-
public function getFilters(): array
38-
{
39-
return [
40-
new TwigFilter('trans_second_factor_type', $this->translateSecondFactorType(...)),
41-
];
42-
}
43-
36+
#[AsTwigFilter(name: 'trans_second_factor_type')]
4437
public function translateSecondFactorType($secondFactorType): string
4538
{
4639
return $this->translator->translate($secondFactorType, 'ra.second_factor.search.type.%s');

0 commit comments

Comments
 (0)