mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
fix: Remove trailing spaces from empty docblock lines (#30)
When DocBlock text contains empty lines, str_replace replaces each newline with a newline followed by ' * ', producing ' * ' (with trailing space) for empty lines. This triggers trailing-whitespace linters. Added a preg_replace after each str_replace call to strip trailing horizontal whitespace from lines that consist only of ' *' followed by spaces.
This commit is contained in:
@@ -206,6 +206,7 @@ class Serializer
|
|||||||
$text = wordwrap($text, $wrapLength);
|
$text = wordwrap($text, $wrapLength);
|
||||||
}
|
}
|
||||||
$text = str_replace("\n", "\n{$indent} * ", $text);
|
$text = str_replace("\n", "\n{$indent} * ", $text);
|
||||||
|
$text = preg_replace('/^(\s*\*)[ \t]+$/m', '$1', $text);
|
||||||
|
|
||||||
$comment = !empty($text)? "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n" : "{$firstIndent}/**\n";
|
$comment = !empty($text)? "{$firstIndent}/**\n{$indent} * {$text}\n{$indent} *\n" : "{$firstIndent}/**\n";
|
||||||
|
|
||||||
@@ -220,6 +221,7 @@ class Serializer
|
|||||||
$tagText = wordwrap($tagText, $wrapLength);
|
$tagText = wordwrap($tagText, $wrapLength);
|
||||||
}
|
}
|
||||||
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||||
|
$tagText = preg_replace('/^(\s*\*)[ \t]+$/m', '$1', $tagText);
|
||||||
|
|
||||||
$comment .= "{$indent} * {$tagText}\n";
|
$comment .= "{$indent} * {$tagText}\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user