10000 minor #38858 Use short array deconstruction syntax (derrabus) · Nek-/symfony@2fb61a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fb61a4

Browse files
committed
minor symfony#38858 Use short array deconstruction syntax (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- Use short array deconstruction syntax | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Now that the support for the 3.4 branch is coming to an end, I think we should consider banning a relic from old php 5 times from our codebase: The old array deconstructor `list()`. Right now, both deconstructors `list()` and `[]` are being used, with `list()` being the more common one. The changes in this PR were done with PHP CS Fixer and I can easily redo them later if we decide that the time of this PR hasn't come yet. 😃 Commits ------- 659decf Use short array deconstruction syntax.
2 parents 051cf5f + 659decf commit 2fb61a4

File tree

106 files changed

+215
-214
lines changed
  • WebProfilerBundle/Profiler
  • WebServerBundle/Command
  • Component
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    106 files changed

    +215
    -214
    lines changed

    .php_cs.dist

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -15,6 +15,7 @@ return PhpCsFixer\Config::create()
    1515
    'protected_to_private' => false,
    1616
    'native_constant_invocation' => true,
    1717
    'combine_nested_dirname' => true,
    18+
    'list_syntax' => ['syntax' => 'short'],
    1819
    ])
    1920
    ->setRiskyAllowed(true)
    2021
    ->setFinder(

    src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -195,7 +195,7 @@ private function sanitizeQuery(string $connectionName, array $query): array
    195195
    }
    196196
    }
    197197

    198-
    list($query['params'][$j], $explainable, $runnable) = $this->sanitizeParam($param, $e);
    198+
    [$query['params'][$j], $explainable, $runnable] = $this->sanitizeParam($param, $e);
    199199
    if (!$explainable) {
    200200
    $query['explainable'] = fal D7AE se;
    201201
    }
    @@ -231,7 +231,7 @@ private function sanitizeParam($var, ?\Throwable $error): array
    231231
    $a = [];
    232232
    $explainable = $runnable = true;
    233233
    foreach ($var as $k => $v) {
    234-
    list($value, $e, $r) = $this->sanitizeParam($v, null);
    234+
    [$value, $e, $r] = $this->sanitizeParam($v, null);
    235235
    $explainable = $explainable && $e;
    236236
    $runnable = $runnable && $r;
    237237
    $a[$k] = $value;

    src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -65,7 +65,7 @@ private function addTaggedSubscribers(ContainerBuilder $container)
    6565
    $taggedSubscribers = $this->findAndSortTags($subscriberTag, $container);
    6666

    6767
    foreach ($taggedSubscribers as $taggedSubscriber) {
    68-
    list($id, $tag) = $taggedSubscriber;
    68+
    [$id, $tag] = $taggedSubscriber;
    6969
    $connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
    7070
    foreach ($connections as $con) {
    7171
    if (!isset($this->connections[$con])) {
    @@ -84,7 +84,7 @@ private function addTaggedListeners(ContainerBuilder $container)
    8484
    $listenerRefs = [];
    8585

    8686
    foreach ($taggedListeners as $taggedListener) {
    87-
    list($id, $tag) = $taggedListener;
    87+
    [$id, $tag] = $taggedListener;
    8888
    if (!isset($tag['event'])) {
    8989
    throw new InvalidArgumentException(sprintf('Doctrine event listener "%s" must specify the "event" attribute.', $id));
    9090
    }

    src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -49,7 +49,7 @@ public function guessType($class, $property)
    4949
    return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
    5050
    }
    5151

    52-
    list($metadata, $name) = $ret;
    52+
    [$metadata, $name] = $ret;
    5353

    5454
    if ($metadata->hasAssociation($property)) {
    5555
    $multiple = $metadata->isCollectionValuedAssociation($property);

    src/Symfony/Bridge/Monolog/Tests/LoggerTest.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -75,7 +75,7 @@ public function testGetLogsWithDebugProcessor2()
    7575

    7676
    $logger->info('test');
    7777
    $this->assertCount(1, $logger->getLogs());
    78-
    list($record) = $logger->getLogs();
    78+
    [$record] = $logger->getLogs();
    7979

    8080
    $this->assertEquals('test', $record['message']);
    8181
    $this->assertEquals(Logger::INFO, $record['priority']);

    src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -22,7 +22,7 @@ class WebProcessorTest extends TestCase
    2222
    {
    2323
    public function testUsesRequestServerData()
    2424
    {
    25-
    list($event, $server) = $this->createRequestEvent();
    25+
    [$event, $server] = $this->createRequestEvent();
    2626

    2727
    $processor = new WebProcessor();
    2828
    $processor->onKernelRequest($event);
    @@ -39,7 +39,7 @@ public function testUsesRequestServerData()
    3939
    public function testUseRequestClientIp()
    4040
    {
    4141
    Request::setTrustedProxies(['192.168.0.1'], Request::HEADER_X_FORWARDED_ALL);
    42-
    list($event, $server) = $this->createRequestEvent(['X_FORWARDED_FOR' => '192.168.0.2']);
    42+
    [$event, $server] = $this->createRequestEvent(['X_FORWARDED_FOR' => '192.168.0.2']);
    4343

    4444
    $processor = new WebProcessor();
    4545
    $processor->onKernelRequest($event);
    @@ -61,7 +61,7 @@ public function testCanBeConstructedWithExtraFields()
    6161
    $this->markTestSkipped('WebProcessor of the installed Monolog version does not support $extraFields parameter');
    6262
    10000 }
    6363

    64-
    list($event, $server) = $this->createRequestEvent();
    64+
    [$event, $server] = $this->createRequestEvent();
    6565

    6666
    $processor = new WebProcessor(['url', 'referrer']);
    6767
    $processor->onKernelRequest($event);

    src/Symfony/Bridge/Twig/Command/DebugCommand.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -161,7 +161,7 @@ private function displayPathsText(SymfonyStyle $io, string $name)
    161161
    $shortnames[] = str_replace('\\', '/', $file->getRelativePathname());
    162162
    }
    163163

    164-
    list($namespace, $shortname) = $this->parseTemplateName($name);
    164+
    [$namespace, $shortname] = $this->parseTemplateName($name);
    165165
    $alternatives = $this->findAlternatives($shortname, $shortnames);
    166166
    if (FilesystemLoader::MAIN_NAMESPACE !== $namespace) {
    167167
    $alternatives = array_map(function ($shortname) use ($namespace) {
    @@ -482,7 +482,7 @@ private function error(SymfonyStyle $io, string $message, array $alternatives =
    482482

    483483
    private function findTemplateFiles(string $name): array
    484484
    {
    485-
    list($namespace, $shortname) = $this->parseTemplateName($name);
    485+
    [$namespace, $shortname] = $this->parseTemplateName($name);
    486486

    487487
    $files = [];
    488488
    foreach ($this->getFilesystemLoaders() as $loader) {

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

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -72,7 +72,7 @@ public function abbrClass($class)
    7272
    public function abbrMethod($method)
    7373
    {
    7474
    if (false !== strpos($method, '::')) {
    75-
    list($class, $method) = explode('::', $method, 2);
    75+
    [$class, $method] = explode('::', $method, 2);
    7676
    $result = sprintf('%s::%s()', $this->abbrClass($class), $method);
    7777
    } elseif ('Closure' === $method) {
    7878
    $result = sprintf('<abbr title="%s">%1$s</abbr>', $method);

    src/Symfony/Bridge/Twig/Node/TransNode.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -60,7 +60,7 @@ public function compile(Compiler $compiler)
    6060
    $defaults = $this->getNode('vars');
    6161
    $vars = null;
    6262
    }
    63-
    list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
    63+
    [$msg, $defaults] = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
    6464

    6565
    $compiler
    6666
    ->write('echo $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans(')

    src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -58,7 +58,7 @@ public function parse($controller)
    5858
    }
    5959

    6060
    $originalController = $controller;
    61-
    list($bundleName, $controller, $action) = $parts;
    61+
    [$bundleName, $controller, $action] = $parts;
    6262
    $controller = str_replace('/', '\\', $controller);
    6363

    6464
    try {

    0 commit comments

    Comments
     (0)
    0