Skip to content

Commit 34556fb

Browse files
Use ??= more
1 parent 1983b80 commit 34556fb

File tree

5 files changed

+6
-18
lines changed

5 files changed

+6
-18
lines changed

Compiler/AbstractRecursivePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
150150
}
151151
} elseif ($class instanceof Definition) {
152152
$class = $class->getClass();
153-
} elseif (null === $class) {
154-
$class = $definition->getClass();
153+
} else {
154+
$class ??= $definition->getClass();
155155
}
156156

157157
return $this->getReflectionMethod(new Definition($class), $method);

ContainerBuilder.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,12 +1336,8 @@ public function getAutoconfiguredAttributes(): array
13361336
*/
13371337
public function resolveEnvPlaceholders(mixed $value, string|bool $format = null, array &$usedEnvs = null): mixed
13381338
{
1339-
if (null === $format) {
1340-
$format = '%%env(%s)%%';
1341-
}
1342-
13431339
$bag = $this->getParameterBag();
1344-
if (true === $format) {
1340+
if (true === $format ??= '%%env(%s)%%') {
13451341
$value = $bag->resolveValue($value);
13461342
}
13471343

Dumper/PhpDumper.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,9 +1700,7 @@ private function getServiceConditionals(mixed $value): string
17001700

17011701
private function getDefinitionsFromArguments(array $arguments, \SplObjectStorage $definitions = null, array &$calls = [], bool $byConstructor = null): \SplObjectStorage
17021702
{
1703-
if (null === $definitions) {
1704-
$definitions = new \SplObjectStorage();
1705-
}
1703+
$definitions ??= new \SplObjectStorage();
17061704

17071705
foreach ($arguments as $argument) {
17081706
if (\is_array($argument)) {

Loader/FileLoader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ private function findClasses(string $namespace, string $pattern, array $excludeP
186186
$excludePatterns = $parameterBag->unescapeValue($parameterBag->resolveValue($excludePatterns));
187187
foreach ($excludePatterns as $excludePattern) {
188188
foreach ($this->glob($excludePattern, true, $resource, true, true) as $path => $info) {
189-
if (null === $excludePrefix) {
190-
$excludePrefix = $resource->getPrefix();
191-
}
189+
$excludePrefix ??= $resource->getPrefix();
192190

193191
// normalize Windows slashes and remove trailing slashes
194192
$excludePaths[rtrim(str_replace('\\', '/', $path), '/')] = true;

Loader/YamlFileLoader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,7 @@ private function parseDefinition(string $id, array|string|null $service, string
348348
$service = ['arguments' => $service];
349349
}
350350

351-
if (null === $service) {
352-
$service = [];
353-
}
354-
355-
if (!\is_array($service)) {
351+
if (!\is_array($service ??= [])) {
356352
throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', get_debug_type($service), $id, $file));
357353
}
358354

0 commit comments

Comments
 (0)