mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-15 05:15:04 +01:00
5689cbe017
remove passing extra fileInfo with file, already included7bba40aa32
remove OPTION_ prefixc2ce6104d3
remove extra parma in value object77a90c5fd4
remove is cache debugff3de640d4
add shot options constant0c035c390d
misc
36 lines
1.2 KiB
PHP
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 \Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator
|
|
*/
|
|
private $nodeScopeAndMetadataDecorator;
|
|
/**
|
|
* @var \Rector\Core\PhpParser\Parser\Parser
|
|
*/
|
|
private $parser;
|
|
public function __construct(\Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\Parser $parser)
|
|
{
|
|
$this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator;
|
|
$this->parser = $parser;
|
|
}
|
|
/**
|
|
* @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);
|
|
}
|
|
}
|