Verified Commit 523cbdf6 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3501866 by quietone, oily: Remove remaining instances of the array language construct

parent 0c23c746
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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));
+2 −2
Original line number Diff line number Diff line
@@ -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')) {
+1 −1
Original line number Diff line number Diff line
@@ -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.');
+2 −2
Original line number Diff line number Diff line
@@ -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',
      ],
      [
+3 −3
Original line number Diff line number Diff line
@@ -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];
Loading