mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-15 05:15:04 +01:00
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\FileSystemRector\Parser;
|
|
|
|
use PhpParser\Node;
|
|
use Rector\Core\PhpParser\Parser\Parser;
|
|
use Rector\Core\ValueObject\Application\File;
|
|
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
|
use Symplify\SmartFileSystem\SmartFileInfo;
|
|
final class FileInfoParser
|
|
{
|
|
/**
|
|
* @var Parser
|
|
*/
|
|
private $parser;
|
|
/**
|
|
* @var NodeScopeAndMetadataDecorator
|
|
*/
|
|
private $nodeScopeAndMetadataDecorator;
|
|
public function __construct(NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, Parser $parser)
|
|
{
|
|
$this->parser = $parser;
|
|
$this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator;
|
|
}
|
|
/**
|
|
* @return Node[]
|
|
*/
|
|
public function parseFileInfoToNodesAndDecorate(SmartFileInfo $smartFileInfo) : array
|
|
{
|
|
$oldStmts = $this->parser->parseFileInfo($smartFileInfo);
|
|
$file = new File($smartFileInfo, $smartFileInfo->getContents());
|
|
return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts, $smartFileInfo);
|
|
}
|
|
}
|