Skip to content

Commit 363d370

Browse files
committed
Fix tags parser
Fix tags parser when there's a blank line between tags.
1 parent 7b010e2 commit 363d370

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/Docblock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function parseTags(string $tags): void {
184184
foreach (explode("\n", $tags) as $line) {
185185
if ($this->isTagLine($line) || count($result) == 0) {
186186
$result[] = $line;
187-
} else {
187+
} elseif ($line !== '') {
188188
$result[count($result) - 1] .= "\n" . $line;
189189
}
190190
}

tests/DocblockTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,20 @@ public function testRemoveTag(): void {
201201
$this->assertTrue($docblock->hasTag('see'));
202202
$this->assertFalse($docblock->hasTag('since'));
203203
}
204+
205+
public function testDocblockWithBlankLines(): void {
206+
$text = '/**
207+
* @param string $foo makes a fow
208+
*
209+
* @return bool true on success and false if it fails
210+
*/';
211+
$docblock = new Docblock($text);
212+
$tags = $docblock->getTags();
213+
214+
$this->assertEquals(2, $tags->size());
215+
$this->assertInstanceOf(ParamTag::class, $tags->get(0));
216+
$this->assertEquals('makes a fow', $tags->get(0)->getDescription());
217+
$this->assertInstanceOf(ReturnTag::class, $tags->get(1));
218+
$this->assertEquals('true on success and false if it fails', $tags->get(1)->getDescription());
219+
}
204220
}

0 commit comments

Comments
 (0)