Skip to content

Commit

Permalink
bug #5630 PhpdocTypesOrderFixer - handle complex keys (Leprechaunz)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.18 branch.

Discussion
----------

PhpdocTypesOrderFixer - handle complex keys

Fixes #5116

Commits
-------

f0337f4 PhpdocTypesOrderFixer - handle complex keys
  • Loading branch information
keradus committed Apr 16, 2021
2 parents 29b3a89 + f0337f4 commit c990a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
private function sortTypes(array $types)
{
foreach ($types as $index => $type) {
$types[$index] = Preg::replaceCallback('/^([^<]+)<(?:([\w\|]+?)(,\s*))?(.*)>$/', function (array $matches) {
$types[$index] = Preg::replaceCallback('/^([^<]+)<(?:([\w\|]+?|<?.*>)(,\s*))?(.*)>$/', function (array $matches) {
return $matches[1].'<'.$this->sortJoinedTypes($matches[2]).$matches[3].$this->sortJoinedTypes($matches[4]).'>';
}, $type);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Fixer/Phpdoc/PhpdocTypesOrderFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ public function provideFixCases()
'<?php /** @method void bar(null|string $delimiter = \',<br/>\') */',
'<?php /** @method void bar(string|null $delimiter = \',<br/>\') */',
],
[
'<?php /** @var array<array<int, int>, OutputInterface> */',
],
];
}

Expand Down

0 comments on commit c990a13

Please sign in to comment.