Skip to content

Commit c77a268

Browse files
committed
Use short array deconstruction syntax.
1 parent 3cb45dc commit c77a268

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

Controller/ControllerResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function createController($controller)
116116
return $controller;
117117
}
118118

119-
list($class, $method) = explode('::', $controller, 2);
119+
[$class, $method] = explode('::', $controller, 2);
120120

121121
try {
122122
$controller = [$this->instantiateController($class), $method];
@@ -176,7 +176,7 @@ private function getControllerError($callable): string
176176
return 'Invalid array callable, expected [controller, method].';
177177
}
178178

179-
list($controller, $method) = $callable;
179+
[$controller, $method] = $callable;
180180

181181
if (\is_string($controller) && !class_exists($controller)) {
182182
return sprintf('Class "%s" does not exist.', $controller);

DataCollector/DumpDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function dump(Data $data)
7575
$this->stopwatch->start('dump');
7676
}
7777

78-
list('name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt) = $this->sourceContextProvider->getContext();
78+
['name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt] = $this->sourceContextProvider->getContext();
7979

8080
if ($this->dumper instanceof Connection) {
8181
if (!$this->dumper->write($data)) {

DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function process(ContainerBuilder $container)
9999
if (!isset($methods[$action = strtolower($attributes['action'])])) {
100100
throw new InvalidArgumentException(sprintf('Invalid "action" attribute on tag "%s" for service "%s": no public "%s()" method found on class "%s".', $this->controllerTag, $id, $attributes['action'], $class));
101101
}
102-
list($r, $parameters) = $methods[$action];
102+
[$r, $parameters] = $methods[$action];
103103
$found = false;
104104

105105
foreach ($parameters as $p) {
@@ -117,7 +117,7 @@ public function process(ContainerBuilder $container)
117117
}
118118
}
119119

120-
foreach ($methods as list($r, $parameters)) {
120+
foreach ($methods as [$r, $parameters]) {
121121
/** @var \ReflectionMethod $r */
122122

123123
// create a per-method map of argument-names to service/type-references
@@ -139,7 +139,7 @@ public function process(ContainerBuilder $container)
139139
} elseif (isset($bindings[$bindingName = $type.' $'.$p->name]) || isset($bindings[$bindingName = '$'.$p->name]) || isset($bindings[$bindingName = $type])) {
140140
$binding = $bindings[$bindingName];
141141

142-
list($bindingValue, $bindingId, , $bindingType, $bindingFile) = $binding->getValues();
142+
[$bindingValue, $bindingId, , $bindingType, $bindingFile] = $binding->getValues();
143143
$binding->setValues([$bindingValue, $bindingId, true, $bindingType, $bindingFile]);
144144

145145
if (!$bindingValue instanceof Reference) {

DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public function process(ContainerBuilder $container)
4242
} else {
4343
// any methods listed for call-at-instantiation cannot be actions
4444
$reason = false;
45-
list($id, $action) = explode('::', $controller);
45+
[$id, $action] = explode('::', $controller);
4646
$controllerDef = $container->getDefinition($id);
47-
foreach ($controllerDef->getMethodCalls() as list($method)) {
47+
foreach ($controllerDef->getMethodCalls() as [$method]) {
4848
if (0 === strcasecmp($action, $method)) {
4949
$reason = sprintf('Removing method "%s" of service "%s" from controller candidates: the method is called at instantiation, thus cannot be an action.', $action, $id);
5050
break;

Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function locateResource($name/*, $dir = null, $first = true, $triggerDepr
262262
$bundleName = substr($name, 1);
263263
$path = '';
264264
if (false !== strpos($bundleName, '/')) {
265-
list($bundleName, $path) = explode('/', $bundleName, 2);
265+
[$bundleName, $path] = explode('/', $bundleName, 2);
266266
}
267267

268268
$isResource = 0 === strpos($path, 'Resources') && null !== $dir;
@@ -893,7 +893,7 @@ public function serialize()
893893
public function unserialize($data)
894894
{
895895
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3.', __METHOD__), \E_USER_DEPRECATED);
896-
list($environment, $debug) = unserialize($data, ['allowed_classes' => false]);
896+
[$environment, $debug] = unserialize($data, ['allowed_classes' => false]);
897897

898898
$this->__construct($environment, $debug);
899899
}

Profiler/FileProfilerStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null, $st
6161
$result = [];
6262
while (\count($result) < $limit && $line = $this->readLineFromFile($file)) {
6363
$values = str_getcsv($line);
64-
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values;
64+
[$csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode] = $values;
6565
$csvTime = (int) $csvTime;
6666

6767
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method) || $statusCode && false === strpos($csvStatusCode, $statusCode)) {

Tests/DependencyInjection/ControllerArgumentValueResolverPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testServicesAreOrderedAccordingToPriority()
3939
$container = new ContainerBuilder();
4040
$container->setDefinition('argument_resolver', $definition);
4141

42-
foreach ($services as $id => list($tag)) {
42+
foreach ($services as $id => [$tag]) {
4343
$container->register($id)->addTag('controller.argument_value_resolver', $tag);
4444
}
4545

@@ -72,7 +72,7 @@ public function testInDebugWithStopWatchDefinition()
7272
$container->register('debug.stopwatch', Stopwatch::class);
7373
$container->setDefinition('argument_resolver', $definition);
7474

75-
foreach ($services as $id => list($tag)) {
75+
foreach ($services as $id => [$tag]) {
7676
$container->register($id)->addTag('controller.argument_value_resolver', $tag);
7777
}
7878

Tests/HttpCache/StoreTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testSetsTheXContentDigestResponseHeaderBeforeStoring()
9292
{
9393
$cacheKey = $this->storeSimpleEntry();
9494
$entries = $this->getStoreMetadata($cacheKey);
95-
list(, $res) = $entries[0];
95+
[, $res] = $entries[0];
9696

9797
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]);
9898
}
@@ -103,7 +103,7 @@ public function testDoesNotTrustXContentDigestFromUpstream()
103103

104104
$cacheKey = $this->store->write($this->request, $response);
105105
$entries = $this->getStoreMetadata($cacheKey);
106-
list(, $res) = $entries[0];
106+
[, $res] = $entries[0];
107107

108108
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $res['x-content-digest'][0]);
109109
$this->assertEquals('en9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', $response->headers->get('X-Content-Digest'));

Tests/HttpCache/TestHttpKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public function assert(\Closure $callback)
4343
{
4444
$trustedConfig = [Request::getTrustedProxies(), Request::getTrustedHeaderSet()];
4545

46-
list($trustedProxies, $trustedHeaderSet, $backendRequest) = $this->backendRequest;
46+
[$trustedProxies, $trustedHeaderSet, $backendRequest] = $this->backendRequest;
4747
Request::setTrustedProxies($trustedProxies, $trustedHeaderSet);
4848

4949
try {
5050
$callback($backendRequest);
5151
} finally {
52-
list($trustedProxies, $trustedHeaderSet) = $trustedConfig;
52+
[$trustedProxies, $trustedHeaderSet] = $trustedConfig;
5353
Request::setTrustedProxies($trustedProxies, $trustedHeaderSet);
5454
}
5555
}

0 commit comments

Comments
 (0)