Skip to content

Commit b0eb9ba

Browse files
committed
minor #42165 Simplify some code with null coalesce operator (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Simplify some code with null coalesce operator | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - For your consideration. There are many other possible usages of null coalesce operator, but the result is not very readable ... so this PR only contains the changes where the result is clearly better. Commits ------- 17ad5b75fa Simplify some code with null coalesce operator
2 parents ea56ad0 + 6e7c383 commit b0eb9ba

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Firewall/RememberMeListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(TokenStorageInterface $tokenStorage, RememberMeServi
5858
}
5959

6060
$this->catchExceptions = $catchExceptions;
61-
$this->sessionStrategy = null === $sessionStrategy ? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE) : $sessionStrategy;
61+
$this->sessionStrategy = $sessionStrategy ?? new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
6262
}
6363

6464
/**

Tests/Firewall/ExceptionListenerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle
9999
$listener->onKernelException($event);
100100

101101
$this->assertNull($event->getResponse());
102-
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious());
102+
$this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious());
103103
}
104104

105105
/**
@@ -122,7 +122,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithoutAccessDeniedHandle
122122

123123
$this->assertEquals('Unauthorized', $event->getResponse()->getContent());
124124
$this->assertEquals(401, $event->getResponse()->getStatusCode());
125-
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious());
125+
$this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious());
126126
}
127127

128128
/**
@@ -139,7 +139,7 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn
139139
$listener->onKernelException($event);
140140

141141
$this->assertEquals('error', $event->getResponse()->getContent());
142-
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious());
142+
$this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious());
143143
}
144144

145145
/**
@@ -156,7 +156,7 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \
156156
$listener->onKernelException($event);
157157

158158
$this->assertEquals('OK', $event->getResponse()->getContent());
159-
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getThrowable()->getPrevious());
159+
$this->assertSame($eventException ?? $exception, $event->getThrowable()->getPrevious());
160160
}
161161

162162
public function testLogoutException()

0 commit comments

Comments
 (0)