Skip to content

Commit

Permalink
bug #4690 PhpdocVarAnnotationCorrectOrderFixer - fix for multiline `@…
Browse files Browse the repository at this point in the history
…var` without type (kubawerlos)

This PR was squashed before being merged into the 2.15 branch (closes #4690).

Discussion
----------

PhpdocVarAnnotationCorrectOrderFixer - fix for multiline `@var` without type

Commits
-------

4e435e0 PhpdocVarAnnotationCorrectOrderFixer - fix for multiline `@var` without type
  • Loading branch information
julienfalque committed Dec 9, 2019
2 parents e1d4488 + 4e435e0 commit befd688
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocVarAnnotationCorrectOrderFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
}

$newContent = Preg::replace(
'/(@(?:type|var)\s*)(\$\S+)(\s+)([^\$](?:[^<\s]|<[^>]*>)*)(\s|\*)/i',
'/(@(?:type|var)\s*)(\$\S+)(\h+)([^\$](?:[^<\s]|<[^>]*>)*)(\s|\*)/i',
'$1$4$3$2$5',
$token->getContent()
);
Expand Down
12 changes: 12 additions & 0 deletions tests/Fixer/Phpdoc/PhpdocVarAnnotationCorrectOrderFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,17 @@ public function provideFixCases()
/** @var $foo Foo|array<int, int>|null */
',
];

yield [
'<?php
class Foo
{
/**
* @var $bar
*/
private $bar;
}
',
];
}
}

0 comments on commit befd688

Please sign in to comment.