Skip to content

Commit 745d1dc

Browse files
committed
Use short array deconstruction syntax.
1 parent 4c41ad6 commit 745d1dc

13 files changed

+27
-27
lines changed

Argument/BoundArgument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function getValues(): array
5454
public function setValues(array $values)
5555
{
5656
if (5 === \count($values)) {
57-
list($this->value, $this->identifier, $this->used, $this->type, $this->file) = $values;
57+
[$this->value, $this->identifier, $this->used, $this->type, $this->file] = $values;
5858
} else {
59-
list($this->value, $this->identifier, $this->used) = $values;
59+
[$this->value, $this->identifier, $this->used] = $values;
6060
}
6161
}
6262
}

Compiler/AbstractRecursivePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function getConstructor(Definition $definition, $required)
130130
}
131131

132132
if ($factory) {
133-
list($class, $method) = $factory;
133+
[$class, $method] = $factory;
134134
if ($class instanceof Reference) {
135135
$class = $this->container->findDefinition((string) $class)->getClass();
136136
} elseif ($class instanceof Definition) {

Compiler/AutowirePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private function doProcessValue($value, bool $isRoot = false)
126126
$this->methodCalls = $this->autowireCalls($reflectionClass, $isRoot);
127127

128128
if ($constructor) {
129-
list(, $arguments) = array_shift($this->methodCalls);
129+
[, $arguments] = array_shift($this->methodCalls);
130130

131131
if ($arguments !== $value->getArguments()) {
132132
$value->setArguments($arguments);
@@ -152,7 +152,7 @@ private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot):
152152

153153
foreach ($this->methodCalls as $i => $call) {
154154
$this->decoratedMethodIndex = $i;
155-
list($method, $arguments) = $call;
155+
[$method, $arguments] = $call;
156156

157157
if ($method instanceof \ReflectionFunctionAbstract) {
158158
$reflectionMethod = $method;

Compiler/AutowireRequiredMethodsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function processValue($value, $isRoot = false)
3737
$alreadyCalledMethods = [];
3838
$withers = [];
3939

40-
foreach ($value->getMethodCalls() as list($method)) {
40+
foreach ($value->getMethodCalls() as [$method]) {
4141
$alreadyCalledMethods[strtolower($method)] = true;
4242
}
4343

Compiler/DecoratorServicePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function process(ContainerBuilder $container)
3939
}
4040
$decoratingDefinitions = [];
4141

42-
foreach ($definitions as list($id, $definition)) {
42+
foreach ($definitions as [$id, $definition]) {
4343
$decoratedService = $definition->getDecoratedService();
44-
list($inner, $renamedId) = $decoratedService;
44+
[$inner, $renamedId] = $decoratedService;
4545
$invalidBehavior = $decoratedService[3] ?? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
4646

4747
$definition->setDecoratedService(null);

Compiler/ResolveBindingsPass.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public function process(ContainerBuilder $container)
4141
try {
4242
parent::process($container);
4343

44-
foreach ($this->unusedBindings as list($key, $serviceId, $bindingType, $file)) {
44+
foreach ($this->unusedBindings as [$key, $serviceId, $bindingType, $file]) {
4545
$argumentType = $argumentName = $message = null;
4646

4747
if (false !== strpos($key, ' ')) {
48-
list($argumentType, $argumentName) = explode(' ', $key, 2);
48+
[$argumentType, $argumentName] = explode(' ', $key, 2);
4949
} elseif ('$' === $key[0]) {
5050
$argumentName = $key;
5151
} else {
@@ -117,7 +117,7 @@ protected function processValue($value, $isRoot = false)
117117
$bindingNames = [];
118118

119119
foreach ($bindings as $key => $binding) {
120-
list($bindingValue, $bindingId, $used, $bindingType, $file) = $binding->getValues();
120+
[$bindingValue, $bindingId, $used, $bindingType, $file] = $binding->getValues();
121121
if ($used) {
122122
$this->usedBindings[$bindingId] = true;
123123
unset($this->unusedBindings[$bindingId]);
@@ -156,7 +156,7 @@ protected function processValue($value, $isRoot = false)
156156
}
157157

158158
foreach ($calls as $i => $call) {
159-
list($method, $arguments) = $call;
159+
[$method, $arguments] = $call;
160160

161161
if ($method instanceof \ReflectionFunctionAbstract) {
162162
$reflectionMethod = $method;
@@ -210,7 +210,7 @@ protected function processValue($value, $isRoot = false)
210210
}
211211

212212
if ($constructor) {
213-
list(, $arguments) = array_pop($calls);
213+
[, $arguments] = array_pop($calls);
214214

215215
if ($arguments !== $value->getArguments()) {
216216
$value->setArguments($arguments);
@@ -229,7 +229,7 @@ protected function processValue($value, $isRoot = false)
229229
*/
230230
private function getBindingValue(BoundArgument $binding)
231231
{
232-
list($bindingValue, $bindingId) = $binding->getValues();
232+
[$bindingValue, $bindingId] = $binding->getValues();
233233

234234
$this->usedBindings[$bindingId] = true;
235235
unset($this->unusedBindings[$bindingId]);

Compiler/ResolveNamedArgumentsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function processValue($value, $isRoot = false)
3636
$calls[] = ['__construct', $value->getArguments()];
3737

3838
foreach ($calls as $i => $call) {
39-
list($method, $arguments) = $call;
39+
[$method, $arguments] = $call;
4040
$parameters = null;
4141
$resolvedArguments = [];
4242

@@ -98,7 +98,7 @@ protected function processValue($value, $isRoot = false)
9898
}
9999
}
100100

101-
list(, $arguments) = array_pop($calls);
101+
[, $arguments] = array_pop($calls);
102102

103103
if ($arguments !== $value->getArguments()) {
104104
$value->setArguments($arguments);

ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ public function removeBindings(string $id)
15111511
{
15121512
if ($this->hasDefinition($id)) {
15131513
foreach ($this->getDefinition($id)->getBindings() as $key => $binding) {
1514-
list(, $bindingId) = $binding->getValues();
1514+
[, $bindingId] = $binding->getValues();
15151515
$this->removedBindingIds[(int) $bindingId] = true;
15161516
}
15171517
}

Dumper/PhpDumper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ private function addServiceInclude(string $cId, Definition $definition): string
568568
}
569569
}
570570

571-
foreach ($this->serviceCalls as $id => list($callCount, $behavior)) {
571+
foreach ($this->serviceCalls as $id => [$callCount, $behavior]) {
572572
if ('service_container' !== $id && $id !== $cId
573573
&& ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $behavior
574574
&& $this->container->has($id)
@@ -878,7 +878,7 @@ private function addInlineReference(string $id, Definition $definition, string $
878878
$targetId = (string) $this->container->getAlias($targetId);
879879
}
880880

881-
list($callCount, $behavior) = $this->serviceCalls[$targetId];
881+
[$callCount, $behavior] = $this->serviceCalls[$targetId];
882882

883883
if ($id === $targetId) {
884884
return $this->addInlineService($id, $definition, $definition);
@@ -934,7 +934,7 @@ private function addInlineService(string $id, Definition $definition, Definition
934934
$code = '';
935935

936936
if ($isSimpleInstance = $isRootInstance = null === $inlineDef) {
937-
foreach ($this->serviceCalls as $targetId => list($callCount, $behavior, $byConstructor)) {
937+
foreach ($this->serviceCalls as $targetId => [$callCount, $behavior, $byConstructor]) {
938938
if ($byConstructor && isset($this->circularReferences[$id][$targetId]) && !$this->circularReferences[$id][$targetId]) {
939939
$code .= $this->addInlineReference($id, $definition, $targetId, $forConstructor);
940940
}
@@ -1004,7 +1004,7 @@ private function addServices(array &$services = null): string
10041004
}
10051005

10061006
foreach ($definitions as $id => $definition) {
1007-
if (!(list($file, $code) = $services[$id]) || null !== $file) {
1007+
if (!([$file, $code] = $services[$id]) || null !== $file) {
10081008
continue;
10091009
}
10101010
if ($definition->isPublic()) {
@@ -1022,7 +1022,7 @@ private function generateServiceFiles(array $services): iterable
10221022
$definitions = $this->container->getDefinitions();
10231023
ksort($definitions);
10241024
foreach ($definitions as $id => $definition) {
1025-
if ((list($file, $code) = $services[$id]) && null !== $file && ($definition->isPublic() || !$this->isTrivialInstance($definition) || isset($this->locatedIds[$id]))) {
1025+
if (([$file, $code] = $services[$id]) && null !== $file && ($definition->isPublic() || !$this->isTrivialInstance($definition) || isset($this->locatedIds[$id]))) {
10261026
if (!$definition->isShared()) {
10271027
$i = strpos($code, "\n\ninclude_once ");
10281028
if (false !== $i && false !== $i = strpos($code, "\n\n", 2 + $i)) {
@@ -1732,7 +1732,7 @@ private function dumpValue($value, bool $interpolate = true): string
17321732
return sprintf('new \%s($this->getService, [%s%s], [%s%s])', ServiceLocator::class, $serviceMap, $serviceMap ? "\n " : '', $serviceTypes, $serviceTypes ? "\n " : '');
17331733
}
17341734
} finally {
1735-
list($this->definitionVariables, $this->referenceVariables) = $scope;
1735+
[$this->definitionVariables, $this->referenceVariables] = $scope;
17361736
}
17371737
} elseif ($value instanceof Definition) {
17381738
if ($value->hasErrors() && $e = $value->getErrors()) {

Dumper/XmlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function addService(Definition $definition, ?string $id, \DOMElement $pa
117117
$service->setAttribute('lazy', 'true');
118118
}
119119
if (null !== $decoratedService = $definition->getDecoratedService()) {
120-
list($decorated, $renamedId, $priority) = $decoratedService;
120+
[$decorated, $renamedId, $priority] = $decoratedService;
121121
$service->setAttribute('decorates', $decorated);
122122

123123
$decorationOnInvalid = $decoratedService[3] ?? ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;

0 commit comments

Comments
 (0)