From 700b4e071f2280b2f3a9b8e888de9332f8f598c0 Mon Sep 17 00:00:00 2001 From: isaackaara Date: Thu, 5 Mar 2026 14:30:11 +0300 Subject: [PATCH] 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. --- src/Barryvdh/Reflection/DocBlock/Serializer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Barryvdh/Reflection/DocBlock/Serializer.php b/src/Barryvdh/Reflection/DocBlock/Serializer.php index 46662b8..87ebac4 100644 --- a/src/Barryvdh/Reflection/DocBlock/Serializer.php +++ b/src/Barryvdh/Reflection/DocBlock/Serializer.php @@ -206,6 +206,7 @@ class Serializer $text = wordwrap($text, $wrapLength); } $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"; @@ -220,6 +221,7 @@ class Serializer $tagText = wordwrap($tagText, $wrapLength); } $tagText = str_replace("\n", "\n{$indent} * ", $tagText); + $tagText = preg_replace('/^(\s*\*)[ \t]+$/m', '$1', $tagText); $comment .= "{$indent} * {$tagText}\n";