42
42
class PrinterTest extends TestCase
43
43
{
44
44
45
+ /** @var PhpDocParser */
46
+ private $ phpDocParser ;
47
+
48
+ protected function setUp (): void
49
+ {
50
+ $ usedAttributes = ['lines ' => true , 'indexes ' => true ];
51
+ $ constExprParser = new ConstExprParser (true , true , $ usedAttributes );
52
+ $ this ->phpDocParser = new PhpDocParser (
53
+ new TypeParser ($ constExprParser , true , $ usedAttributes ),
54
+ $ constExprParser ,
55
+ true ,
56
+ true ,
57
+ $ usedAttributes
58
+ );
59
+ }
60
+
45
61
/**
46
62
* @return iterable<array{string, string, NodeVisitor}>
47
63
*/
@@ -1153,18 +1169,9 @@ public function enterNode(Node $node)
1153
1169
*/
1154
1170
public function testPrintFormatPreserving (string $ phpDoc , string $ expectedResult , NodeVisitor $ visitor ): void
1155
1171
{
1156
- $ usedAttributes = ['lines ' => true , 'indexes ' => true ];
1157
- $ constExprParser = new ConstExprParser (true , true , $ usedAttributes );
1158
- $ phpDocParser = new PhpDocParser (
1159
- new TypeParser ($ constExprParser , true , $ usedAttributes ),
1160
- $ constExprParser ,
1161
- true ,
1162
- true ,
1163
- $ usedAttributes
1164
- );
1165
1172
$ lexer = new Lexer ();
1166
1173
$ tokens = new TokenIterator ($ lexer ->tokenize ($ phpDoc ));
1167
- $ phpDocNode = $ phpDocParser ->parse ($ tokens );
1174
+ $ phpDocNode = $ this -> phpDocParser ->parse ($ tokens );
1168
1175
$ cloningTraverser = new NodeTraverser ([new NodeVisitor \CloningVisitor ()]);
1169
1176
$ newNodes = $ cloningTraverser ->traverse ([$ phpDocNode ]);
1170
1177
@@ -1179,7 +1186,7 @@ public function testPrintFormatPreserving(string $phpDoc, string $expectedResult
1179
1186
1180
1187
$ this ->assertEquals (
1181
1188
$ this ->unsetAttributes ($ newNode ),
1182
- $ this ->unsetAttributes ($ phpDocParser ->parse (new TokenIterator ($ lexer ->tokenize ($ newPhpDoc ))))
1189
+ $ this ->unsetAttributes ($ this -> phpDocParser ->parse (new TokenIterator ($ lexer ->tokenize ($ newPhpDoc ))))
1183
1190
);
1184
1191
}
1185
1192
0 commit comments