mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 1a7e63bca3c024b25c99cd0d11f2a1eda2dd8609
1a7e63bca3
[DX] Instead of smart-file-system wrapper, use filesystem helpers directly (#2853)
This commit is contained in:
parent
785f5e3b06
commit
c2b6d2f759
@ -45,6 +45,7 @@ use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface;
|
||||
use Rector\Utils\Command\MissingInSetCommand;
|
||||
use RectorPrefix202208\Symfony\Component\Console\Application;
|
||||
use function RectorPrefix202208\Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
use RectorPrefix202208\Symfony\Component\Filesystem\Filesystem;
|
||||
use RectorPrefix202208\Symplify\EasyParallel\ValueObject\EasyParallelConfig;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Php\TypeChecker;
|
||||
@ -94,6 +95,7 @@ return static function (RectorConfig $rectorConfig) : void {
|
||||
$services->load('Rector\\', __DIR__ . '/../rules')->exclude([__DIR__ . '/../rules/*/ValueObject/*', __DIR__ . '/../rules/*/Rector/*', __DIR__ . '/../rules/*/Contract/*', __DIR__ . '/../rules/*/Exception/*', __DIR__ . '/../rules/*/Enum/*']);
|
||||
// parallel
|
||||
$services->set(ParametersMerger::class);
|
||||
$services->set(Filesystem::class);
|
||||
// use faster in-memory cache in CI.
|
||||
// CI always starts from scratch, therefore IO intensive caching is not worth it
|
||||
$ciDetector = new CiDetector();
|
||||
|
@ -6,8 +6,8 @@ namespace Rector\Caching;
|
||||
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
|
||||
use Rector\Caching\ValueObject\Storage\MemoryCacheStorage;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use RectorPrefix202208\Symfony\Component\Filesystem\Filesystem;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class CacheFactory
|
||||
{
|
||||
/**
|
||||
@ -17,13 +17,13 @@ final class CacheFactory
|
||||
private $parameterProvider;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(ParameterProvider $parameterProvider, SmartFileSystem $smartFileSystem)
|
||||
private $fileSystem;
|
||||
public function __construct(ParameterProvider $parameterProvider, Filesystem $fileSystem)
|
||||
{
|
||||
$this->parameterProvider = $parameterProvider;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->fileSystem = $fileSystem;
|
||||
}
|
||||
public function create() : \Rector\Caching\Cache
|
||||
{
|
||||
@ -34,10 +34,10 @@ final class CacheFactory
|
||||
}
|
||||
if ($cacheClass === FileCacheStorage::class) {
|
||||
// ensure cache directory exists
|
||||
if (!$this->smartFileSystem->exists($cacheDirectory)) {
|
||||
$this->smartFileSystem->mkdir($cacheDirectory);
|
||||
if (!$this->fileSystem->exists($cacheDirectory)) {
|
||||
$this->fileSystem->mkdir($cacheDirectory);
|
||||
}
|
||||
$fileCacheStorage = new FileCacheStorage($cacheDirectory, $this->smartFileSystem);
|
||||
$fileCacheStorage = new FileCacheStorage($cacheDirectory, $this->fileSystem);
|
||||
return new \Rector\Caching\Cache($fileCacheStorage);
|
||||
}
|
||||
return new \Rector\Caching\Cache(new MemoryCacheStorage());
|
||||
|
@ -22,13 +22,13 @@ final class FileCacheStorage implements CacheStorageInterface
|
||||
*/
|
||||
private $directory;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(string $directory, SmartFileSystem $smartFileSystem)
|
||||
private $filesystem;
|
||||
public function __construct(string $directory, \RectorPrefix202208\Symfony\Component\Filesystem\Filesystem $filesystem)
|
||||
{
|
||||
$this->directory = $directory;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
public function load(string $key, string $variableKey)
|
||||
{
|
||||
@ -54,8 +54,8 @@ final class FileCacheStorage implements CacheStorageInterface
|
||||
public function save(string $key, string $variableKey, $data) : void
|
||||
{
|
||||
$cacheFilePaths = $this->getCacheFilePaths($key);
|
||||
$this->smartFileSystem->mkdir($cacheFilePaths->getFirstDirectory());
|
||||
$this->smartFileSystem->mkdir($cacheFilePaths->getSecondDirectory());
|
||||
$this->filesystem->mkdir($cacheFilePaths->getFirstDirectory());
|
||||
$this->filesystem->mkdir($cacheFilePaths->getSecondDirectory());
|
||||
$path = $cacheFilePaths->getFilePath();
|
||||
$tmpPath = \sprintf('%s/%s.tmp', $this->directory, Random::generate());
|
||||
$errorBefore = \error_get_last();
|
||||
@ -84,25 +84,25 @@ final class FileCacheStorage implements CacheStorageInterface
|
||||
}
|
||||
public function clear() : void
|
||||
{
|
||||
$this->smartFileSystem->remove($this->directory);
|
||||
$this->filesystem->remove($this->directory);
|
||||
}
|
||||
private function processRemoveCacheFilePath(CacheFilePaths $cacheFilePaths) : void
|
||||
{
|
||||
$filePath = $cacheFilePaths->getFilePath();
|
||||
if (!$this->smartFileSystem->exists($filePath)) {
|
||||
if (!$this->filesystem->exists($filePath)) {
|
||||
return;
|
||||
}
|
||||
$this->smartFileSystem->remove($filePath);
|
||||
$this->filesystem->remove($filePath);
|
||||
}
|
||||
private function processRemoveEmptyDirectory(string $directory) : void
|
||||
{
|
||||
if (!$this->smartFileSystem->exists($directory)) {
|
||||
if (!$this->filesystem->exists($directory)) {
|
||||
return;
|
||||
}
|
||||
if ($this->isNotEmptyDirectory($directory)) {
|
||||
return;
|
||||
}
|
||||
$this->smartFileSystem->remove($directory);
|
||||
$this->filesystem->remove($directory);
|
||||
}
|
||||
private function isNotEmptyDirectory(string $directory) : bool
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ use Rector\Core\ValueObjectFactory\Application\FileFactory;
|
||||
use Rector\Parallel\Application\ParallelFileProcessor;
|
||||
use Rector\Parallel\ValueObject\Bridge;
|
||||
use RectorPrefix202208\Symfony\Component\Console\Input\InputInterface;
|
||||
use RectorPrefix202208\Symfony\Component\Filesystem\Filesystem;
|
||||
use RectorPrefix202208\Symplify\EasyParallel\CpuCoreCountProvider;
|
||||
use RectorPrefix202208\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException;
|
||||
use RectorPrefix202208\Symplify\EasyParallel\FileSystem\FilePathNormalizer;
|
||||
@ -24,7 +25,6 @@ use RectorPrefix202208\Symplify\EasyParallel\ScheduleFactory;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Yaml\ParametersMerger;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
use RectorPrefix202208\Webmozart\Assert\Assert;
|
||||
final class ApplicationFileProcessor
|
||||
{
|
||||
@ -38,9 +38,9 @@ final class ApplicationFileProcessor
|
||||
private $systemErrors = [];
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
private $filesystem;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Application\FileDecorator\FileDiffFileDecorator
|
||||
@ -104,9 +104,9 @@ final class ApplicationFileProcessor
|
||||
/**
|
||||
* @param FileProcessorInterface[] $fileProcessors
|
||||
*/
|
||||
public function __construct(SmartFileSystem $smartFileSystem, FileDiffFileDecorator $fileDiffFileDecorator, RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, OutputStyleInterface $rectorOutputStyle, FileFactory $fileFactory, NodeScopeResolver $nodeScopeResolver, ParametersMerger $parametersMerger, ParallelFileProcessor $parallelFileProcessor, ParameterProvider $parameterProvider, ScheduleFactory $scheduleFactory, FilePathNormalizer $filePathNormalizer, CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = [])
|
||||
public function __construct(Filesystem $filesystem, FileDiffFileDecorator $fileDiffFileDecorator, RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, OutputStyleInterface $rectorOutputStyle, FileFactory $fileFactory, NodeScopeResolver $nodeScopeResolver, ParametersMerger $parametersMerger, ParallelFileProcessor $parallelFileProcessor, ParameterProvider $parameterProvider, ScheduleFactory $scheduleFactory, FilePathNormalizer $filePathNormalizer, CpuCoreCountProvider $cpuCoreCountProvider, array $fileProcessors = [])
|
||||
{
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->fileDiffFileDecorator = $fileDiffFileDecorator;
|
||||
$this->removedAndAddedFilesProcessor = $removedAndAddedFilesProcessor;
|
||||
$this->rectorOutputStyle = $rectorOutputStyle;
|
||||
@ -194,8 +194,8 @@ final class ApplicationFileProcessor
|
||||
private function printFile(File $file) : void
|
||||
{
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
$this->smartFileSystem->dumpFile($smartFileInfo->getPathname(), $file->getFileContent());
|
||||
$this->smartFileSystem->chmod($smartFileInfo->getRealPath(), $smartFileInfo->getPerms());
|
||||
$this->filesystem->dumpFile($smartFileInfo->getPathname(), $file->getFileContent());
|
||||
$this->filesystem->chmod($smartFileInfo->getRealPath(), $smartFileInfo->getPerms());
|
||||
}
|
||||
/**
|
||||
* Inspired by @see https://github.com/phpstan/phpstan-src/blob/89af4e7db257750cdee5d4259ad312941b6b25e8/src/Analyser/Analyser.php#L134
|
||||
|
@ -6,7 +6,7 @@ namespace Rector\Core\Application\FileSystem;
|
||||
use Rector\Core\Contract\Console\OutputStyleInterface;
|
||||
use Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
use RectorPrefix202208\Symfony\Component\Filesystem\Filesystem;
|
||||
/**
|
||||
* Adds and removes scheduled file
|
||||
*/
|
||||
@ -14,9 +14,9 @@ final class RemovedAndAddedFilesProcessor
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
private $filesystem;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter
|
||||
@ -32,9 +32,9 @@ final class RemovedAndAddedFilesProcessor
|
||||
* @var \Rector\Core\Contract\Console\OutputStyleInterface
|
||||
*/
|
||||
private $rectorOutputStyle;
|
||||
public function __construct(SmartFileSystem $smartFileSystem, NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, OutputStyleInterface $rectorOutputStyle)
|
||||
public function __construct(Filesystem $filesystem, NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, OutputStyleInterface $rectorOutputStyle)
|
||||
{
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->nodesWithFileDestinationPrinter = $nodesWithFileDestinationPrinter;
|
||||
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
|
||||
$this->rectorOutputStyle = $rectorOutputStyle;
|
||||
@ -56,7 +56,7 @@ final class RemovedAndAddedFilesProcessor
|
||||
} else {
|
||||
$message = \sprintf('File "%s" was removed', $relativePath);
|
||||
$this->rectorOutputStyle->warning($message);
|
||||
$this->smartFileSystem->remove($removedFile->getPathname());
|
||||
$this->filesystem->remove($removedFile->getPathname());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ final class RemovedAndAddedFilesProcessor
|
||||
$message = \sprintf('File "%s" will be added', $addedFileWithContent->getFilePath());
|
||||
$this->rectorOutputStyle->note($message);
|
||||
} else {
|
||||
$this->smartFileSystem->dumpFile($addedFileWithContent->getFilePath(), $addedFileWithContent->getFileContent());
|
||||
$this->filesystem->dumpFile($addedFileWithContent->getFilePath(), $addedFileWithContent->getFileContent());
|
||||
$message = \sprintf('File "%s" was added', $addedFileWithContent->getFilePath());
|
||||
$this->rectorOutputStyle->note($message);
|
||||
}
|
||||
@ -81,7 +81,7 @@ final class RemovedAndAddedFilesProcessor
|
||||
$message = \sprintf('File "%s" will be added', $addedFileWithNode->getFilePath());
|
||||
$this->rectorOutputStyle->note($message);
|
||||
} else {
|
||||
$this->smartFileSystem->dumpFile($addedFileWithNode->getFilePath(), $fileContent);
|
||||
$this->filesystem->dumpFile($addedFileWithNode->getFilePath(), $fileContent);
|
||||
$message = \sprintf('File "%s" was added', $addedFileWithNode->getFilePath());
|
||||
$this->rectorOutputStyle->note($message);
|
||||
}
|
||||
@ -95,8 +95,8 @@ final class RemovedAndAddedFilesProcessor
|
||||
$message = \sprintf('File "%s" will be moved to "%s"', $movedFile->getFilePath(), $movedFile->getNewFilePath());
|
||||
$this->rectorOutputStyle->note($message);
|
||||
} else {
|
||||
$this->smartFileSystem->dumpFile($movedFile->getNewFilePath(), $fileContent);
|
||||
$this->smartFileSystem->remove($movedFile->getFilePath());
|
||||
$this->filesystem->dumpFile($movedFile->getNewFilePath(), $fileContent);
|
||||
$this->filesystem->remove($movedFile->getFilePath());
|
||||
$message = \sprintf('File "%s" was moved to "%s"', $movedFile->getFilePath(), $movedFile->getNewFilePath());
|
||||
$this->rectorOutputStyle->note($message);
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '74f6b181e82f191c1e471d446a029a06dff16619';
|
||||
public const PACKAGE_VERSION = '1a7e63bca3c024b25c99cd0d11f2a1eda2dd8609';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-08-29 23:41:18';
|
||||
public const RELEASE_DATE = '2022-08-30 00:38:34';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -7,17 +7,12 @@ use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\StaticReflection\DynamicSourceLocatorDecorator;
|
||||
use RectorPrefix202208\Symfony\Component\Console\Input\InputInterface;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use RectorPrefix202208\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* Should it pass autoload files/directories to PHPStan analyzer?
|
||||
*/
|
||||
final class AdditionalAutoloader
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\FileSystemGuard
|
||||
*/
|
||||
private $fileSystemGuard;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
|
||||
@ -28,9 +23,8 @@ final class AdditionalAutoloader
|
||||
* @var \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator
|
||||
*/
|
||||
private $dynamicSourceLocatorDecorator;
|
||||
public function __construct(FileSystemGuard $fileSystemGuard, ParameterProvider $parameterProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator)
|
||||
public function __construct(ParameterProvider $parameterProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator)
|
||||
{
|
||||
$this->fileSystemGuard = $fileSystemGuard;
|
||||
$this->parameterProvider = $parameterProvider;
|
||||
$this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator;
|
||||
}
|
||||
@ -44,7 +38,7 @@ final class AdditionalAutoloader
|
||||
if ($autoloadFile === null) {
|
||||
return;
|
||||
}
|
||||
$this->fileSystemGuard->ensureFileExists($autoloadFile, 'Extra autoload');
|
||||
Assert::fileExists($autoloadFile, \sprintf('Extra autoload file %s was not found', $autoloadFile));
|
||||
require_once $autoloadFile;
|
||||
}
|
||||
public function autoloadPaths() : void
|
||||
|
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Console\Command;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\FileSystem;
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Contract\Console\OutputStyleInterface;
|
||||
@ -12,7 +13,6 @@ use RectorPrefix202208\Symfony\Component\Console\Input\InputInterface;
|
||||
use RectorPrefix202208\Symfony\Component\Console\Input\InputOption;
|
||||
use RectorPrefix202208\Symfony\Component\Console\Output\OutputInterface;
|
||||
use RectorPrefix202208\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class InitCommand extends Command
|
||||
{
|
||||
/**
|
||||
@ -21,9 +21,9 @@ final class InitCommand extends Command
|
||||
private const TEMPLATE_PATH = __DIR__ . '/../../../templates/rector.php.dist';
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
private $filesystem;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Contract\Console\OutputStyleInterface
|
||||
@ -39,9 +39,9 @@ final class InitCommand extends Command
|
||||
* @var \Symfony\Component\Console\Style\SymfonyStyle
|
||||
*/
|
||||
private $symfonyStyle;
|
||||
public function __construct(SmartFileSystem $smartFileSystem, OutputStyleInterface $rectorOutputStyle, PhpVersionProvider $phpVersionProvider, SymfonyStyle $symfonyStyle)
|
||||
public function __construct(\RectorPrefix202208\Symfony\Component\Filesystem\Filesystem $filesystem, OutputStyleInterface $rectorOutputStyle, PhpVersionProvider $phpVersionProvider, SymfonyStyle $symfonyStyle)
|
||||
{
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->rectorOutputStyle = $rectorOutputStyle;
|
||||
$this->phpVersionProvider = $phpVersionProvider;
|
||||
$this->symfonyStyle = $symfonyStyle;
|
||||
@ -63,16 +63,16 @@ final class InitCommand extends Command
|
||||
\sleep(3);
|
||||
}
|
||||
$rectorRootFilePath = \getcwd() . '/rector.php';
|
||||
$doesFileExist = $this->smartFileSystem->exists($rectorRootFilePath);
|
||||
$doesFileExist = $this->filesystem->exists($rectorRootFilePath);
|
||||
if ($doesFileExist) {
|
||||
$this->rectorOutputStyle->warning('Config file "rector.php" already exists');
|
||||
} else {
|
||||
$this->smartFileSystem->copy(self::TEMPLATE_PATH, $rectorRootFilePath);
|
||||
$this->filesystem->copy(self::TEMPLATE_PATH, $rectorRootFilePath);
|
||||
$fullPHPVersion = (string) $this->phpVersionProvider->provide();
|
||||
$phpVersion = Strings::substring($fullPHPVersion, 0, 1) . Strings::substring($fullPHPVersion, 2, 1);
|
||||
$fileContent = $this->smartFileSystem->readFile($rectorRootFilePath);
|
||||
$fileContent = FileSystem::read($rectorRootFilePath);
|
||||
$fileContent = \str_replace('LevelSetList::UP_TO_PHP_XY', 'LevelSetList::UP_TO_PHP_' . $phpVersion, $fileContent);
|
||||
$this->smartFileSystem->dumpFile($rectorRootFilePath, $fileContent);
|
||||
$this->filesystem->dumpFile($rectorRootFilePath, $fileContent);
|
||||
$this->rectorOutputStyle->success('"rector.php" config file was added');
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
|
@ -3,22 +3,22 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\FileSystem;
|
||||
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
use RectorPrefix202208\Symfony\Component\Filesystem\Filesystem;
|
||||
final class FilePathHelper
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(SmartFileSystem $smartFileSystem)
|
||||
private $filesystem;
|
||||
public function __construct(Filesystem $filesystem)
|
||||
{
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
public function relativePath(string $fileRealPath) : string
|
||||
{
|
||||
$normalizedFileRealPath = $this->normalizePath($fileRealPath);
|
||||
$relativeFilePath = $this->smartFileSystem->makePathRelative($normalizedFileRealPath, (string) \realpath(\getcwd()));
|
||||
$relativeFilePath = $this->filesystem->makePathRelative($normalizedFileRealPath, (string) \realpath(\getcwd()));
|
||||
return \rtrim($relativeFilePath, '/');
|
||||
}
|
||||
private function normalizePath(string $filePath) : string
|
||||
|
@ -3,6 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\Parser;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\FileSystem;
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
@ -12,7 +13,6 @@ use PhpParser\Node\Stmt;
|
||||
use Rector\Core\Contract\PhpParser\NodePrinterInterface;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class InlineCodeParser
|
||||
{
|
||||
/**
|
||||
@ -60,17 +60,11 @@ final class InlineCodeParser
|
||||
* @var \Rector\Core\PhpParser\Parser\SimplePhpParser
|
||||
*/
|
||||
private $simplePhpParser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(NodePrinterInterface $nodePrinter, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser, SmartFileSystem $smartFileSystem)
|
||||
public function __construct(NodePrinterInterface $nodePrinter, NodeScopeAndMetadataDecorator $nodeScopeAndMetadataDecorator, \Rector\Core\PhpParser\Parser\SimplePhpParser $simplePhpParser)
|
||||
{
|
||||
$this->nodePrinter = $nodePrinter;
|
||||
$this->nodeScopeAndMetadataDecorator = $nodeScopeAndMetadataDecorator;
|
||||
$this->simplePhpParser = $simplePhpParser;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
}
|
||||
/**
|
||||
* @return Stmt[]
|
||||
@ -79,7 +73,7 @@ final class InlineCodeParser
|
||||
{
|
||||
// to cover files too
|
||||
if (\is_file($content)) {
|
||||
$content = $this->smartFileSystem->readFile($content);
|
||||
$content = FileSystem::read($content);
|
||||
}
|
||||
// wrap code so php-parser can interpret it
|
||||
$content = StringUtils::isMatch($content, self::OPEN_PHP_TAG_REGEX) ? $content : '<?php ' . $content;
|
||||
|
@ -3,12 +3,12 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\Parser;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\FileSystem;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PhpParser\NodeVisitor\NodeConnectingVisitor;
|
||||
use PhpParser\Parser;
|
||||
use PhpParser\ParserFactory;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class SimplePhpParser
|
||||
{
|
||||
/**
|
||||
@ -16,14 +16,8 @@ final class SimplePhpParser
|
||||
* @var \PhpParser\Parser
|
||||
*/
|
||||
private $phpParser;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(SmartFileSystem $smartFileSystem)
|
||||
public function __construct()
|
||||
{
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$parserFactory = new ParserFactory();
|
||||
$this->phpParser = $parserFactory->create(ParserFactory::PREFER_PHP7);
|
||||
}
|
||||
@ -32,7 +26,7 @@ final class SimplePhpParser
|
||||
*/
|
||||
public function parseFile(string $filePath) : array
|
||||
{
|
||||
$fileContent = $this->smartFileSystem->readFile($filePath);
|
||||
$fileContent = FileSystem::read($filePath);
|
||||
return $this->parseString($fileContent);
|
||||
}
|
||||
/**
|
||||
|
@ -8,8 +8,8 @@ use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use RectorPrefix202208\Symfony\Component\Filesystem\Filesystem;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
/**
|
||||
* @see \Rector\Core\Tests\PhpParser\Printer\FormatPerservingPrinterTest
|
||||
*/
|
||||
@ -22,13 +22,13 @@ final class FormatPerservingPrinter
|
||||
private $betterStandardPrinter;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, SmartFileSystem $smartFileSystem)
|
||||
private $filesystem;
|
||||
public function __construct(\Rector\Core\PhpParser\Printer\BetterStandardPrinter $betterStandardPrinter, Filesystem $filesystem)
|
||||
{
|
||||
$this->betterStandardPrinter = $betterStandardPrinter;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->filesystem = $filesystem;
|
||||
}
|
||||
/**
|
||||
* @param Node[] $newStmts
|
||||
@ -38,8 +38,8 @@ final class FormatPerservingPrinter
|
||||
public function printToFile(SmartFileInfo $fileInfo, array $newStmts, array $oldStmts, array $oldTokens) : string
|
||||
{
|
||||
$newContent = $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
|
||||
$this->smartFileSystem->dumpFile($fileInfo->getRealPath(), $newContent);
|
||||
$this->smartFileSystem->chmod($fileInfo->getRealPath(), $fileInfo->getPerms());
|
||||
$this->filesystem->dumpFile($fileInfo->getRealPath(), $newContent);
|
||||
$this->filesystem->chmod($fileInfo->getRealPath(), $fileInfo->getPerms());
|
||||
return $newContent;
|
||||
}
|
||||
public function printParsedStmstAndTokensToString(File $file) : string
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit6fbd778a432c95223d21b3e7c10c4d3b::getLoader();
|
||||
return ComposerAutoloaderInitb23d7a729708042650a6f0853a19c73a::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit6fbd778a432c95223d21b3e7c10c4d3b
|
||||
class ComposerAutoloaderInitb23d7a729708042650a6f0853a19c73a
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInit6fbd778a432c95223d21b3e7c10c4d3b
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit6fbd778a432c95223d21b3e7c10c4d3b', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb23d7a729708042650a6f0853a19c73a', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit6fbd778a432c95223d21b3e7c10c4d3b', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb23d7a729708042650a6f0853a19c73a', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb23d7a729708042650a6f0853a19c73a::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitb23d7a729708042650a6f0853a19c73a::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire6fbd778a432c95223d21b3e7c10c4d3b($fileIdentifier, $file);
|
||||
composerRequireb23d7a729708042650a6f0853a19c73a($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInit6fbd778a432c95223d21b3e7c10c4d3b
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire6fbd778a432c95223d21b3e7c10c4d3b($fileIdentifier, $file)
|
||||
function composerRequireb23d7a729708042650a6f0853a19c73a($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b
|
||||
class ComposerStaticInitb23d7a729708042650a6f0853a19c73a
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -3192,9 +3192,9 @@ class ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit6fbd778a432c95223d21b3e7c10c4d3b::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb23d7a729708042650a6f0853a19c73a::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb23d7a729708042650a6f0853a19c73a::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb23d7a729708042650a6f0853a19c73a::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user