Skip to content

Commit 3c91887

Browse files
committed
[ci-review] Rector Rectify
1 parent d0d8c85 commit 3c91887

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

tests/PhpParser/Printer/PHPStanPrinterTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace Rector\Tests\PhpParser\Printer;
66

7+
use ReflectionProperty;
78
use PhpParser\PrettyPrinter\Standard;
89
use PHPStan\DependencyInjection\MemoizingContainer;
910
use PHPStan\DependencyInjection\Nette\NetteContainer;
1011
use PHPStan\Parser\AnonymousClassVisitor;
11-
use PHPStan\Parser\ArrayMapArgVisitor;
1212
use PHPStan\Parser\Parser;
1313
use PHPStan\Parser\RichParser;
1414
use 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

Comments
 (0)