Skip to content

Commit befd688

Browse files
committed
bug PHP-CS-Fixer#4690 PhpdocVarAnnotationCorrectOrderFixer - fix for multiline @var without type (kubawerlos)
This PR was squashed before being merged into the 2.15 branch (closes PHP-CS-Fixer#4690). Discussion ---------- PhpdocVarAnnotationCorrectOrderFixer - fix for multiline `@var` without type Commits ------- 4e435e0 PhpdocVarAnnotationCorrectOrderFixer - fix for multiline `@var` without type
2 parents e1d4488 + 4e435e0 commit befd688

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Fixer/Phpdoc/PhpdocVarAnnotationCorrectOrderFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
5252
}
5353

5454
$newContent = Preg::replace(
55-
'/(@(?:type|var)\s*)(\$\S+)(\s+)([^\$](?:[^<\s]|<[^>]*>)*)(\s|\*)/i',
55+
'/(@(?:type|var)\s*)(\$\S+)(\h+)([^\$](?:[^<\s]|<[^>]*>)*)(\s|\*)/i',
5656
'$1$4$3$2$5',
5757
$token->getContent()
5858
);

tests/Fixer/Phpdoc/PhpdocVarAnnotationCorrectOrderFixerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,17 @@ public function provideFixCases()
161161
/** @var $foo Foo|array<int, int>|null */
162162
',
163163
];
164+
165+
yield [
166+
'<?php
167+
class Foo
168+
{
169+
/**
170+
* @var $bar
171+
*/
172+
private $bar;
173+
}
174+
',
175+
];
164176
}
165177
}

0 commit comments

Comments
 (0)