8000 minor #42165 Simplify some code with null coalesce operator (javiereg… · symfony/http-kernel@6dfb6c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6dfb6c5

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 f96639d + 0b693cf commit 6dfb6c5

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

EventListener/DebugHandlersListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $
6060

6161
$this->exceptionHandler = $exceptionHandler;
6262
$this->logger = $logger;
63-
$this->levels = null === $levels ? \E_ALL : $levels;
63+
$this->levels = $levels ?? \E_ALL;
6464
$this->throwAt = \is_int($throwAt) ? $throwAt : (null === $throwAt ? null : ($throwAt ? \E_ALL : null));
6565
$this->scream = $scream;
6666
$this->fileLinkFormat = $fileLinkFormat;

Profiler/Profile.php

Lines changed: 1 addition & 5 deletions
< 8000 td data-grid-cell-id="diff-73a9d31d66b39bf9aa1b7793180e1cf5152170bc74b76820fa68bd202e1e6a38-156-156-0" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">156
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ public function setUrl($url)
156
*/
157157
public function getTime()
158158
{
159-
if (null === $this->time) {
160-
return 0;
161-
}
162-
163-
return $this->time;
159+
return $this->time ?? 0;
164160
}
165161

166162
/**

Tests/KernelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
709709
$bundle
710710
->expects($this->any())
711711
->method('getName')
712-
->willReturn(null === $bundleName ? \get_class($bundle) : $bundleName)
712+
->willReturn($bundleName ?? \get_class($bundle))
713713
;
714714

715715
$bundle

0 commit comments

Comments
 (0)
0