Skip to content
This repository has been archived by the owner on Apr 24, 2021. It is now read-only.

Commit

Permalink
fix: parse comments tags error
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Feb 2, 2019
1 parent dc8d169 commit 6e4b249
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/PhpDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ public static function getTags(string $comment, array $options = []): array
'default' => 'description', // default tag name, first line text will attach to it.
], $options);

$allow = (array)$options['allow'];
$allow = (array)$options['allow'];
$ignored = (array)$options['ignore'];

// always allow default tag
if ($default = (string)$options['default']) {
$allow[] = $default;
}
$default = (string)$options['default'];

$comment = \str_replace("\r\n", "\n", $comment);
$comment = "@{$default} \n" .
Expand All @@ -59,11 +55,12 @@ public static function getTags(string $comment, array $options = []): array
foreach ($parts as $part) {
if (\preg_match('/^(\w+)(.*)/ms', \trim($part), $matches)) {
$name = $matches[1];
if (\in_array($name, $ignored, true)) {
if (!$name || \in_array($name, $ignored, true)) {
continue;
}

if ($allow && !\in_array($name, $allow, true)) {
// always allow default tag
if ($default !== $name && $allow && !\in_array($name, $allow, true)) {
continue;
}

Expand Down

0 comments on commit 6e4b249

Please sign in to comment.