Skip to content

Commit

Permalink
Simplify PhpdocSingleLineVarFixer (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Apr 8, 2024
1 parent 9bb6148 commit 5decc64
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Fixer/PhpdocSingleLineVarFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

if (!Preg::match('#^/\\*\\*[\\s\\*]+(@var[^\\r\\n]+)[\\s\\*]*\\*\\/$#u', $tokens[$index]->getContent(), $matches)) {
continue;
}

$var = $matches[1];
\assert(\is_string($var));

$newContent = '/** ' . \rtrim($var) . ' */';
$newContent = Preg::replace(
'#^/\\*\\*[\\s\\*]+(@var[^\\r\\n]+)(?<!\\s)[\\s\\*]*\\*\\/$#',
'/** $1 */',
$tokens[$index]->getContent(),
);

if ($newContent === $tokens[$index]->getContent()) {
continue;
Expand Down

0 comments on commit 5decc64

Please sign in to comment.