mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-06 19:30:50 +00:00
38 lines
991 B
PHP
38 lines
991 B
PHP
|
<?php declare(strict_types=1);
|
||
|
|
||
|
namespace Rector\FileSystemRector\Parser;
|
||
|
|
||
|
use PhpParser\Node;
|
||
|
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||
|
use Rector\PhpParser\Parser\Parser;
|
||
|
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||
|
|
||
|
final class FileInfoParser
|
||
|
{
|
||
|
/**
|
||
|
* @var Parser
|
||
|
*/
|
||
|
private $parser;
|
||
|
|
||
|
/**
|
||
|
* @var NodeScopeAndMetadataDecorator
|
||
|
*/
|
||
|
private $nodeScopeAndMetadataDecorator;
|
||
|
|
||
|
public function __construct(Parser $parser, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator)
|
||
|
{
|
||
|
$this->parser = $parser;
|
||
|
$this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return Node[]
|
||
|
*/
|
||
|
public function parseFileInfoToNodesAndDecorate(SmartFileInfo $fileInfo): array
|
||
|
{
|
||
|
$oldStmts = $this->parser->parseFile($fileInfo->getRealPath());
|
||
|
|
||
|
return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($oldStmts, $fileInfo->getRealPath());
|
||
|
}
|
||
|
}
|