Skip to content

Commit 632e68b

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: CS: Apply ternary_to_null_coalescing fixer
2 parents 4b562db + 03210cd commit 632e68b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Definition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public function getTags()
479479
*/
480480
public function getTag(string $name)
481481
{
482-
return isset($this->tags[$name]) ? $this->tags[$name] : [];
482+
return $this->tags[$name] ?? [];
483483
}
484484

485485
/**

Loader/YamlFileLoader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ private function parseDefinition(string $id, $service, string $file, array $defa
559559
}
560560
}
561561

562-
$tags = isset($service['tags']) ? $service['tags'] : [];
562+
$tags = $service['tags'] ?? [];
563563
if (!\is_array($tags)) {
564564
throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file));
565565
}
@@ -615,8 +615,8 @@ private function parseDefinition(string $id, $service, string $file, array $defa
615615
throw new InvalidArgumentException(sprintf('Invalid value "%s" for attribute "decoration_on_invalid" on service "%s". Did you mean "exception", "ignore" or null in "%s"?', $decorationOnInvalid, $id, $file));
616616
}
617617

618-
$renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null;
619-
$priority = isset($service['decoration_priority']) ? $service['decoration_priority'] : 0;
618+
$renameId = $service['decoration_inner_name'] ?? null;
619+
$priority = $service['decoration_priority'] ?? 0;
620620

621621
$definition->setDecoratedService($decorates, $renameId, $priority, $invalidBehavior);
622622
}
@@ -666,8 +666,8 @@ private function parseDefinition(string $id, $service, string $file, array $defa
666666
if (!\is_string($service['resource'])) {
667667
throw new InvalidArgumentException(sprintf('A "resource" attribute must be of type string for service "%s" in "%s". Check your YAML syntax.', $id, $file));
668668
}
669-
$exclude = isset($service['exclude']) ? $service['exclude'] : null;
670-
$namespace = isset($service['namespace']) ? $service['namespace'] : $id;
669+
$exclude = $service['exclude'] ?? null;
670+
$namespace = $service['namespace'] ?? $id;
671671
$this->registerClasses($definition, $namespace, $service['resource'], $exclude);
672672
} else {
673673
$this->setDefinition($id, $definition);
@@ -841,7 +841,7 @@ private function resolveServices($value, string $file, bool $isParameter = false
841841
$instanceof = $this->instanceof;
842842
$this->instanceof = [];
843843

844-
$id = sprintf('.%d_%s', ++$this->anonymousServicesCount, preg_replace('/^.*\\\\/', '', isset($argument['class']) ? $argument['class'] : '').$this->anonymousServicesSuffix);
844+
$id = sprintf('.%d_%s', ++$this->anonymousServicesCount, preg_replace('/^.*\\\\/', '', $argument['class'] ?? '').$this->anonymousServicesSuffix);
845845
$this->parseDefinition($id, $argument, $file, []);
846846

847847
if (!$this->container->hasDefinition($id)) {

Tests/Fixtures/includes/ProjectExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public function load(array $configs, ContainerBuilder $configuration)
1717
}
1818

1919
$configuration->register('project.service.bar', 'FooClass')->setPublic(true);
20-
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
20+
$configuration->setParameter('project.parameter.bar', $config['foo'] ?? 'foobar');
2121

2222
$configuration->register('project.service.foo', 'FooClass')->setPublic(true);
23-
$configuration->setParameter('project.parameter.foo', isset($config['foo']) ? $config['foo'] : 'foobar');
23+
$configuration->setParameter('project.parameter.foo', $config['foo'] ?? 'foobar');
2424

2525
return $configuration;
2626
}

0 commit comments

Comments
 (0)