diff --git a/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php b/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php index f11fec8a4b1..ab6a7ff53ef 100644 --- a/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php +++ b/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php @@ -132,8 +132,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens) // fix @method parameters types $line = $doc->getLine($annotation->getStart()); $line->setContent(Preg::replaceCallback('/(@method\s+.+?\s+\w+\()(.*)\)/', function (array $matches) { - $sorted = Preg::replaceCallback('/((?:^|,)\s*)([^\s]+)/', function (array $matches) { - return $matches[1].$this->sortJoinedTypes($matches[2]); + $sorted = Preg::replaceCallback('/([^\s,]+)([\s]+\$[^\s,]+)/', function (array $matches) { + return $this->sortJoinedTypes($matches[1]).$matches[2]; }, $matches[2]); return $matches[1].$sorted.')'; diff --git a/tests/Fixer/Phpdoc/PhpdocTypesOrderFixerTest.php b/tests/Fixer/Phpdoc/PhpdocTypesOrderFixerTest.php index 0d99aa932b0..d2be9ed8721 100644 --- a/tests/Fixer/Phpdoc/PhpdocTypesOrderFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocTypesOrderFixerTest.php @@ -141,6 +141,10 @@ public function provideFixCases() '\') */', + '\') */', + ], ]; }