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

Skip to content

Commit 20d3d84

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 ------- 17ad5b7 Simplify some code with null coalesce operator
2 parents 39c02d6 + 17ad5b7 commit 20d3d84

File tree

35 files changed

+45
-61
lines changed

35 files changed

+45
-61
lines changed

src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null)
5454
return;
5555
}
5656

57-
$eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs;
57+
$eventArgs = $eventArgs ?? EventArgs::getEmptyInstance();
5858

5959
if (!isset($this->initialized[$eventName])) {
6060
$this->initializeListeners($eventName);

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function validate($entity, Constraint $constraint)
163163
return;
164164
}
165165

166-
$errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
166+
$errorPath = $constraint->errorPath ?? $fields[0];
167167
$invalidValue = $criteria[$errorPath] ?? $criteria[$fields[0]];
168168

169169
$this->context->buildViolation($constraint->message)

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,6 @@ private function getPublicDirectory(ContainerInterface $container): string
278278

279279
$composerConfig = json_decode(file_get_contents($composerFilePath), true);
280280

281-
if (isset($composerConfig['extra']['public-dir'])) {
282-
return $composerConfig['extra']['public-dir'];
283-
}
284-
285-
return $defaultPublicDir;
281+
return $composerConfig['extra']['public-dir'] ?? $defaultPublicDir;
286282
}
287283
}

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con
134134

135135
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
136136
{
137-
$this->writeData($this->getEventDispatcherListenersData($eventDispatcher, \array_key_exists('event', $options) ? $options['event'] : null), $options);
137+
$this->writeData($this->getEventDispatcherListenersData($eventDispatcher, $options['event'] ?? null), $options);
138138
}
139139

140140
protected function describeCallable($callable, array $options = [])

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ protected function describeContainerEnvVars(array $envs, array $options = [])
258258

259259
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
260260
{
261-
$event = \array_key_exists('event', $options) ? $options['event'] : null;
261+
$event = $options['event'] ?? null;
262262

263263
$title = 'Registered listeners';
264264
if (null !== $event) {

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ protected function describeContainerEnvVars(array $envs, array $options = [])
442442

443443
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
444444
{
445-
$event = \array_key_exists('event', $options) ? $options['event'] : null;
445+
$event = $options['event'] ?? null;
446446

447447
if (null !== $event) {
448448
$title = sprintf('Registered Listeners for "%s" Event', $event);

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function describeContainerAlias(Alias $alias, array $options = [], Con
8888

8989
protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
9090
{
91-
$this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, \array_key_exists('event', $options) ? $options['event'] : null));
91+
$this->writeDocument($this->getEventDispatcherListenersDocument($eventDispatcher, $options['event'] ?? null));
9292
}
9393

9494
protected function describeCallable($callable, array $options = [])

src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected function json($data, int $status = 200, array $headers = [], array $co
144144
protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse
145145
{
146146
$response = new BinaryFileResponse($file);
147-
$response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName);
147+
$response->setContentDisposition($disposition, $fileName ?? $response->getFile()->getFilename());
148148

149149
return $response;
150150
}

src/Symfony/Component/Cache/Adapter/ArrayAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function save(CacheItemInterface $item)
141141
}
142142

143143
$this->values[$key] = $value;
144-
$this->expiries[$key] = null !== $expiry ? $expiry : \PHP_INT_MAX;
144+
$this->expiries[$key] = $expiry ?? \PHP_INT_MAX;
145145

146146
return true;
147147
}

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static function createConnection($dsn, array $options = [])
172172
if (null === $params['class'] && !isset($params['redis_sentinel']) && \extension_loaded('redis')) {
173173
$class = $params['redis_cluster'] ? \RedisCluster::class : (1 < \count($hosts) ? \RedisArray::class : \Redis::class);
174174
} else {
175-
$class = null === $params['class'] ? \Predis\Client::class : $params['class'];
175+
$class = $params['class'] ?? \Predis\Client::class;
176176
}
177177

178178
if (is_a($class, \Redis::class, true)) {

src/Symfony/Component/Console/Event/ConsoleErrorEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public function setExitCode(int $exitCode): void
5353

5454
public function getExitCode(): int
5555
{
56-
return null !== $this->exitCode ? $this->exitCode : (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
56+
return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
5757
}
5858
}

src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function freezeAfterProcessing(Extension $extension, ContainerBuilder $co
143143
*/
144144
public function getEnvPlaceholders(): array
145145
{
146-
return null !== $this->processedEnvPlaceholders ? $this->processedEnvPlaceholders : parent::getEnvPlaceholders();
146+
return $this->processedEnvPlaceholders ?? parent::getEnvPlaceholders();
147147
}
148148

149149
public function getUnusedEnvPlaceholders(): array

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ private function callMethod($service, array $call, array &$inlineServices)
16301630
*/
16311631
private function shareService(Definition $definition, $service, ?string $id, array &$inlineServices)
16321632
{
1633-
$inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service;
1633+
$inlineServices[$id ?? spl_object_hash($definition)] = $service;
16341634

16351635
if (null !== $id && $definition->isShared()) {
16361636
$this->services[$id] = $service;

src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($grouping = false, $roundingMode = self::ROUND_DOWN,
3434
@trigger_error(sprintf('Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.', __CLASS__), \E_USER_DEPRECATED);
3535

3636
$grouping = $roundingMode;
37-
$roundingMode = null !== $locale ? $locale : self::ROUND_DOWN;
37+
$roundingMode = $locale ?? self::ROUND_DOWN;
3838
$locale = null;
3939
}
4040

src/Symfony/Component/Form/Extension/Core/Type/TextType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ public function transform($data)
6262
*/
6363
public function reverseTransform($data)
6464
{
65-
return null === $data ? '' : $data;
65+
return $data ?? '';
6666
}
6767
}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ public function getRequestFormat($default = 'html')
13711371
$this->format = $this->attributes->get('_format');
13721372
}
13731373

1374-
return null === $this->format ? $default : $this->format;
1374+
return $this->format ?? $default;
13751375
}
13761376

13771377
/**

src/Symfony/Component/HttpFoundation/RequestStack.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public function getParentRequest()
9494
{
9595
$pos = \count($this->requests) - 2;
9696

97-
if (!isset($this->requests[$pos])) {
98-
return null;
99-
}
100-
101-
return $this->requests[$pos];
97+
return $this->requests[$pos] ?? null;
10298
}
10399
}

src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function hasCacheControlDirective($key)
176176
*/
177177
public function getCacheControlDirective($key)
178178
{
179-
return \array_key_exists($key, $this->computedCacheControl) ? $this->computedCacheControl[$key] : null;
179+
return $this->computedCacheControl[$key] ?? null;
180180
}
181181

182182
public function setCookie(Cookie $cookie)

src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,6 @@ private function stampCreated(int $lifetime = null): void
163163
{
164164
$timeStamp = time();
165165
$this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
166-
$this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime;
166+
$this->meta[self::LIFETIME] = $lifetime ?? ini_get('session.cookie_lifetime');
167167
}
168168
}

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

Lines changed: 1 addition & 1 deletion
< 741A /div>
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;

src/Symfony/Component/HttpKernel/Profiler/Profile.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,7 @@ public function setUrl($url)
156156
*/
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
/**

src/Symfony/Component/HttpKernel/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

src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
142142
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
143143
}
144144

145-
$this->datetype = null !== $datetype ? $datetype : self::FULL;
146-
$this->timetype = null !== $timetype ? $timetype : self::FULL;
145+
$this->datetype = $datetype ?? self::FULL;
146+
$this->timetype = $timetype ?? self::FULL;
147147

148148
if ('' === ($pattern ?? '')) {
149149
$pattern = $this->getDefaultPattern();

src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ protected function getDefaultDateFormatter($pattern = null)
933933
protected function getDateTime($timestamp, $timeZone)
934934
{
935935
$dateTime = new \DateTime();
936-
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
936+
$dateTime->setTimestamp($timestamp ?? time());
937937
$dateTime->setTimezone(new \DateTimeZone($timeZone ?: getenv('TZ') ?: 'UTC'));
938938

939939
return $dateTime;

src/Symfony/Component/Intl/Util/GitRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static function exec(string $command, string $customErrorMessage = null)
9595
exec(sprintf('%s 2>&1', $command), $output, $result);
9696

9797
if (0 !== $result) {
98-
throw new RuntimeException(null !== $customErrorMessage ? $customErrorMessage : sprintf('The "%s" command failed.', $command));
98+
throw new RuntimeException($customErrorMessage ?? sprintf('The "%s" command failed.', $command));
9999
}
100100

101101
return $output;

src/Symfony/Component/Messenger/Tests/WorkerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public function get(): iterable
260260
{
261261
$val = array_shift($this->deliveriesOfEnvelopes);
262262

263-
return null === $val ? [] : $val;
263+
return $val ?? [];
264264
}
265265

266266
public function ack(Envelope $envelope): void

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public function __construct(DocBlockFactoryInterface $docBlockFactory = null, ar
6666
$this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance();
6767
$this->contextFactory = new ContextFactory();
6868
$this->phpDocTypeHelper = new PhpDocTypeHelper();
69-
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : ReflectionExtractor::$defaultMutatorPrefixes;
70-
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : ReflectionExtractor::$defaultAccessorPrefixes;
71-
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : ReflectionExtractor::$defaultArrayMutatorPrefixes;
69+
$this->mutatorPrefixes = $mutatorPrefixes ?? ReflectionExtractor::$defaultMutatorPrefixes;
70+
$this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;
71+
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes;
7272
}
7373

7474
/**

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
6868
*/
6969
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC)
7070
{
71-
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes;
72-
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : self::$defaultAccessorPrefixes;
73-
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : self::$defaultArrayMutatorPrefixes;
71+
$this->mutatorPrefixes = $mutatorPrefixes ?? self::$defaultMutatorPrefixes;
72+
$this->accessorPrefixes = $accessorPrefixes ?? self::$defaultAccessorPrefixes;
73+
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? self::$defaultArrayMutatorPrefixes;
7474
$this->enableConstructorExtraction = $enableConstructorExtraction;
7575
$this->accessFlags = $accessFlags;
7676

src/Symfony/Component/Security/Http/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
/**

src/Symfony/Component/Security/Http/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()

src/Symfony/Component/Validator/Constraints/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ private function normalizeBinaryFormat($maxSize)
112112
];
113113
if (ctype_digit((string) $maxSize)) {
114114
$this->maxSize = (int) $maxSize;
115-
$this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat;
115+
$this->binaryFormat = $this->binaryFormat ?? false;
116116
} elseif (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) {
117117
$this->maxSize = $matches[1] * $factors[$unit = strtolower($matches[2])];
118-
$this->binaryFormat = null === $this->binaryFormat ? 2 === \strlen($unit) : $this->binaryFormat;
118+
$this->binaryFormat = $this->binaryFormat ?? (2 === \strlen($unit));
119119
} else {
120120
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size.', $this->maxSize));
121121
}

src/Symfony/Component/Validator/Constraints/FileValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function validate($value, Constraint $constraint)
6060
$binaryFormat = $constraint->binaryFormat;
6161
} else {
6262
$limitInBytes = $iniLimitSize;
63-
$binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat;
63+
$binaryFormat = $constraint->binaryFormat ?? true;
6464
}
6565

6666
[, $limitAsString, $suffix] = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,7 @@ public function hasPropertyMetadata($property)
365365
*/
366366
public function getPropertyMetadata($property)
367367
{
368-
if (!isset($this->members[$property])) {
369-
return [];
370-
}
371-
372-
return $this->members[$property];
368+
return $this->members[$property] ?? [];
373369
}
374370

375371
/**

src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php

Lines changed: 1 addition & 1 deletion
< 10000 /div>
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct($output = null, string $charset = null, int $flags =
6363
*/
6464
public function setOutput($output)
6565
{
66-
$prev = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
66+
$prev = $this->outputStream ?? $this->lineDumper;
6767

6868
if (\is_callable($output)) {
6969
$this->outputStream = null;

src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function dump(Data $data, $output = null, array $extraDisplayOptions = []
153153
*/
154154
protected function getDumpHeader()
155155
{
156-
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
156+
$this->headerIsDumped = $this->outputStream ?? $this->lineDumper;
157157

158158
if (null !== $this->dumpHeader) {
159159
return $this->dumpHeader;
@@ -964,7 +964,7 @@ protected function dumpLine($depth, $endOfValue = false)
964964
if (-1 === $this->lastDepth) {
965965
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
966966
}
967-
if ($this->headerIsDumped !== (null !== $this->outputStream ? $this->outputStream : $this->lineDumper)) {
967+
if ($this->headerIsDumped !== ($this->outputStream ?? $this->lineDumper)) {
968968
$this->line = $this->getDumpHeader().$this->line;
969969
}
970970

0 commit comments

Comments
 (0)
0