Skip to content

Commit 25395ea

Browse files
committed
Fix some issues detected by PHPStan
1 parent 4c23f4e commit 25395ea

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

phpstan.dist.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 2
2+
level: 5
33
paths:
44
- bin/
55
- config/

src/Controller/Ajax/User/Security/GoogleAuthenticatorController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use App\Controller\Ajax\AjaxController;
88
use App\Entity\User;
99
use App\Service\User\GoogleAuthenticatorService;
10-
use Scheb\TwoFactorBundle\Model\Google\TwoFactorInterface;
1110
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1211
use Symfony\Component\HttpFoundation\JsonResponse;
1312
use Symfony\Component\HttpFoundation\Request;
@@ -26,7 +25,7 @@ public function __construct(private readonly GoogleAuthenticatorService $service
2625
public function getAuthCode(): JsonResponse
2726
{
2827
try {
29-
/** @var User|TwoFactorInterface $user */
28+
/** @var User $user */
3029
$user = $this->getUser();
3130

3231
return new JsonResponse($this->service->generateSecret($user));

src/Controller/Auth/ResetPasswordController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function passwordReset(ResettingService $service, Request $request): Resp
3737
#[Route(path: '/password/reset/{token}', name: 'password_reset_confirm', methods: ['GET|POST'])]
3838
public function passwordResetConfirm(ResettingRepository $repository, Request $request, string $token): Response
3939
{
40-
/** @var User $user */
40+
/** @var ?User $user */
4141
$user = $repository->findOneBy(['confirmation_token' => $token]);
4242

4343
if (!$user) {

src/Service/AbstractService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ abstract class AbstractService
1818

1919
public function __construct(private readonly CsrfTokenManagerInterface $tokenManager, RequestStack $requestStack)
2020
{
21-
$this->session = $requestStack->getSession();
21+
$session = $requestStack->getSession();
22+
23+
if (!$session instanceof FlashBagAwareSessionInterface) {
24+
throw new \LogicException('Session must implement FlashBagAwareSessionInterface.');
25+
}
26+
$this->session = $session;
2227
}
2328

2429
/**

src/Service/Admin/PageService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function create(Page $page): void
3232
if (true === $page->getShowInMenu()) {
3333
$menu = new Menu();
3434
$menu->setTitle($page->getTitle() ?? '');
35-
$menu->setLocale($page->getLocale() ?? '');
35+
$menu->setLocale($page->getLocale());
3636
$menu->setUrl('/info/'.($page->getSlug() ?? ''));
3737
$this->save($menu);
3838
}

src/Validator/ConfirmPasswordValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
final class ConfirmPasswordValidator extends ConstraintValidator
1111
{
1212
/** @param ConfirmPassword $constraint */
13-
public function validate($value, Constraint $constraint): void
13+
public function validate(mixed $value, Constraint $constraint): void
1414
{
1515
if (null === $value || '' === $value) {
1616
return;

src/Validator/RegisteredUserValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(private readonly UserRepository $userRepository)
1616
}
1717

1818
/** @param RegisteredUser $constraint */
19-
public function validate($value, Constraint $constraint): void
19+
public function validate(mixed $value, Constraint $constraint): void
2020
{
2121
if (null === $value || '' === $value) {
2222
return;

0 commit comments

Comments
 (0)