Repository: PHP-CS-Fixer/PHP-CS-Fixer (PHP)

Issue:
Two passes needed for array_syntax+ single_space_around_construct
## Bug report

### Description

Two passes may be required if we use both `ArraySyntaxFixer` and `SingleSpaceAroundConstructFixer`.

### Runtime version

```
PHP CS Fixer 3.26.1 Crank Cake by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 7.4.33
```

### Configuration file

```php
<?php

$config = new PhpCsFixer\Config();

return $config
    ->setRules([
        'array_syntax' => true,
        'single_space_around_construct' => true,
    ])
    ->setFinder(PhpCsFixer\Finder::create()
        ->in(__DIR__)
    )
;
```

### Code snippet that reproduces the problem

Let's assume we have this file:

```php
<?php

function foo()
{
    return array // bar
    (
        1,
    );
}
```

At the first pass, `ArraySyntaxFixer` changes it to

```php
<?php

function foo()
{
    return  // bar
    [
        1,
    ];
}
```

(please remark that there are two spaces before the comment)

At the second pass, `SingleSpaceAroundConstructFixer` changes it to

```php
<?php

function foo()
{
    return // bar
    [
        1,
    ];
}
```



Fix (patch):
diff --git a/src/Fixer/ArrayNotation/ArraySyntaxFixer.php b/src/Fixer/ArrayNotation/ArraySyntaxFixer.php
index f762d99a39e..a7b0b20f6e3 100644
--- a/src/Fixer/ArrayNotation/ArraySyntaxFixer.php
+++ b/src/Fixer/ArrayNotation/ArraySyntaxFixer.php
@@ -70,11 +70,11 @@ public function getDefinition(): FixerDefinitionInterface
     /**
      * {@inheritdoc}
      *
-     * Must run before BinaryOperatorSpacesFixer, TernaryOperatorSpacesFixer.
+     * Must run before BinaryOperatorSpacesFixer, SingleSpaceAfterConstructFixer, SingleSpaceAroundConstructFixer, TernaryOperatorSpacesFixer.
      */
     public function getPriority(): int
     {
-        return 1;
+        return 37;
     }
 
     public function isCandidate(Tokens $tokens): bool
diff --git a/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php b/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php
index 89986cd60f4..229049a32e0 100644
--- a/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php
+++ b/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php
@@ -168,7 +168,7 @@ public function getDefinition(): FixerDefinitionInterface
      * {@inheritdoc}
      *
      * Must run before BracesFixer, FunctionDeclarationFixer.
-     * Must run after ModernizeStrposFixer.
+     * Must run after ArraySyntaxFixer, ModernizeStrposFixer.
      */
     public function getPriority(): int
     {
diff --git a/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php b/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php
index afcfbafd880..29d395f998f 100644
--- a/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php
+++ b/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php
@@ -256,7 +256,7 @@ function foo() { yield  from  baz(); }
      * {@inheritdoc}
      *
      * Must run before BracesFixer, FunctionDeclarationFixer, NullableTypeDeclarationFixer.
-     * Must run after ModernizeStrposFixer.
+     * Must run after ArraySyntaxFixer, ModernizeStrposFixer.
      */
     public function getPriority(): int
     {