44
55namespace Rector \Tests \PhpParser \Printer ;
66
7+ use ReflectionProperty ;
78use PhpParser \PrettyPrinter \Standard ;
89use PHPStan \DependencyInjection \MemoizingContainer ;
910use PHPStan \DependencyInjection \Nette \NetteContainer ;
1011use PHPStan \Parser \AnonymousClassVisitor ;
11- use PHPStan \Parser \ArrayMapArgVisitor ;
1212use PHPStan \Parser \Parser ;
1313use PHPStan \Parser \RichParser ;
1414use Rector \Testing \PHPUnit \AbstractLazyTestCase ;
@@ -27,36 +27,33 @@ public function testAddingCommentOnSomeNodesFail(): void
2727 /** @var RichParser $phpstanParser */
2828 $ phpstanParser = $ this ->make (Parser::class);
2929
30- $ this ->removeNodeVisitorFromPHPStanParser ($ phpstanParser, [ArrayMapArgVisitor::class] );
30+ $ this ->removeNodeVisitorFromPHPStanParser ($ phpstanParser );
3131
3232 $ stmts = $ phpstanParser ->parseFile (__DIR__ . '/Fixture/some_array_map.php ' );
3333
3434 // get private property "parser"
35- $ parserReflectionProperty = new \ ReflectionProperty (RichParser::class, 'parser ' );
35+ $ parserReflectionProperty = new ReflectionProperty (RichParser::class, 'parser ' );
3636
3737 /** @var \PhpParser\Parser $innerParser */
3838 $ innerParser = $ parserReflectionProperty ->getValue ($ phpstanParser );
3939 $ tokens = $ innerParser ->getTokens ();
4040
41- $ standardPrinter = new Standard ([
41+ $ standard = new Standard ([
4242 'newline ' => "\n" ,
4343 ]);
44- $ printerContents = $ standardPrinter ->printFormatPreserving ($ stmts , $ stmts , $ tokens );
44+ $ printerContents = $ standard ->printFormatPreserving ($ stmts , $ stmts , $ tokens );
4545
4646 $ this ->assertStringEqualsFile (__DIR__ . '/Fixture/some_array_map.php ' , $ printerContents );
4747 }
4848
49- /**
50- * @param class-string[] $nodeVisitorsToRemove
51- */
52- private function removeNodeVisitorFromPHPStanParser (RichParser $ phpstanParser , array $ nodeVisitorsToRemove ): void
49+ private function removeNodeVisitorFromPHPStanParser (RichParser $ richParser ): void
5350 {
5451 // the only way now seems to access container early and remove unwanted services
5552 // here https://github.com/phpstan/phpstan-src/blob/522421b007cbfc674bebb93e823c774167ac78cd/src/Parser/RichParser.php#L90-L92
5653 $ privatesAccessor = new PrivatesAccessor ();
5754
5855 /** @var MemoizingContainer $container */
59- $ container = $ privatesAccessor ->getPrivateProperty ($ phpstanParser , 'container ' );
56+ $ container = $ privatesAccessor ->getPrivateProperty ($ richParser , 'container ' );
6057
6158 /** @var NetteContainer $originalContainer */
6259 $ originalContainer = $ privatesAccessor ->getPrivateProperty ($ container , 'originalContainer ' );
0 commit comments