File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed
Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ protected function createDescription(?string $description): ?Description
3131 return null ;
3232 }
3333
34+ public function setDescriptionFactory (?DescriptionFactoryInterface $ factory ): void
35+ {
36+ $ this ->descriptions = $ factory ;
37+ }
38+
3439 public function withDescriptionFactory (?DescriptionFactoryInterface $ factory ): self
3540 {
3641 $ self = clone $ this ;
Original file line number Diff line number Diff line change 44
55namespace TypeLang \PhpDocParser \DocBlock ;
66
7+ use TypeLang \PhpDocParser \Description \DescriptionFactoryInterface ;
78use TypeLang \PhpDocParser \DocBlock \Extractor \TagNameExtractor ;
89use TypeLang \PhpDocParser \DocBlock \Tag \GenericTag ;
910use TypeLang \PhpDocParser \DocBlock \Tag \InvalidTag ;
@@ -27,15 +28,17 @@ final class TagFactorySelector extends TagFactory
2728 /**
2829 * @param iterable<non-empty-string, TagFactoryInterface> $factories
2930 */
30- public function __construct (iterable $ factories = [])
31- {
31+ public function __construct (
32+ iterable $ factories = [],
33+ ?DescriptionFactoryInterface $ descriptions = null ,
34+ ) {
3235 $ this ->parts = new TagNameExtractor ();
3336
3437 foreach ($ factories as $ name => $ factory ) {
3538 $ this ->add ($ factory , $ name );
3639 }
3740
38- parent ::__construct ();
41+ parent ::__construct ($ descriptions );
3942 }
4043
4144 /**
@@ -81,7 +84,10 @@ public function create(string $tag): TagInterface
8184 return new GenericTag ($ name );
8285 }
8386
84- return new GenericTag ($ name , $ this ->createDescription ($ body ));
87+ return new GenericTag (
88+ name: $ name ,
89+ description: $ this ->createDescription ($ body ),
90+ );
8591 }
8692
8793 private function getFactory (string $ tag ): ?TagFactoryInterface
Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ public function __construct(
2929
3030 public static function createInstance (?Parser $ parser = null ): self
3131 {
32- $ tags = new TagFactorySelector ();
32+ $ descriptions = new DescriptionFactory (
33+ tags: $ tags = new TagFactorySelector (),
34+ );
3335
34- $ descriptions = new DescriptionFactory ( $ tags );
36+ $ tags -> setDescriptionFactory ( $ descriptions );
3537
3638 // Load standard tags
3739 $ provider = new StandardTagProvider ($ parser ?? new Parser (true ));
You can’t perform that action at this time.
0 commit comments