rector/packages/FileSystemRector/Parser/FileInfoParser.php
Tomas Votruba 7d36c3b0b9 Updated Rector to commit a80cf5292d
a80cf5292d revert to working scoper 0.14
2021-05-10 22:23:08 +00:00

36 lines
1.2 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(\Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\Parser $parser)
{
$this->parser = $parser;
$this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator;
}
/**
* @return Node[]
*/
public function parseFileInfoToNodesAndDecorate(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array
{
$oldStmts = $this->parser->parseFileInfo($smartFileInfo);
$file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents());
return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts, $smartFileInfo);
}
}