Skip to content

Commit e681bd5

Browse files
committed
Add a few more ??=
1 parent 4d09837 commit e681bd5

File tree

22 files changed

+38
-38
lines changed

22 files changed

+38
-38
lines changed

src/Symfony/Bridge/Twig/Extension/DumpExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function dump(Environment $env, array $context): ?string
6868
}
6969

7070
$dump = fopen('php://memory', 'r+');
71-
$this->dumper = $this->dumper ?? new HtmlDumper();
71+
$this->dumper ??= new HtmlDumper();
7272
$this->dumper->setCharset($env->getCharset());
7373

7474
foreach ($vars as $value) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static function createSystemCache(string $namespace, int $defaultLifetime
9494
$opcache->setLogger($logger);
9595
}
9696

97-
if (!self::$apcuSupported = self::$apcuSupported ?? ApcuAdapter::isSupported()) {
97+
if (!self::$apcuSupported ??= ApcuAdapter::isSupported()) {
9898
return $opcache;
9999
}
100100

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ private static function getOptions(string $options): array
141141

142142
private static function initOptions(array $options): array
143143
{
144-
$options['username'] = $options['username'] ?? '';
145-
$options['password'] = $options['password'] ?? '';
146-
$options['operationTimeout'] = $options['operationTimeout'] ?? 0;
147-
$options['configTimeout'] = $options['configTimeout'] ?? 0;
148-
$options['configNodeTimeout'] = $options['configNodeTimeout'] ?? 0;
149-
$options['n1qlTimeout'] = $options['n1qlTimeout'] ?? 0;
150-
$options['httpTimeout'] = $options['httpTimeout'] ?? 0;
151-
$options['configDelay'] = $options['configDelay'] ?? 0;
152-
$options['htconfigIdleTimeout'] = $options['htconfigIdleTimeout'] ?? 0;
153-
$options['durabilityInterval'] = $options['durabilityInterval'] ?? 0;
154-
$options['durabilityTimeout'] = $options['durabilityTimeout'] ?? 0;
144+
$options['username'] ??= '';
145+
$options['password'] ??= '';
146+
$options['operationTimeout'] ??= 0;
147+
$options['configTimeout'] ??= 0;
148+
$options['configNodeTimeout'] ??= 0;
149+
$options['n1qlTimeout'] ??= 0;
150+
$options['httpTimeout'] ??= 0;
151+
$options['configDelay'] ??= 0;
152+
$options['htconfigIdleTimeout'] ??= 0;
153+
$options['durabilityInterval'] ??= 0;
154+
$options['durabilityTimeout'] ??= 0;
155155

156156
return $options;
157157
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
4646
public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null, bool $appendOnly = false)
4747
{
4848
$this->appendOnly = $appendOnly;
49-
self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
49+
self::$startTime ??= $_SERVER['REQUEST_TIME'] ?? time();
5050
parent::__construct('', $defaultLifetime);
5151
$this->init($namespace, $directory);
5252
$this->includeHandler = static function ($type, $msg, $file, $line) {
@@ -56,7 +56,7 @@ public function __construct(string $namespace = '', int $defaultLifetime = 0, st
5656

5757
public static function isSupported()
5858
{
59-
self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time();
59+
self::$startTime ??= $_SERVER['REQUEST_TIME'] ?? time();
6060

6161
return \function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(\ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOL));
6262
}

src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function canBeEnabled(): static
246246
->beforeNormalization()
247247
->ifArray()
248248
->then(function (array $v) {
249-
$v['enabled'] = $v['enabled'] ?? true;
249+
$v['enabled'] ??= true;
250250

251251
return $v;
252252
})

src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function process(ContainerBuilder $container)
7373
continue;
7474
}
7575

76-
$event['method'] = $event['method'] ?? '__invoke';
76+
$event['method'] ??= '__invoke';
7777
$event['event'] = $this->getEventFromTypeDeclaration($container, $id, $event['method']);
7878
}
7979

src/Symfony/Component/HttpClient/Internal/AmpListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(array &$info, array $pinSha256, \Closure $onProgress
5050

5151
public function startRequest(Request $request): Promise
5252
{
53-
$this->info['start_time'] = $this->info['start_time'] ?? microtime(true);
53+
$this->info['start_time'] ??= microtime(true);
5454
($this->onProgress)();
5555

5656
return new Success();

src/Symfony/Component/HttpClient/Internal/CurlClientState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class CurlClientState extends ClientState
3838

3939
public function __construct(int $maxHostConnections, int $maxPendingPushes)
4040
{
41-
self::$curlVersion = self::$curlVersion ?? curl_version();
41+
self::$curlVersion ??= curl_version();
4242

4343
$this->handle = curl_multi_init();
4444
$this->dnsCache = new DnsCache();

src/Symfony/Component/HttpClient/Response/CurlResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct(CurlClientState $multi, \CurlHandle|string $ch, arra
6868
$this->info['http_method'] = $method;
6969
$this->info['user_data'] = $options['user_data'] ?? null;
7070
$this->info['max_duration'] = $options['max_duration'] ?? null;
71-
$this->info['start_time'] = $this->info['start_time'] ?? microtime(true);
71+
$this->info['start_time'] ??= microtime(true);
7272
$this->info['original_url'] = $originalUrl ?? $this->info['url'] ?? curl_getinfo($ch, \CURLINFO_EFFECTIVE_URL);
7373
$info = &$this->info;
7474
$headers = &$this->headers;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ protected function loadSession()
208208

209209
foreach ($bags as $bag) {
210210
$key = $bag->getStorageKey();
211-
$this->data[$key] = $this->data[$key] ?? [];
211+
$this->data[$key] ??= [];
212212
$bag->initialize($this->data[$key]);
213213
}
214214

src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function initialize(): void
146146
$options = array_merge($options, $this->streamContextOptions);
147147
}
148148
// do it unconditionnally as it will be used by STARTTLS as well if supported
149-
$options['ssl']['crypto_method'] = $options['ssl']['crypto_method'] ?? \STREAM_CRYPTO_METHOD_TLS_CLIENT | \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
149+
$options['ssl']['crypto_method'] ??= \STREAM_CRYPTO_METHOD_TLS_CLIENT | \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
150150
$streamContext = stream_context_create($options);
151151

152152
$timeout = $this->getTimeout();

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ private function publishOnExchange(\AMQPExchange $exchange, string $body, string
329329
{
330330
$attributes = $amqpStamp ? $amqpStamp->getAttributes() : [];
331331
$attributes['headers'] = array_merge($attributes['headers'] ?? [], $headers);
332-
$attributes['delivery_mode'] = $attributes['delivery_mode'] ?? 2;
333-
$attributes['timestamp'] = $attributes['timestamp'] ?? time();
332+
$attributes['delivery_mode'] ??= 2;
333+
$attributes['timestamp'] ??= time();
334334

335335
$exchange->publish(
336336
$body,

src/Symfony/Component/Messenger/Bridge/Redis/Transport/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public static function fromDsn(string $dsn, array $options = [], \Redis|\RedisCl
209209
$options['host'] = $parsedUrl['host'] ?? $options['host'];
210210
$options['port'] = $parsedUrl['port'] ?? $options['port'];
211211
// See: https://github.com/phpredis/phpredis/#auth
212-
$options['auth'] = $options['auth'] ?? (null !== $pass && null !== $user ? [$user, $pass] : ($pass ?? $user));
212+
$options['auth'] ??= null !== $pass && null !== $user ? [$user, $pass] : ($pass ?? $user);
213213

214214
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));
215215
$options['stream'] = $pathParts[1] ?? $options['stream'];

src/Symfony/Component/Notifier/Bridge/Expo/ExpoTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function doSend(MessageInterface $message): SentMessage
6767

6868
$options['title'] = $message->getSubject();
6969
$options['body'] = $message->getContent();
70-
$options['data'] = $options['data'] ?? [];
70+
$options['data'] ??= [];
7171

7272
$response = $this->client->request('POST', $endpoint, [
7373
'headers' => [

src/Symfony/Component/Notifier/Bridge/Firebase/FirebaseTransport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ protected function doSend(MessageInterface $message): SentMessage
6363
if (null === $options['to']) {
6464
throw new InvalidArgumentException(sprintf('The "%s" transport required the "to" option to be set.', __CLASS__));
6565
}
66-
$options['notification'] = $options['notification'] ?? [];
66+
$options['notification'] ??= [];
6767
$options['notification']['body'] = $message->getSubject();
68-
$options['data'] = $options['data'] ?? [];
68+
$options['data'] ??= [];
6969

7070
$response = $this->client->request('POST', $endpoint, [
7171
'headers' => [

src/Symfony/Component/Notifier/Bridge/MicrosoftTeams/MicrosoftTeamsTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function doSend(MessageInterface $message): SentMessage
6464

6565
$options = ($opts = $message->getOptions()) ? $opts->toArray() : [];
6666

67-
$options['text'] = $options['text'] ?? $message->getSubject();
67+
$options['text'] ??= $message->getSubject();
6868

6969
$path = $message->getRecipientId() ?? $this->path;
7070
$endpoint = sprintf('https://%s%s', $this->getEndpoint(), $path);

src/Symfony/Component/OptionsResolver/OptionsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public function addNormalizer(string $option, \Closure $normalizer, bool $forceP
537537
}
538538

539539
if ($forcePrepend) {
540-
$this->normalizers[$option] = $this->normalizers[$option] ?? [];
540+
$this->normalizers[$option] ??= [];
541541
array_unshift($this->normalizers[$option], $normalizer);
542542
} else {
543543
$this->normalizers[$option][] = $normalizer;

src/Symfony/Component/PropertyInfo/PhpStan/NameScopeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class NameScopeFactory
2222
{
2323
public function create(string $calledClassName, string $declaringClassName = null): NameScope
2424
{
25-
$declaringClassName = $declaringClassName ?? $calledClassName;
25+
$declaringClassName ??= $calledClassName;
2626

2727
$path = explode('\\', $calledClassName);
2828
$calledClassName = array_pop($path);

src/Symfony/Component/Runtime/Tests/phpt/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Symfony\Component\Runtime\SymfonyRuntime;
1313

14-
$_SERVER['APP_RUNTIME_OPTIONS'] = $_SERVER['APP_RUNTIME_OPTIONS'] ?? [];
14+
$_SERVER['APP_RUNTIME_OPTIONS'] ??= [];
1515
$_SERVER['APP_RUNTIME_OPTIONS'] += [
1616
'project_dir' => __DIR__,
1717
] + ($_SERVER['APP_RUNTIME_OPTIONS'] ?? []);

src/Symfony/Component/String/LazyString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function fromCallable(callable|array $callback, mixed ...$argument
3434
if (null !== $arguments) {
3535
if (!\is_callable($callback)) {
3636
$callback[0] = $callback[0]();
37-
$callback[1] = $callback[1] ?? '__invoke';
37+
$callback[1] ??= '__invoke';
3838
}
3939
$value = $callback(...$arguments);
4040
$callback = self::getPrettyName($callback);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ private function normalizeBinaryFormat(int|string $maxSize)
152152
];
153153
if (ctype_digit((string) $maxSize)) {
154154
$this->maxSize = (int) $maxSize;
155-
$this->binaryFormat = $this->binaryFormat ?? false;
155+
$this->binaryFormat ??= false;
156156
} elseif (preg_match('/^(\d++)('.implode('|', array_keys($factors)).')$/i', $maxSize, $matches)) {
157157
$this->maxSize = $matches[1] * $factors[$unit = strtolower($matches[2])];
158-
$this->binaryFormat = $this->binaryFormat ?? (2 === \strlen($unit));
158+
$this->binaryFormat ??= 2 === \strlen($unit);
159159
} else {
160160
throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size.', $maxSize));
161161
}

src/Symfony/Component/VarDumper/Caster/MemcachedCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public static function castMemcached(\Memcached $c, array $a, Stub $stub, bool $
3737

3838
private static function getNonDefaultOptions(\Memcached $c): array
3939
{
40-
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
41-
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
40+
self::$defaultOptions ??= self::discoverDefaultOptions();
41+
self::$optionConstants ??= self::getOptionConstants();
4242

4343
$nonDefaultOptions = [];
4444
foreach (self::$optionConstants as $constantKey => $value) {
@@ -56,7 +56,7 @@ private static function discoverDefaultOptions(): array
5656
$defaultMemcached->addServer('127.0.0.1', 11211);
5757

5858
$defaultOptions = [];
59-
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
59+
self::$optionConstants ??= self::getOptionConstants();
6060

6161
foreach (self::$optionConstants as $constantKey => $value) {
6262
$defaultOptions[$constantKey] = $defaultMemcached->getOption($value);

0 commit comments

Comments
 (0)