Skip to content

Commit 2fb5439

Browse files
committed
Make use of the nullsafe operator
1 parent d40a69b commit 2fb5439

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

Logger/DbalLogger.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public function __construct(LoggerInterface $logger = null, Stopwatch $stopwatch
3737
*/
3838
public function startQuery($sql, array $params = null, array $types = null): void
3939
{
40-
if (null !== $this->stopwatch) {
41-
$this->stopwatch->start('doctrine', 'doctrine');
42-
}
40+
$this->stopwatch?->start('doctrine', 'doctrine');
4341

4442
if (null !== $this->logger) {
4543
$this->log($sql, null === $params ? [] : $this->normalizeParams($params));
@@ -51,9 +49,7 @@ public function startQuery($sql, array $params = null, array $types = null): voi
5149
*/
5250
public function stopQuery(): void
5351
{
54-
if (null !== $this->stopwatch) {
55-
$this->stopwatch->stop('doctrine');
56-
}
52+
$this->stopwatch?->stop('doctrine');
5753
}
5854

5955
/**

Validator/DoctrineInitializer.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ public function __construct(ManagerRegistry $registry)
3030

3131
public function initialize(object $object)
3232
{
33-
$manager = $this->registry->getManagerForClass(\get_class($object));
34-
if (null !== $manager) {
35-
$manager->initializeObject($object);
36-
}
33+
$this->registry->getManagerForClass(\get_class($object))?->initializeObject($object);
3734
}
3835
}

0 commit comments

Comments
 (0)