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()));

Tests/Firewall/ContextListenerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function testHandleAddsKernelResponseListener()
175175

176176
$dispatcher->expects($this->once())
177177
->method('addListener')
178-
->with(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
178+
->with(KernelEvents::RESPONSE, $listener->onKernelResponse(...));
179179

180180
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MAIN_REQUEST));
181181
}
@@ -197,7 +197,7 @@ public function testOnKernelResponseListenerRemovesItself()
197197

198198
$dispatcher->expects($this->once())
199199
->method('removeListener')
200-
->with(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
200+
->with(KernelEvents::RESPONSE, $listener->onKernelResponse(...));
201201

202202
$listener->onKernelResponse($event);
203203
}
@@ -299,7 +299,7 @@ public function testWithPreviousNotStartedSession()
299299
$usageIndex = $session->getUsageIndex();
300300

301301
$tokenStorage = new TokenStorage();
302-
$listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, [$tokenStorage, 'getToken']);
302+
$listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, $tokenStorage->getToken(...));
303303
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST));
304304

305305
$this->assertSame($usageIndex, $session->getUsageIndex());
@@ -318,7 +318,7 @@ public function testSessionIsNotReported()
318318

319319
$tokenStorage = new TokenStorage();
320320

321-
$listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, [$tokenStorage, 'getToken']);
321+
$listener = new ContextListener($tokenStorage, [], 'context_key', null, null, null, $tokenStorage->getToken(...));
322322
$listener(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST));
323323
}
324324

@@ -354,7 +354,7 @@ protected function runSessionOnKernelResponse($newToken, $original = null)
354354
new Response()
355355
);
356356

357-
$listener = new ContextListener($tokenStorage, [], 'session', null, new EventDispatcher(), null, [$tokenStorage, 'enableUsageTracking']);
357+
$listener = new ContextListener($tokenStorage, [], 'session', null, new EventDispatcher(), null, $tokenStorage->enableUsageTracking(...));
358358
$listener->onKernelResponse($event);
359359

360360
if ($session->getId() === $sessionId) {
@@ -385,7 +385,7 @@ private function handleEventWithPreviousSession($userProviders, UserInterface $u
385385
$tokenStorage = new UsageTrackingTokenStorage($tokenStorage, new class($factories) implements ContainerInterface {
386386
use ServiceLocatorTrait;
387387
});
388-
$sessionTrackerEnabler = [$tokenStorage, 'enableUsageTracking'];
388+
$sessionTrackerEnabler = $tokenStorage->enableUsageTracking(...);
389389

390390
$listener = new ContextListener($tokenStorage, $userProviders, 'context_key', null, null, null, $sessionTrackerEnabler);
391391

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=8.0.2",
19+
"php": ">=8.1",
2020
"symfony/security-core": "^5.4|^6.0",
2121
"symfony/http-foundation": "^5.4|^6.0",
2222
"symfony/http-kernel": "^5.4|^6.0",

0 commit comments

Comments
 (0)