diff --git a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php index c16f7d75da22ae04fe52576890e89cc6791f2773..77ac5cfdcec7ec3d3fd67709610495e26fe25416 100644 --- a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php +++ b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php @@ -298,12 +298,12 @@ private function parseDefinition(string $id, $service, string $file, array $defa if (is_string($service['factory'])) { if (str_contains($service['factory'], ':') && !str_contains($service['factory'], '::')) { $parts = explode(':', $service['factory']); - $definition->setFactory(array($this->resolveServices('@'.$parts[0]), $parts[1])); + $definition->setFactory([$this->resolveServices('@'.$parts[0]), $parts[1]]); } else { $definition->setFactory($service['factory']); } } else { - $definition->setFactory(array($this->resolveServices($service['factory'][0]), $service['factory'][1])); + $definition->setFactory([$this->resolveServices($service['factory'][0]), $service['factory'][1]]); } } @@ -335,7 +335,7 @@ private function parseDefinition(string $id, $service, string $file, array $defa if (is_string($service['configurator'])) { $definition->setConfigurator($service['configurator']); } else { - $definition->setConfigurator(array($this->resolveServices($service['configurator'][0]), $service['configurator'][1])); + $definition->setConfigurator([$this->resolveServices($service['configurator'][0]), $service['configurator'][1]]); } } @@ -347,10 +347,10 @@ private function parseDefinition(string $id, $service, string $file, array $defa foreach ($service['calls'] as $call) { if (isset($call['method'])) { $method = $call['method']; - $args = isset($call['arguments']) ? $this->resolveServices($call['arguments']) : array(); + $args = isset($call['arguments']) ? $this->resolveServices($call['arguments']) : []; } else { $method = $call[0]; - $args = isset($call[1]) ? $this->resolveServices($call[1]) : array(); + $args = isset($call[1]) ? $this->resolveServices($call[1]) : []; } $definition->addMethodCall($method, $args); @@ -476,7 +476,7 @@ private function validate($content, $file) throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); } - if ($invalid_keys = array_keys(array_diff_key($content, array('parameters' => 1, 'services' => 1)))) { + if ($invalid_keys = array_keys(array_diff_key($content, ['parameters' => 1, 'services' => 1]))) { throw new InvalidArgumentException(sprintf('The service file "%s" is not valid: it contains invalid root key(s) "%s". Services have to be added under "services" and Parameters under "parameters".', $file, implode('", "', $invalid_keys))); } @@ -522,7 +522,7 @@ private function resolveServices(mixed $value): mixed } if (is_array($value)) { - $value = array_map(array($this, 'resolveServices'), $value); + $value = array_map([$this, 'resolveServices'], $value); } elseif (is_string($value) && str_starts_with($value, '@=')) { // Not supported. //return new Expression(substr($value, 2)); diff --git a/core/lib/Drupal/Core/Template/TwigNodeTrans.php b/core/lib/Drupal/Core/Template/TwigNodeTrans.php index 801fd7ec48a16b946ccda4d0647bcb5d4e913efa..799c3d82924767d0f486cb4da1b8c9d5d8731773 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeTrans.php +++ b/core/lib/Drupal/Core/Template/TwigNodeTrans.php @@ -80,11 +80,11 @@ public function compile(Compiler $compiler) { // Write any tokens found as an associative array parameter, otherwise just // leave as an empty array. - $compiler->raw(', array('); + $compiler->raw(', ['); foreach ($tokens as $token) { $compiler->string($token->getAttribute('placeholder'))->raw(' => ')->subcompile($token)->raw(', '); } - $compiler->raw(')'); + $compiler->raw(']'); // Write any options passed. if ($this->hasNode('options')) { diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php index 1a9686cf8cd72c090bea1291fbdf2abe9dec125e..2a0e45a36a010fbba34a0ab8230ae2be60eea0b6 100644 --- a/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php @@ -53,7 +53,7 @@ public function testDiscoveryInterface(): void { } // Ensure that an empty array is returned if no plugin definitions are found. - $this->assertSame([], $this->emptyDiscovery->getDefinitions(), 'array() returned if no plugin definitions are found.'); + $this->assertSame([], $this->emptyDiscovery->getDefinitions(), 'Empty array returned if no plugin definitions are found.'); // Ensure that NULL is returned as the definition of a non-existing plugin. $this->assertNull($this->emptyDiscovery->getDefinition('non_existing', FALSE), 'NULL returned as the definition of a non-existing plugin.'); diff --git a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php index 7d8b28ef37ed95c124bc5fe9c6bcf42de1fa7a14..13451b9e364ae74824dc89f311e16fb0a058f2f7 100644 --- a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php @@ -51,7 +51,7 @@ public function testDrupalRewriteSettings(): void { EXPECTED ], [ - 'original' => '$no_index_value_array = array("old" => "value");', + 'original' => '$no_index_value_array = ["old" => "value"];', 'settings' => [ 'no_index_value_array' => (object) [ 'value' => FALSE, @@ -59,7 +59,7 @@ public function testDrupalRewriteSettings(): void { 'comment' => 'comment', ], ], - 'expected' => '$no_index_value_array = array("old" => "value"); + 'expected' => '$no_index_value_array = ["old" => "value"]; $no_index_value_array = false; // comment', ], [ diff --git a/core/tests/Drupal/Tests/ComposerIntegrationTest.php b/core/tests/Drupal/Tests/ComposerIntegrationTest.php index 10f9bb0774daea88d6bbf3f2429a154fab678b2b..69e3517e775397d35e67adac5509d58acb9a220a 100644 --- a/core/tests/Drupal/Tests/ComposerIntegrationTest.php +++ b/core/tests/Drupal/Tests/ComposerIntegrationTest.php @@ -221,7 +221,7 @@ protected static function getContentHash($composerFileContents): string { $content = json_decode($composerFileContents, true); - $relevantKeys = array( + $relevantKeys = [ 'name', 'version', 'require', @@ -233,9 +233,9 @@ protected static function getContentHash($composerFileContents): string 'prefer-stable', 'repositories', 'extra', - ); + ]; - $relevantContent = array(); + $relevantContent = []; foreach (array_intersect($relevantKeys, array_keys($content)) as $key) { $relevantContent[$key] = $content[$key]; diff --git a/core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml b/core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml index 3a6f25186fd6cc34c76153395a4950f7f475c329..0f27e4e4ec4decb307550d562c5bea2754990721 100644 --- a/core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml +++ b/core/tests/Drupal/Tests/Core/Test/fixtures/phpunit_error.xml @@ -20,19 +20,19 @@ Undefined index: foo <testsuite name="Drupal\Tests\Core\Route\RoleAccessCheckTest" file="/var/www/d8/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTestTest.php" namespace="Drupal\Tests\Core\Route" fullPackage="Drupal.Tests.Core.Route" tests="3" assertions="3" failures="3" errors="0" time="0.009176"> <testsuite name="Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess" tests="3" assertions="3" failures="3" errors="0" time="0.009176"> <testcase name="testRoleAccess with data set #0" assertions="1" time="0.004519"> - <failure type="PHPUnit_Framework_ExpectationFailedException">Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess with data set #0 ('role_test_1', array(Drupal\user\Entity\User, Drupal\user\Entity\User)) + <failure type="PHPUnit_Framework_ExpectationFailedException">Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess with data set #0 ('role_test_1', [Drupal\user\Entity\User, Drupal\user\Entity\User]) Access granted for user with the roles role_test_1 on path: role_test_1 Failed asserting that false is true. </failure> </testcase> <testcase name="testRoleAccess with data set #1" assertions="1" time="0.002354"> - <failure type="PHPUnit_Framework_ExpectationFailedException">Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess with data set #1 ('role_test_2', array(Drupal\user\Entity\User, Drupal\user\Entity\User)) + <failure type="PHPUnit_Framework_ExpectationFailedException">Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess with data set #1 ('role_test_2', [Drupal\user\Entity\User, Drupal\user\Entity\User]) Access granted for user with the roles role_test_2 on path: role_test_2 Failed asserting that false is true. </failure> </testcase> <testcase name="testRoleAccess with data set #2" assertions="1" time="0.002303"> - <failure type="PHPUnit_Framework_ExpectationFailedException">Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess with data set #2 ('role_test_3', array(Drupal\user\Entity\User)) + <failure type="PHPUnit_Framework_ExpectationFailedException">Drupal\Tests\Core\Route\RoleAccessCheckTest::testRoleAccess with data set #2 ('role_test_3', [Drupal\user\Entity\User]) Access granted for user with the roles role_test_1, role_test_2 on path: role_test_3 Failed asserting that false is true. </failure>