mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-04 18:30:50 +00:00
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\Tests\NodeTypeResolver\PerNodeTypeResolver;
|
|
|
|
use PhpParser\Node;
|
|
use Rector\Core\HttpKernel\RectorKernel;
|
|
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
|
use Rector\NodeTypeResolver\NodeTypeResolver;
|
|
use Rector\Testing\TestingParser\TestingParser;
|
|
use Symplify\PackageBuilder\Testing\AbstractKernelTestCase;
|
|
|
|
abstract class AbstractNodeTypeResolverTest extends AbstractKernelTestCase
|
|
{
|
|
/**
|
|
* @var NodeTypeResolver
|
|
*/
|
|
protected $nodeTypeResolver;
|
|
|
|
/**
|
|
* @var BetterNodeFinder
|
|
*/
|
|
private $betterNodeFinder;
|
|
|
|
/**
|
|
* @var TestingParser
|
|
*/
|
|
private $testingParser;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->bootKernel(RectorKernel::class);
|
|
|
|
$this->betterNodeFinder = $this->getService(BetterNodeFinder::class);
|
|
$this->testingParser = $this->getService(TestingParser::class);
|
|
$this->nodeTypeResolver = $this->getService(NodeTypeResolver::class);
|
|
}
|
|
|
|
/**
|
|
* @template T as Node
|
|
* @param class-string<T> $type
|
|
* @return T[]
|
|
*/
|
|
protected function getNodesForFileOfType(string $file, string $type): array
|
|
{
|
|
$nodes = $this->testingParser->parseFileToDecoratedNodes($file);
|
|
|
|
return $this->betterNodeFinder->findInstanceOf($nodes, $type);
|
|
}
|
|
}
|