File tree Expand file tree Collapse file tree 4 files changed +9
-8
lines changed
Expand file tree Collapse file tree 4 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 55namespace TypeLang \PhpDocParser \DocBlock \Tag ;
66
77use TypeLang \Parser \Parser ;
8- use TypeLang \Parser \ParserInterface ;
98use TypeLang \PhpDocParser \DocBlock \DescriptionFactoryInterface ;
109use TypeLang \PhpDocParser \Exception \InvalidTagException ;
1110
Original file line number Diff line number Diff line change 44
55namespace TypeLang \PhpDocParser \DocBlock \Tag ;
66
7- use TypeLang \Parser \ParserInterface ;
7+ use TypeLang \Parser \Parser ;
88use TypeLang \PhpDocParser \DocBlock \DescriptionFactoryInterface ;
99use TypeLang \PhpDocParser \DocBlock \Extractor \TagVariableExtractor ;
1010use TypeLang \PhpDocParser \Exception \InvalidTagException ;
@@ -23,7 +23,7 @@ final class CommonTypedTagWithNameFactory extends TypedTagFactory
2323 */
2424 public function __construct (
2525 private readonly string $ class ,
26- ParserInterface $ parser ,
26+ private readonly Parser $ parser ,
2727 ?DescriptionFactoryInterface $ descriptions = null ,
2828 ) {
2929 $ this ->variables = new TagVariableExtractor ();
@@ -38,7 +38,7 @@ public function create(string $tag): TypedTag
3838 try {
3939 [$ variable , $ description ] = $ this ->variables ->extractOrFail ($ description );
4040 } catch (InvalidTagVariableNameException $ e ) {
41- $ offset = $ this ->types -> getTypeOffset ( $ type ) ;
41+ $ offset = $ this ->parser -> lastProcessedTokenOffset ;
4242
4343 throw InvalidTagVariableNameException::fromTyped ($ type , $ offset , $ e );
4444 }
Original file line number Diff line number Diff line change 55namespace TypeLang \PhpDocParser \DocBlock \Tag ;
66
77use TypeLang \Parser \Parser ;
8- use TypeLang \Parser \ParserInterface ;
98use TypeLang \PhpDocParser \DocBlock \DescriptionFactoryInterface ;
109use TypeLang \PhpDocParser \DocBlock \Extractor \TagTypeExtractor ;
1110
Original file line number Diff line number Diff line change 55namespace TypeLang \PhpDocParser ;
66
77use TypeLang \Parser \Parser ;
8- use TypeLang \Parser \ParserInterface ;
98use TypeLang \PhpDocParser \DocBlock \Description ;
109use TypeLang \PhpDocParser \DocBlock \DescriptionFactory ;
1110use TypeLang \PhpDocParser \DocBlock \DescriptionFactoryInterface ;
@@ -61,7 +60,7 @@ public function __construct(
6160 public readonly TagFactoryInterface $ tags ,
6261 ) {}
6362
64- public static function createInstance (?ParserInterface $ parser = null ): self
63+ public static function createInstance (?Parser $ parser = null ): self
6564 {
6665 $ tags = new StandardTagFactory ();
6766
@@ -98,10 +97,14 @@ public static function getStandardPrefixes(): iterable
9897 /**
9998 * @return iterable<non-empty-lowercase-string|list<non-empty-lowercase-string>, TagFactoryInterface>
10099 */
101- public static function getStandardTags (?ParserInterface $ parser = null ): iterable
100+ public static function getStandardTags (?Parser $ parser = null ): iterable
102101 {
103102 $ parser ??= new Parser (true );
104103
104+ if (!$ parser ->tolerant ) {
105+ throw new \InvalidArgumentException ('Tolerant parser mode required ' );
106+ }
107+
105108 // Typed doc blocks
106109 yield 'var ' => new CommonTypedTagFactory (VarTag::class, $ parser );
107110 yield 'global ' => new CommonTypedTagWithNameFactory (GlobalTag::class, $ parser );
You can’t perform that action at this time.
0 commit comments