Skip to content

Commit 64a71d6

Browse files
nicolas-grekasfabpot
authored andcommitted
Bump minimum version of PHP to 8.1
1 parent 110b9fb commit 64a71d6

12 files changed

+19
-22
lines changed

Authenticator/AbstractPreAuthenticatedAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function supports(Request $request): ?bool
9292
public function authenticate(Request $request): Passport
9393
{
9494
return new SelfValidatingPassport(
95-
new UserBadge($request->attributes->get('_pre_authenticated_username'), [$this->userProvider, 'loadUserByIdentifier']),
95+
new UserBadge($request->attributes->get('_pre_authenticated_username'), $this->userProvider->loadUserByIdentifier(...)),
9696
[new PreAuthenticatedUserBadge()]
9797
);
9898
}

Authenticator/FormLoginAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function authenticate(Request $request): Passport
8383
$credentials = $this->getCredentials($request);
8484

8585
$passport = new Passport(
86-
new UserBadge($credentials['username'], [$this->userProvider, 'loadUserByIdentifier']),
86+
new UserBadge($credentials['username'], $this->userProvider->loadUserByIdentifier(...)),
8787
new PasswordCredentials($credentials['password']),
8888
[new RememberMeBadge()]
8989
);

Authenticator/HttpBasicAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function authenticate(Request $request): Passport
6464
$password = $request->headers->get('PHP_AUTH_PW', '');
6565

6666
$passport = new Passport(
67-
new UserBadge($username, [$this->userProvider, 'loadUserByIdentifier']),
67+
new UserBadge($username, $this->userProvider->loadUserByIdentifier(...)),
6868
new PasswordCredentials($password)
6969
);
7070
if ($this->userProvider instanceof PasswordUpgraderInterface) {

Authenticator/JsonLoginAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function authenticate(Request $request): Passport
8787
}
8888

8989
$passport = new Passport(
90-
new UserBadge($credentials['username'], [$this->userProvider, 'loadUserByIdentifier']),
90+
new UserBadge($credentials['username'], $this->userProvider->loadUserByIdentifier(...)),
9191
new PasswordCredentials($credentials['password'])
9292
);
9393
if ($this->userProvider instanceof PasswordUpgraderInterface) {

Authenticator/Passport/Credentials/CustomCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CustomCredentials implements CredentialsInterface
3434
*/
3535
public function __construct(callable $customCredentialsChecker, mixed $credentials)
3636
{
37-
$this->customCredentialsChecker = $customCredentialsChecker instanceof \Closure ? $customCredentialsChecker : \Closure::fromCallable($customCredentialsChecker);
37+
$this->customCredentialsChecker = $customCredentialsChecker(...);
3838
$this->credentials = $credentials;
3939
}
4040

EventListener/UserProviderListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ public function checkPassport(CheckPassportEvent $event): void
4545
return;
4646
}
4747

48-
$badge->setUserLoader([$this->userProvider, 'loadUserByIdentifier']);
48+
$badge->setUserLoader($this->userProvider->loadUserByIdentifier(...));
4949
}
5050
}

Firewall/ContextListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct(TokenStorageInterface $tokenStorage, iterable $userP
6868
$this->dispatcher = $dispatcher;
6969

7070
$this->trustResolver = $trustResolver ?? new AuthenticationTrustResolver();
71-
$this->sessionTrackerEnabler = null === $sessionTrackerEnabler || $sessionTrackerEnabler instanceof \Closure ? $sessionTrackerEnabler : \Closure::fromCallable($sessionTrackerEnabler);
71+
$this->sessionTrackerEnabler = null === $sessionTrackerEnabler ? null : $sessionTrackerEnabler(...);
7272
}
7373

7474
/**
@@ -85,7 +85,7 @@ public function supports(Request $request): ?bool
8585
public function authenticate(RequestEvent $event)
8686
{
8787
if (!$this->registered && null !== $this->dispatcher && $event->isMainRequest()) {
88-
$this->dispatcher->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
88+
$this->dispatcher->addListener(KernelEvents::RESPONSE, $this->onKernelResponse(...));
8989
$this->registered = true;
9090
}
9191

@@ -162,7 +162,7 @@ public function onKernelResponse(ResponseEvent $event)
162162
return;
163163
}
164164

165-
$this->dispatcher?->removeListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
165+
$this->dispatcher?->removeListener(KernelEvents::RESPONSE, $this->onKernelResponse(...));
166166
$this->registered = false;
167167
$session = $request->getSession();
168168
$sessionId = $session->getId();

Firewall/ExceptionListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationT
7575
*/
7676
public function register(EventDispatcherInterface $dispatcher)
7777
{
78-
$dispatcher->addListener(KernelEvents::EXCEPTION, [$this, 'onKernelException'], 1);
78+
$dispatcher->addListener(KernelEvents::EXCEPTION, $this->onKernelException(...), 1);
7979
}
8080

8181
/**
8282
* Unregisters the dispatcher.
8383
*/
8484
public function unregister(EventDispatcherInterface $dispatcher)
8585
{
86-
$dispatcher->removeListener(KernelEvents::EXCEPTION, [$this, 'onKernelException']);
86+
$dispatcher->removeListener(KernelEvents::EXCEPTION, $this->onKernelException(...));
8787
}
8888

8989
/**

Tests/EventListener/PasswordMigratingListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testUpgradeWithoutUpgrader()
9191
$event = $this->createEvent(new SelfValidatingPassport(new UserBadge('test', [$userLoader, 'loadUserByIdentifier']), [new PasswordUpgradeBadge('pa$$word')]));
9292
$this->listener->onLoginSuccess($event);
9393

94-
$event = $this->createEvent(new SelfValidatingPassport(new UserBadge('test', \Closure::fromCallable([$userLoader, 'loadUserByIdentifier'])), [new PasswordUpgradeBadge('pa$$word')]));
94+
$event = $this->createEvent(new SelfValidatingPassport(new UserBadge('test', $userLoader->loadUserByIdentifier(...)), [new PasswordUpgradeBadge('pa$$word')]));
9595
$this->listener->onLoginSuccess($event);
9696
}
9797

Tests/EventListener/UserProviderListenerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public function testSetUserProvider()
3737

3838
$this->listener->checkPassport(new CheckPassportEvent($this->createMock(AuthenticatorInterface::class), $passport));
3939

40-
$badge = $passport->getBadge(UserBadge::class);
41-
$this->assertEquals([$this->userProvider, 'loadUserByIdentifier'], $badge->getUserLoader());
42-
4340
$user = new InMemoryUser('wouter', null);
4441
$this->userProvider->createUser($user);
4542
$this->assertTrue($user->isEqualTo($passport->getUser()));

0 commit comments

Comments
 (0)