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

Issue:
PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer removes only the first variable name
## Bug report
PHP version: 7.4
PHP CS Fixer 2.17.3 Desert Beast by Fabien Potencier and Dariusz Ruminski

Run via `https://github.com/symplify/easy-coding-standard`

Console output:
``` bash
13) FeedbackModalControl.php

    ---------- begin diff ----------
--- Original
+++ New
@@ -16,7 +16,7 @@
 {

     /**
-     * @var array<callable(string $feedback, FileUpload $screenshot): void>
+     * @var array<callable(string, FileUpload $screenshot): void>
      */
     public array $onSuccess = [];
    ----------- end diff -----------


Applied checkers:

 * PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer
```

Relevant source code:
```php
final class FeedbackModalControl extends Control
{

    /**
     * @var array<callable(string $feedback, FileUpload $screenshot): void>
     */
    public array $onSuccess = [];

}
```

Expected behavior:
Remove both variables.

Pull request description:
fix: Remove all variable names in `@var` callable signature
Fixes #5402.

Patch:
diff --git a/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php b/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php
index f2240105f..f42b2d9fe 100644
--- a/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php
+++ b/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php
@@ -114,12 +114,12 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
 
     private function fixLine(Line $line): void
     {
-        $content = $line->getContent();
+        Preg::matchAll('/ \$'.TypeExpression::REGEX_IDENTIFIER.'(?<!\$this)/', $line->getContent(), $matches);
 
-        Preg::matchAll('/ \$'.TypeExpression::REGEX_IDENTIFIER.'(?<!\$this)/', $content, $matches);
-
-        if (isset($matches[0][0])) {
-            $line->setContent(str_replace($matches[0][0], '', $content));
+        if (isset($matches[0])) {
+            foreach ($matches[0] as $match) {
+                $line->setContent(str_replace($match, '', $line->getContent()));
+            }
         }
     }
 


Test patch:
diff --git a/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php b/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php
index 19782bc33..f4c447bdb 100644
--- a/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php
+++ b/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php
@@ -595,6 +595,29 @@ class Foo
                 EOF
             ,
         ];
+
+        yield '@var with callable syntax' => [
+            <<<'EOF'
+                <?php
+
+                class Foo
+                {
+                    /** @var array<callable(string, Buzz): void> */
+                    protected $bar;
+                }
+                EOF
+            ,
+            <<<'EOF'
+                <?php
+
+                class Foo
+                {
+                    /** @var array<callable(string $baz, Buzz $buzz): void> */
+                    protected $bar;
+                }
+                EOF
+            ,
+        ];
     }
 
     /**