1212use function array_merge ;
1313use function in_array ;
1414use function is_array ;
15+ use function preg_match ;
16+ use function preg_replace ;
1517use function preg_split ;
1618use function str_replace ;
17- use function preg_replace ;
18- use function preg_match ;
1919use function substr ;
2020use function trim ;
21- use const PREG_SPLIT_NO_EMPTY ;
2221use const PREG_OFFSET_CAPTURE ;
22+ use const PREG_SPLIT_NO_EMPTY ;
2323
2424/**
2525 * Class PhpDoc
@@ -36,11 +36,14 @@ class PhpDoc
3636 * Parses the comment block into tags.
3737 *
3838 * @param string $comment The comment block text
39- * @param array $options
39+ * @param array $options
4040 * - 'allow' // only allowed tags
41+ * - 'multi' // allowed multi tag names
4142 * - 'ignore' // ignored tags
4243 * - 'default' => 'description', // default tag name, first line text will attach to it.
4344 *
45+ * @psalm-param array{allow: array, multi: array, ignore: array, default: string} $options
46+ *
4447 * @return array The parsed tags
4548 */
4649 public static function getTags (string $ comment , array $ options = []): array
@@ -51,16 +54,22 @@ public static function getTags(string $comment, array $options = []): array
5154
5255 $ options = array_merge ([
5356 'allow ' => [], // only allowed tags
54- 'ignore ' => ['param ' , 'return ' ], // ignore tags
57+ 'multi ' => [], // allowed multi tags
58+ 'ignore ' => ['param ' , 'return ' ], // ignored tags
5559 'default ' => 'description ' , // default tag name, first line text will attach to it.
5660 ], $ options );
5761
58- $ allow = (array )$ options ['allow ' ];
62+ $ multi = (array )$ options ['multi ' ];
63+ $ allowed = (array )$ options ['allow ' ];
5964 $ ignored = (array )$ options ['ignore ' ];
6065 $ default = (string )$ options ['default ' ];
6166
6267 $ comment = str_replace ("\r\n" , "\n" , $ comment );
63- $ comment = "@ {$ default } \n" . str_replace ("\r" , '' , trim (preg_replace ('/^\s*\**( |\t)?/m ' , '' , $ comment )));
68+ $ comment = "@ $ default \n" . str_replace (
69+ "\r" ,
70+ '' ,
71+ trim (preg_replace ('/^\s*\**( |\t)?/m ' , '' , $ comment ))
72+ );
6473
6574 $ tags = [];
6675 $ parts = preg_split ('/^\s*@/m ' , $ comment , -1 , PREG_SPLIT_NO_EMPTY );
@@ -73,7 +82,7 @@ public static function getTags(string $comment, array $options = []): array
7382 }
7483
7584 // always allow default tag
76- if ($ default !== $ name && $ allow && !in_array ($ name , $ allow , true )) {
85+ if ($ default !== $ name && $ allowed && !in_array ($ name , $ allowed , true )) {
7786 continue ;
7887 }
7988
0 commit comments