From d4732f118e574f8d409a811bbb2eb9fc4c88ae3e Mon Sep 17 00:00:00 2001 From: kkmuffme <11071985+kkmuffme@users.noreply.github.com> Date: Tue, 13 Jun 2023 22:04:39 +0200 Subject: [PATCH] fix minor trim bug in original code and small speed up --- src/Psalm/Internal/Scanner/DocblockParser.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Scanner/DocblockParser.php b/src/Psalm/Internal/Scanner/DocblockParser.php index 709dc936b..0c052346b 100644 --- a/src/Psalm/Internal/Scanner/DocblockParser.php +++ b/src/Psalm/Internal/Scanner/DocblockParser.php @@ -87,7 +87,9 @@ class DocblockParser if ($first_line_padding === null) { $asterisk_pos = strpos($line, '*'); - if ($asterisk_pos) { + if ($asterisk_pos === 0 || $asterisk_pos === 1) { + $first_line_padding = ''; + } elseif ($asterisk_pos > 1) { $first_line_padding = substr($line, 0, $asterisk_pos - 1); } } @@ -99,7 +101,7 @@ class DocblockParser [$type] = $type_info; [$data, $data_offset] = $data_info; - if (strpos($data, '*')) { + if (strpos($data, '*') !== false) { $data = rtrim(preg_replace('/^ *\*\s*$/m', '', $data)); }