Problem/Motivation
There are still instances of " array(" in the core that are not detected by the sniff. Many of these are in strings. These instances should be replaced as far as possible by the short array syntax []
.
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
- 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.
- core/lib/Drupal/Core/Template/TwigNodeTrans.php
- core/modules/system/tests/src/Functional/Form/FormTest.php. Not sure if it should be changed.
- core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
- core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php
- core/tests/Drupal/Tests/Component/Utility/VariableTest.php. Not changed because it is used PHP
var_export
which still uses long array syntax. - core/tests/Drupal/Tests/ComposerIntegrationTest.php. Like YamlFileLoader this is ignored for the same reason but it is also out of sync.
- core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml
Remaining tasks
Review
Commit