From 6e7c3835efe22d8545a8e7e096665ac542197c93 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Jul 2021 20:11:21 +0200 Subject: [PATCH] Simplify some code with null coalesce operator --- Firewall/RememberMeListener.php | 2 +- Tests/Firewall/ExceptionListenerTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Firewall/RememberMeListener.php b/Firewall/RememberMeListener.php index 441f70cc..d2df4a2b 100644 --- a/Firewall/RememberMeListener.php +++ b/Firewall/RememberMeListener.php @@ -58,7 +58,7 @@ public function __construct(TokenStorageInterface $tokenStorage, RememberMeServi } $this->catchExceptions = $catchExceptions; - $this->sessionStrategy = null === $sessionStrategy ? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE) : $sessionStrategy; + $this->sessionStrategy = $sessionStrategy ?? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE); } /** diff --git a/Tests/Firewall/ExceptionListenerTest.php b/Tests/Firewall/ExceptionListenerTest.php index 46c48b66..27ad9897 100644 --- a/Tests/Firewall/ExceptionListenerTest.php +++ b/Tests/Firewall/ExceptionListenerTest.php @@ -99,7 +99,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle $listener->onKernelException($event); $this->assertNull($event->getResponse()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } /** @@ -122,7 +122,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle $this->assertEquals('Unauthorized', $event->getResponse()->getContent()); $this->assertEquals(401, $event->getResponse()->getStatusCode()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } /** @@ -139,7 +139,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn $listener->onKernelException($event); $this->assertEquals('error', $event->getResponse()->getContent()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } /** @@ -156,7 +156,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \ $listener->onKernelException($event); $this->assertEquals('OK', $event->getResponse()->getContent()); - $this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious()); + $this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious()); } public function testLogoutException()