5
5
namespace TypeLang \PHPDoc \Tests \Unit ;
6
6
7
7
use PHPUnit \Framework \Attributes \DataProvider ;
8
- use TypeLang \PHPDoc \DocBlock \Tag \Content \Stream ;
9
- use TypeLang \PHPDoc \DocBlock \Tag \Description \Description ;
10
- use TypeLang \PHPDoc \DocBlock \Tag \Description \TaggedDescription ;
11
- use TypeLang \PHPDoc \DocBlock \Tag \Description \TaggedDescriptionInterface ;
8
+ use TypeLang \PHPDoc \DocBlock \Description \Description ;
9
+ use TypeLang \PHPDoc \DocBlock \Description \TaggedDescription ;
10
+ use TypeLang \PHPDoc \DocBlock \Description \TaggedDescriptionInterface ;
12
11
use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactory ;
13
12
use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
14
13
use TypeLang \PHPDoc \DocBlock \Tag \InvalidTag ;
@@ -24,9 +23,12 @@ public static function parserDataProvider(): iterable
24
23
{
25
24
$ tags = new TagFactory ([
26
25
'error ' => new class implements TagFactoryInterface {
27
- public function create (Stream $ tag , DescriptionParserInterface $ descriptions ): TagInterface
28
- {
29
- throw new \LogicException ('Error tag ' . $ tag ->getName ());
26
+ public function create (
27
+ string $ tag ,
28
+ string $ content ,
29
+ DescriptionParserInterface $ descriptions
30
+ ): TagInterface {
31
+ throw new \LogicException ('Error tag ' . $ tag );
30
32
}
31
33
},
32
34
]);
@@ -123,14 +125,15 @@ public function testDescriptionWithBadTagName(DescriptionParserInterface $parser
123
125
$ description = $ parser ->parse ('Hello {@@} World! ' );
124
126
125
127
self ::assertInstanceOf (TaggedDescriptionInterface::class, $ description );
126
- self ::assertCount (3 , $ description );
127
- self ::assertInstanceOf (InvalidTag::class, $ description [1 ]);
128
+ self ::assertCount (3 , $ description ->components );
129
+ self ::assertCount (1 , $ description );
130
+ self ::assertInstanceOf (InvalidTag::class, $ description [0 ]);
128
131
129
- $ reason = $ description [1 ]->reason ;
132
+ $ reason = $ description [0 ]->reason ;
130
133
131
134
self ::assertSame ('Tag name cannot be empty ' , $ reason ->getMessage ());
132
- self ::assertSame (InvalidTag::DEFAULT_UNKNOWN_TAG_NAME , $ description [1 ]->getName () );
133
- self ::assertEquals (new Description ('{@} ' ), $ description [1 ]->getDescription () );
135
+ self ::assertSame (InvalidTag::DEFAULT_UNKNOWN_TAG_NAME , $ description [0 ]->name );
136
+ self ::assertEquals (new Description ('@@ ' ), $ description [0 ]->description );
134
137
}
135
138
136
139
#[DataProvider('parserDataProvider ' )]
@@ -139,13 +142,14 @@ public function testErrorWhileParsingInline(DescriptionParserInterface $parser):
139
142
$ description = $ parser ->parse ('Hello {@error description} World! ' );
140
143
141
144
self ::assertInstanceOf (TaggedDescriptionInterface::class, $ description );
142
- self ::assertCount (3 , $ description );
143
- self ::assertInstanceOf (InvalidTag::class, $ description [1 ]);
145
+ self ::assertCount (3 , $ description ->components );
146
+ self ::assertCount (1 , $ description );
147
+ self ::assertInstanceOf (InvalidTag::class, $ description [0 ]);
144
148
145
- $ reason = $ description [1 ]->reason ;
149
+ $ reason = $ description [0 ]->reason ;
146
150
147
151
self ::assertSame ('Error while parsing tag @error ' , $ reason ->getMessage ());
148
- self ::assertSame ('error ' , $ description [1 ]->getName () );
149
- self ::assertEquals (new Description ('description ' ), $ description [1 ]->getDescription () );
152
+ self ::assertSame ('error ' , $ description [0 ]->name );
153
+ self ::assertEquals (new Description ('description ' ), $ description [0 ]->description );
150
154
}
151
155
}
0 commit comments