Skip to content

Commit a6859b8

Browse files
Use ??= more
1 parent 7eddb8f commit a6859b8

File tree

6 files changed

+6
-19
lines changed

6 files changed

+6
-19
lines changed

Firewall/AccessListener.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ public function authenticate(RequestEvent $event)
7979
return;
8080
}
8181

82-
$token = $this->tokenStorage->getToken();
83-
if (null === $token) {
84-
$token = new NullToken();
85-
}
82+
$token = $this->tokenStorage->getToken() ?? new NullToken();
8683

8784
if (!$this->accessDecisionManager->decide($token, $attributes, $request, true)) {
8885
throw $this->createAccessDeniedException($request, $attributes);

HttpUtils.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ public function createRequest(Request $request, string $path): Request
7474

7575
static $setSession;
7676

77-
if (null === $setSession) {
78-
$setSession = \Closure::bind(static function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class);
79-
}
77+
$setSession ??= \Closure::bind(static function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class);
8078
$setSession($newRequest, $request);
8179

8280
if ($request->attributes->has(SecurityRequestAttributes::AUTHENTICATION_ERROR)) {

Impersonate/ImpersonateUrlGenerator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ private function buildExitPath(string $targetUri = null): string
6565
throw new \LogicException('Unable to generate the impersonate exit URL without a firewall configured for the user switch.');
6666
}
6767

68-
if (null === $targetUri) {
69-
$targetUri = $request->getRequestUri();
70-
}
68+
$targetUri ??= $request->getRequestUri();
7169

7270
$targetUri .= (parse_url($targetUri, \PHP_URL_QUERY) ? '&' : '?').http_build_query([$switchUserConfig['parameter'] => SwitchUserListener::EXIT_VALUE], '', '&');
7371

Tests/EventListener/RememberMeListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ public function testCredentialsInvalid()
6666

6767
private function createLoginSuccessfulEvent(Passport $passport = null)
6868
{
69-
if (null === $passport) {
70-
$passport = $this->createPassport();
71-
}
69+
$passport ??= $this->createPassport();
7270

7371
return new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class), $passport, $this->createMock(TokenInterface::class), $this->request, $this->response, 'main_firewall');
7472
}

Tests/EventListener/UserCheckerListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public function testPostAuthValidCredentials()
5959

6060
private function createCheckPassportEvent($passport = null)
6161
{
62-
if (null === $passport) {
63-
$passport = new SelfValidatingPassport(new UserBadge('test', function () { return $this->user; }));
64-
}
62+
$passport ??= new SelfValidatingPassport(new UserBadge('test', function () { return $this->user; }));
6563

6664
return new CheckPassportEvent($this->createMock(AuthenticatorInterface::class), $passport);
6765
}

Tests/Firewall/ExceptionListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ private function createTrustResolver($fullFledged)
221221

222222
private function createEvent(\Exception $exception, $kernel = null)
223223
{
224-
if (null === $kernel) {
225-
$kernel = $this->createMock(HttpKernelInterface::class);
226-
}
224+
$kernel ??= $this->createMock(HttpKernelInterface::class);
227225

228226
return new ExceptionEvent($kernel, Request::create('/'), HttpKernelInterface::MAIN_REQUEST, $exception);
229227
}

0 commit comments

Comments
 (0)