Remove remaining instances of short array syntax

Created on 23 January 2025, 5 days ago

Problem/Motivation

There are still instances of " array(" in the core that are not detected by the sniff. Many of these are in strings.

Steps to reproduce

(11.x)$ git grep -r "\barray(" *  | awk -F: '{print $1}' | sort -u | grep -v drupal6 | grep -v drupal7 | grep -v 'Component/Annotation/Doctrine' | nl
     1  core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
     2  core/lib/Drupal/Core/Template/TwigNodeTrans.php
     3  core/modules/system/tests/src/Functional/Form/FormTest.php
     4  core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
     5  core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php
     6  core/tests/Drupal/Tests/Component/Utility/VariableTest.php
     7  core/tests/Drupal/Tests/ComposerIntegrationTest.php
     8  core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml

Proposed resolution

  1. core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php. This is deliberately ignored by phpcs to "simplify future synchronizations". A comment says "98% of this code is a literal copy of Symfony's YamlFileLoader " but comparing the two file this doesn't seem to be true anymore. Since the Symfony version doesn't use use long array syntax, so these are changed.
  2. core/lib/Drupal/Core/Template/TwigNodeTrans.php
  3. core/modules/system/tests/src/Functional/Form/FormTest.php. Not sure if it should be changed.
  4. core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
  5. core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php
  6. core/tests/Drupal/Tests/Component/Utility/VariableTest.php. Not changed because it is used PHP var_export which still uses long array syntax.
  7. core/tests/Drupal/Tests/ComposerIntegrationTest.php. Like YamlFileLoader this is ignored for the same reason but it is also out of sync.
  8. core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

other

Created by

πŸ‡³πŸ‡ΏNew Zealand quietone

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024