1818use TypeLang \PHPDoc \Parser \SourceMap ;
1919use TypeLang \PHPDoc \Parser \Tag \TagParser ;
2020use TypeLang \PHPDoc \Parser \Tag \TagParserInterface ;
21- use TypeLang \PHPDoc \Tag \MutableRepositoryInterface ;
22- use TypeLang \PHPDoc \Tag \Repository ;
23- use TypeLang \PHPDoc \Tag \RepositoryInterface ;
2421
2522/**
2623 * @psalm-suppress UndefinedAttributeClass : JetBrains language attribute may not be available
@@ -31,26 +28,13 @@ class DocBlockFactory implements DocBlockFactoryInterface
3128
3229 private readonly DescriptionParserInterface $ description ;
3330
34- private readonly MutableRepositoryInterface $ tags ;
31+ private readonly TagParserInterface $ tags ;
3532
36- private readonly TagParserInterface $ parser ;
37-
38- public function __construct (?RepositoryInterface $ tags = null )
33+ public function __construct ()
3934 {
4035 $ this ->comment = new LexerAwareCommentParser ();
4136 $ this ->description = new SprintfDescriptionReader ();
42-
43- $ this ->tags = $ this ->createRepository ($ tags );
44- $ this ->parser = new TagParser ($ this ->tags );
45- }
46-
47- private function createRepository (?RepositoryInterface $ tags ): MutableRepositoryInterface
48- {
49- if ($ tags instanceof MutableRepositoryInterface) {
50- return $ tags ;
51- }
52-
53- return new Repository ($ tags );
37+ $ this ->tags = new TagParser ();
5438 }
5539
5640 /**
@@ -61,7 +45,10 @@ public function create(#[Language('PHP')] string $docblock): DocBlock
6145 $ mapper = new SourceMap ();
6246
6347 try {
64- /** @var Segment $segment */
48+ /**
49+ * @var Segment $segment
50+ * @psalm-suppress InvalidIterator
51+ */
6552 foreach ($ result = $ this ->analyze ($ docblock ) as $ segment ) {
6653 $ mapper ->add ($ segment ->offset , $ segment ->text );
6754 }
@@ -91,6 +78,7 @@ public function create(#[Language('PHP')] string $docblock): DocBlock
9178 */
9279 private function analyze (string $ docblock ): \Generator
9380 {
81+ /** @psalm-suppress InvalidIterator */
9482 yield from $ blocks = $ this ->groupByCommentSections ($ docblock );
9583
9684 $ description = null ;
@@ -100,9 +88,9 @@ private function analyze(string $docblock): \Generator
10088 foreach ($ blocks ->getReturn () as $ block ) {
10189 try {
10290 if ($ description === null ) {
103- $ description = $ this ->description ->parse ($ block , $ this ->parser );
91+ $ description = $ this ->description ->parse ($ block , $ this ->tags );
10492 } else {
105- $ tags [] = $ this ->parser ->parse ($ block );
93+ $ tags [] = $ this ->tags ->parse ($ block, $ this -> description );
10694 }
10795 } catch (RuntimeExceptionInterface $ e ) {
10896 throw $ e ->withSource (
0 commit comments