mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 16:30:51 +00:00
parent
e8e4a58862
commit
7cdc668f8b
|
@ -6,6 +6,7 @@ namespace RectorPrefix20210622;
|
|||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector;
|
||||
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
|
||||
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
|
||||
|
|
|
@ -13,6 +13,8 @@ use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRecto
|
|||
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector;
|
||||
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
|
||||
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector;
|
||||
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrEndsWithRector;
|
||||
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrStartsWithRector;
|
||||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector;
|
||||
|
|
|
@ -41,15 +41,14 @@ use Rector\PostRector\Rector\NameImportingPostRector;
|
|||
use Rector\Core\Configuration\Option;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// get parameters
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_76);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_87);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_95);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_104);
|
||||
$containerConfigurator->import(Typo3SetList::TYPO3_11);
|
||||
|
||||
// get parameters
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::SKIP, [
|
||||
NameImportingPostRector::class => [
|
||||
'ClassAliasMap.php',
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\ChangesReporting\Contract\Output;
|
||||
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\ProcessResult;
|
||||
interface OutputFormatterInterface
|
||||
{
|
||||
public function getName() : string;
|
||||
public function report(\Rector\Core\ValueObject\ProcessResult $processResult) : void;
|
||||
public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace Rector\ChangesReporting\Output;
|
|||
use RectorPrefix20210622\Nette\Utils\Strings;
|
||||
use Rector\ChangesReporting\Annotation\RectorsChangelogResolver;
|
||||
use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Contract\Console\OutputStyleInterface;
|
||||
use Rector\Core\ValueObject\Application\RectorError;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\ProcessResult;
|
||||
use Rector\Core\ValueObject\Reporting\FileDiff;
|
||||
final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\Output\OutputFormatterInterface
|
||||
|
@ -22,10 +22,6 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
|
|||
* @see https://regex101.com/r/q8I66g/1
|
||||
*/
|
||||
private const ON_LINE_REGEX = '# on line #';
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Rector\Core\Contract\Console\OutputStyleInterface
|
||||
*/
|
||||
|
@ -34,15 +30,14 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
|
|||
* @var \Rector\ChangesReporting\Annotation\RectorsChangelogResolver
|
||||
*/
|
||||
private $rectorsChangelogResolver;
|
||||
public function __construct(\Rector\Core\Configuration\Configuration $configuration, \Rector\Core\Contract\Console\OutputStyleInterface $outputStyle, \Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver)
|
||||
public function __construct(\Rector\Core\Contract\Console\OutputStyleInterface $outputStyle, \Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->outputStyle = $outputStyle;
|
||||
$this->rectorsChangelogResolver = $rectorsChangelogResolver;
|
||||
}
|
||||
public function report(\Rector\Core\ValueObject\ProcessResult $processResult) : void
|
||||
public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
if ($this->configuration->shouldShowDiffs()) {
|
||||
if ($configuration->shouldShowDiffs()) {
|
||||
$this->reportFileDiffs($processResult->getFileDiffs());
|
||||
}
|
||||
$this->reportErrors($processResult->getErrors());
|
||||
|
@ -50,7 +45,7 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
|
|||
if ($processResult->getErrors() !== []) {
|
||||
return;
|
||||
}
|
||||
$message = $this->createSuccessMessage($processResult);
|
||||
$message = $this->createSuccessMessage($processResult, $configuration);
|
||||
$this->outputStyle->success($message);
|
||||
}
|
||||
public function getName() : string
|
||||
|
@ -125,13 +120,13 @@ final class ConsoleOutputFormatter implements \Rector\ChangesReporting\Contract\
|
|||
$message = \sprintf('%d nodes were removed', $processResult->getRemovedNodeCount());
|
||||
$this->outputStyle->warning($message);
|
||||
}
|
||||
private function createSuccessMessage(\Rector\Core\ValueObject\ProcessResult $processResult) : string
|
||||
private function createSuccessMessage(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : string
|
||||
{
|
||||
$changeCount = \count($processResult->getFileDiffs()) + $processResult->getRemovedAndAddedFilesCount();
|
||||
if ($changeCount === 0) {
|
||||
return 'Rector is done!';
|
||||
}
|
||||
return \sprintf('%d file%s %s by Rector', $changeCount, $changeCount > 1 ? 's' : '', $this->configuration->isDryRun() ? 'would have changed (dry-run)' : ($changeCount === 1 ? 'has' : 'have') . ' been changed');
|
||||
return \sprintf('%d file%s %s by Rector', $changeCount, $changeCount > 1 ? 's' : '', $configuration->isDryRun() ? 'would have changed (dry-run)' : ($changeCount === 1 ? 'has' : 'have') . ' been changed');
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Rector\ChangesReporting\Output;
|
|||
use RectorPrefix20210622\Nette\Utils\Json;
|
||||
use Rector\ChangesReporting\Annotation\RectorsChangelogResolver;
|
||||
use Rector\ChangesReporting\Contract\Output\OutputFormatterInterface;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\ProcessResult;
|
||||
use RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Output\OutputFormatterInterface
|
||||
|
@ -15,10 +15,6 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out
|
|||
* @var string
|
||||
*/
|
||||
public const NAME = 'json';
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
|
@ -27,9 +23,12 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out
|
|||
* @var \Rector\ChangesReporting\Annotation\RectorsChangelogResolver
|
||||
*/
|
||||
private $rectorsChangelogResolver;
|
||||
public function __construct(\Rector\Core\Configuration\Configuration $configuration, \RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver)
|
||||
public function __construct(
|
||||
// @todo add rector for unused promoted property
|
||||
\RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem,
|
||||
\Rector\ChangesReporting\Annotation\RectorsChangelogResolver $rectorsChangelogResolver
|
||||
)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->rectorsChangelogResolver = $rectorsChangelogResolver;
|
||||
}
|
||||
|
@ -37,9 +36,9 @@ final class JsonOutputFormatter implements \Rector\ChangesReporting\Contract\Out
|
|||
{
|
||||
return self::NAME;
|
||||
}
|
||||
public function report(\Rector\Core\ValueObject\ProcessResult $processResult) : void
|
||||
public function report(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
$errorsArray = ['meta' => ['config' => $this->configuration->getMainConfigFilePath()], 'totals' => ['changed_files' => \count($processResult->getFileDiffs()), 'removed_and_added_files_count' => $processResult->getRemovedAndAddedFilesCount(), 'removed_node_count' => $processResult->getRemovedNodeCount()]];
|
||||
$errorsArray = ['meta' => ['config' => $configuration->getMainConfigFilePath()], 'totals' => ['changed_files' => \count($processResult->getFileDiffs()), 'removed_and_added_files_count' => $processResult->getRemovedAndAddedFilesCount(), 'removed_node_count' => $processResult->getRemovedNodeCount()]];
|
||||
$fileDiffs = $processResult->getFileDiffs();
|
||||
\ksort($fileDiffs);
|
||||
foreach ($fileDiffs as $fileDiff) {
|
||||
|
|
|
@ -12,9 +12,9 @@ use Rector\Core\Application\ApplicationFileProcessor;
|
|||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
|
||||
use Rector\Core\Autoloading\AdditionalAutoloader;
|
||||
use Rector\Core\Autoloading\BootstrapFilesIncluder;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
||||
use Rector\Testing\Contract\RectorTestInterface;
|
||||
use Rector\Testing\PHPUnit\Behavior\MovingFilesTrait;
|
||||
|
@ -71,9 +71,6 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe
|
|||
/** @var BootstrapFilesIncluder $bootstrapFilesIncluder */
|
||||
$bootstrapFilesIncluder = $this->getService(\Rector\Core\Autoloading\BootstrapFilesIncluder::class);
|
||||
$bootstrapFilesIncluder->includeBootstrapFiles();
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = $this->getService(\Rector\Core\Configuration\Configuration::class);
|
||||
$configuration->setIsDryRun(\true);
|
||||
}
|
||||
/**
|
||||
* @return Iterator<SmartFileInfo>
|
||||
|
@ -128,8 +125,9 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe
|
|||
/** @var NodeScopeResolver $nodeScopeResolver */
|
||||
$nodeScopeResolver = $this->getService(\PHPStan\Analyser\NodeScopeResolver::class);
|
||||
$nodeScopeResolver->setAnalysedFiles([$fileInfo->getRealPath()]);
|
||||
$configuration = new \Rector\Core\ValueObject\Configuration(\true);
|
||||
$file = new \Rector\Core\ValueObject\Application\File($fileInfo, $fileInfo->getContents());
|
||||
$this->applicationFileProcessor->run([$file]);
|
||||
$this->applicationFileProcessor->run([$file], $configuration);
|
||||
return $file->getFileContent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Rector\Composer\Application\FileProcessor;
|
|||
use Rector\Composer\Contract\Rector\ComposerRectorInterface;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use RectorPrefix20210622\Symplify\ComposerJsonManipulator\ComposerJsonFactory;
|
||||
use RectorPrefix20210622\Symplify\ComposerJsonManipulator\Printer\ComposerJsonPrinter;
|
||||
|
@ -36,7 +37,7 @@ final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\Fil
|
|||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
public function process(array $files) : void
|
||||
public function process(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
if ($this->composerRectors === []) {
|
||||
return;
|
||||
|
@ -45,7 +46,7 @@ final class ComposerFileProcessor implements \Rector\Core\Contract\Processor\Fil
|
|||
$this->processFile($file);
|
||||
}
|
||||
}
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file) : bool
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool
|
||||
{
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
if ($this->isJsonInTests($smartFileInfo)) {
|
||||
|
|
|
@ -5,17 +5,13 @@ namespace Rector\Core\Application;
|
|||
|
||||
use Rector\Core\Application\FileDecorator\FileDiffFileDecorator;
|
||||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\FileFormatter\FileFormatter;
|
||||
use RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class ApplicationFileProcessor
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
|
@ -39,9 +35,8 @@ final class ApplicationFileProcessor
|
|||
/**
|
||||
* @param FileProcessorInterface[] $fileProcessors
|
||||
*/
|
||||
public function __construct(\Rector\Core\Configuration\Configuration $configuration, \RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\FileFormatter\FileFormatter $fileFormatter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, array $fileProcessors = [])
|
||||
public function __construct(\RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\FileFormatter\FileFormatter $fileFormatter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, array $fileProcessors = [])
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->fileDiffFileDecorator = $fileDiffFileDecorator;
|
||||
$this->fileFormatter = $fileFormatter;
|
||||
|
@ -51,32 +46,32 @@ final class ApplicationFileProcessor
|
|||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
public function run(array $files) : void
|
||||
public function run(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
$this->processFiles($files);
|
||||
$this->processFiles($files, $configuration);
|
||||
$this->fileFormatter->format($files);
|
||||
$this->fileDiffFileDecorator->decorate($files);
|
||||
$this->printFiles($files);
|
||||
$this->printFiles($files, $configuration);
|
||||
}
|
||||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
private function processFiles(array $files) : void
|
||||
private function processFiles(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
foreach ($this->fileProcessors as $fileProcessor) {
|
||||
$supportedFiles = \array_filter($files, function (\Rector\Core\ValueObject\Application\File $file) use($fileProcessor) : bool {
|
||||
return $fileProcessor->supports($file);
|
||||
$supportedFiles = \array_filter($files, function (\Rector\Core\ValueObject\Application\File $file) use($fileProcessor, $configuration) : bool {
|
||||
return $fileProcessor->supports($file, $configuration);
|
||||
});
|
||||
$fileProcessor->process($supportedFiles);
|
||||
$fileProcessor->process($supportedFiles, $configuration);
|
||||
}
|
||||
$this->removedAndAddedFilesProcessor->run();
|
||||
$this->removedAndAddedFilesProcessor->run($configuration);
|
||||
}
|
||||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
private function printFiles(array $files) : void
|
||||
private function printFiles(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
if ($this->configuration->isDryRun()) {
|
||||
if ($configuration->isDryRun()) {
|
||||
return;
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
|
|
|
@ -8,13 +8,13 @@ use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory;
|
|||
use Rector\Core\Application\FileDecorator\FileDiffFileDecorator;
|
||||
use Rector\Core\Application\FileProcessor;
|
||||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Printer\FormatPerservingPrinter;
|
||||
use Rector\Core\Provider\CurrentFileProvider;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Application\RectorError;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\PostRector\Application\PostFileProcessor;
|
||||
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use RectorPrefix20210622\Symfony\Component\Console\Helper\ProgressBar;
|
||||
|
@ -38,10 +38,6 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
* @var File[]
|
||||
*/
|
||||
private $notParsedFiles = [];
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Rector\Core\PhpParser\Printer\FormatPerservingPrinter
|
||||
*/
|
||||
|
@ -78,9 +74,8 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
* @var \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory
|
||||
*/
|
||||
private $errorFactory;
|
||||
public function __construct(\Rector\Core\Configuration\Configuration $configuration, \Rector\Core\PhpParser\Printer\FormatPerservingPrinter $formatPerservingPrinter, \Rector\Core\Application\FileProcessor $fileProcessor, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \RectorPrefix20210622\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \RectorPrefix20210622\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor, \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory $errorFactory)
|
||||
public function __construct(\Rector\Core\PhpParser\Printer\FormatPerservingPrinter $formatPerservingPrinter, \Rector\Core\Application\FileProcessor $fileProcessor, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \RectorPrefix20210622\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle, \RectorPrefix20210622\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor, \Rector\Core\Application\FileDecorator\FileDiffFileDecorator $fileDiffFileDecorator, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider, \Rector\PostRector\Application\PostFileProcessor $postFileProcessor, \Rector\ChangesReporting\ValueObjectFactory\ErrorFactory $errorFactory)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->formatPerservingPrinter = $formatPerservingPrinter;
|
||||
$this->fileProcessor = $fileProcessor;
|
||||
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
|
||||
|
@ -94,28 +89,28 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
public function process(array $files) : void
|
||||
public function process(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
$fileCount = \count($files);
|
||||
if ($fileCount === 0) {
|
||||
return;
|
||||
}
|
||||
$this->prepareProgressBar($fileCount);
|
||||
$this->prepareProgressBar($fileCount, $configuration);
|
||||
// 1. parse files to nodes
|
||||
foreach ($files as $file) {
|
||||
$this->tryCatchWrapper($file, function (\Rector\Core\ValueObject\Application\File $file) : void {
|
||||
$this->fileProcessor->parseFileInfoToLocalCache($file);
|
||||
}, 'parsing');
|
||||
}, 'parsing', $configuration);
|
||||
}
|
||||
// 2. change nodes with Rectors
|
||||
$this->refactorNodesWithRectors($files);
|
||||
$this->refactorNodesWithRectors($files, $configuration);
|
||||
// 3. apply post rectors
|
||||
foreach ($files as $file) {
|
||||
$this->tryCatchWrapper($file, function (\Rector\Core\ValueObject\Application\File $file) : void {
|
||||
$newStmts = $this->postFileProcessor->traverse($file->getNewStmts());
|
||||
// this is needed for new tokens added in "afterTraverse()"
|
||||
$file->changeNewStmts($newStmts);
|
||||
}, 'post rectors');
|
||||
}, 'post rectors', $configuration);
|
||||
}
|
||||
// 4. print to file or string
|
||||
foreach ($files as $file) {
|
||||
|
@ -123,35 +118,35 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
// cannot print file with errors, as print would break everything to original nodes
|
||||
if ($file->hasErrors()) {
|
||||
$this->printFileErrors($file);
|
||||
$this->advance($file, 'printing skipped due error');
|
||||
$this->advance($file, 'printing skipped due error', $configuration);
|
||||
continue;
|
||||
}
|
||||
$this->tryCatchWrapper($file, function (\Rector\Core\ValueObject\Application\File $file) : void {
|
||||
$this->printFile($file);
|
||||
}, 'printing');
|
||||
$this->tryCatchWrapper($file, function (\Rector\Core\ValueObject\Application\File $file) use($configuration) : void {
|
||||
$this->printFile($file, $configuration);
|
||||
}, 'printing', $configuration);
|
||||
}
|
||||
if ($this->configuration->shouldShowProgressBar()) {
|
||||
if ($configuration->shouldShowProgressBar()) {
|
||||
$this->symfonyStyle->newLine(2);
|
||||
}
|
||||
}
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file) : bool
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool
|
||||
{
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
return $smartFileInfo->hasSuffixes($this->getSupportedFileExtensions());
|
||||
return $smartFileInfo->hasSuffixes($configuration->getFileExtensions());
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSupportedFileExtensions() : array
|
||||
{
|
||||
return $this->configuration->getFileExtensions();
|
||||
return ['php'];
|
||||
}
|
||||
private function prepareProgressBar(int $fileCount) : void
|
||||
private function prepareProgressBar(int $fileCount, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
if ($this->symfonyStyle->isVerbose()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->configuration->shouldShowProgressBar()) {
|
||||
if (!$configuration->shouldShowProgressBar()) {
|
||||
return;
|
||||
}
|
||||
$this->configureStepCount($fileCount);
|
||||
|
@ -159,19 +154,19 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
private function refactorNodesWithRectors(array $files) : void
|
||||
private function refactorNodesWithRectors(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$this->currentFileProvider->setFile($file);
|
||||
$this->tryCatchWrapper($file, function (\Rector\Core\ValueObject\Application\File $file) : void {
|
||||
$this->fileProcessor->refactor($file);
|
||||
}, 'refactoring');
|
||||
}, 'refactoring', $configuration);
|
||||
}
|
||||
}
|
||||
private function tryCatchWrapper(\Rector\Core\ValueObject\Application\File $file, callable $callback, string $phase) : void
|
||||
private function tryCatchWrapper(\Rector\Core\ValueObject\Application\File $file, callable $callback, string $phase, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
$this->currentFileProvider->setFile($file);
|
||||
$this->advance($file, $phase);
|
||||
$this->advance($file, $phase, $configuration);
|
||||
try {
|
||||
if (\in_array($file, $this->notParsedFiles, \true)) {
|
||||
// we cannot process this file
|
||||
|
@ -196,14 +191,14 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
$file->addRectorError($rectorError);
|
||||
}
|
||||
}
|
||||
private function printFile(\Rector\Core\ValueObject\Application\File $file) : void
|
||||
private function printFile(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
if ($this->removedAndAddedFilesCollector->isFileRemoved($smartFileInfo)) {
|
||||
// skip, because this file exists no more
|
||||
return;
|
||||
}
|
||||
$newContent = $this->configuration->isDryRun() ? $this->formatPerservingPrinter->printParsedStmstAndTokensToString($file) : $this->formatPerservingPrinter->printParsedStmstAndTokens($file);
|
||||
$newContent = $configuration->isDryRun() ? $this->formatPerservingPrinter->printParsedStmstAndTokensToString($file) : $this->formatPerservingPrinter->printParsedStmstAndTokens($file);
|
||||
$file->changeFileContent($newContent);
|
||||
$this->fileDiffFileDecorator->decorate([$file]);
|
||||
}
|
||||
|
@ -223,25 +218,19 @@ final class PhpFileProcessor implements \Rector\Core\Contract\Processor\FileProc
|
|||
$redrawFrequency = (int) ($progressBar->getMaxSteps() / 20);
|
||||
$progressBar->setRedrawFrequency($redrawFrequency);
|
||||
}
|
||||
private function advance(\Rector\Core\ValueObject\Application\File $file, string $phase) : void
|
||||
private function advance(\Rector\Core\ValueObject\Application\File $file, string $phase, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
if ($this->symfonyStyle->isVerbose()) {
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
$relativeFilePath = $smartFileInfo->getRelativeFilePathFromDirectory(\getcwd());
|
||||
$message = \sprintf('[%s] %s', $phase, $relativeFilePath);
|
||||
$this->symfonyStyle->writeln($message);
|
||||
} elseif ($this->configuration->shouldShowProgressBar()) {
|
||||
} elseif ($configuration->shouldShowProgressBar()) {
|
||||
$this->symfonyStyle->progressAdvance();
|
||||
}
|
||||
}
|
||||
private function printFileErrors(\Rector\Core\ValueObject\Application\File $file) : void
|
||||
{
|
||||
if (!$this->symfonyStyle->isVerbose()) {
|
||||
return;
|
||||
}
|
||||
if (!$file->hasErrors()) {
|
||||
return;
|
||||
}
|
||||
foreach ($file->getErrors() as $rectorError) {
|
||||
$this->symfonyStyle->error($rectorError->getMessage());
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\Application\FileSystem;
|
||||
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use RectorPrefix20210622\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
/**
|
||||
|
@ -12,10 +12,6 @@ use RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem;
|
|||
*/
|
||||
final class RemovedAndAddedFilesProcessor
|
||||
{
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
|
@ -32,25 +28,24 @@ final class RemovedAndAddedFilesProcessor
|
|||
* @var \Symfony\Component\Console\Style\SymfonyStyle
|
||||
*/
|
||||
private $symfonyStyle;
|
||||
public function __construct(\Rector\Core\Configuration\Configuration $configuration, \RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \RectorPrefix20210622\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
|
||||
public function __construct(\RectorPrefix20210622\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter $nodesWithFileDestinationPrinter, \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector $removedAndAddedFilesCollector, \RectorPrefix20210622\Symfony\Component\Console\Style\SymfonyStyle $symfonyStyle)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->nodesWithFileDestinationPrinter = $nodesWithFileDestinationPrinter;
|
||||
$this->removedAndAddedFilesCollector = $removedAndAddedFilesCollector;
|
||||
$this->symfonyStyle = $symfonyStyle;
|
||||
}
|
||||
public function run() : void
|
||||
public function run(\Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
$this->processAddedFilesWithContent();
|
||||
$this->processAddedFilesWithNodes();
|
||||
$this->processDeletedFiles();
|
||||
$this->processAddedFilesWithContent($configuration);
|
||||
$this->processAddedFilesWithNodes($configuration);
|
||||
$this->processDeletedFiles($configuration);
|
||||
}
|
||||
private function processDeletedFiles() : void
|
||||
private function processDeletedFiles(\Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
foreach ($this->removedAndAddedFilesCollector->getRemovedFiles() as $removedFile) {
|
||||
$relativePath = $removedFile->getRelativeFilePathFromDirectory(\getcwd());
|
||||
if ($this->configuration->isDryRun()) {
|
||||
if ($configuration->isDryRun()) {
|
||||
$message = \sprintf('File "%s" will be removed', $relativePath);
|
||||
$this->symfonyStyle->warning($message);
|
||||
} else {
|
||||
|
@ -60,10 +55,10 @@ final class RemovedAndAddedFilesProcessor
|
|||
}
|
||||
}
|
||||
}
|
||||
private function processAddedFilesWithContent() : void
|
||||
private function processAddedFilesWithContent(\Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
foreach ($this->removedAndAddedFilesCollector->getAddedFilesWithContent() as $addedFileWithContent) {
|
||||
if ($this->configuration->isDryRun()) {
|
||||
if ($configuration->isDryRun()) {
|
||||
$message = \sprintf('File "%s" will be added', $addedFileWithContent->getFilePath());
|
||||
$this->symfonyStyle->note($message);
|
||||
} else {
|
||||
|
@ -73,11 +68,11 @@ final class RemovedAndAddedFilesProcessor
|
|||
}
|
||||
}
|
||||
}
|
||||
private function processAddedFilesWithNodes() : void
|
||||
private function processAddedFilesWithNodes(\Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
foreach ($this->removedAndAddedFilesCollector->getAddedFilesWithNodes() as $addedFileWithNode) {
|
||||
$fileContent = $this->nodesWithFileDestinationPrinter->printNodesWithFileDestination($addedFileWithNode);
|
||||
if ($this->configuration->isDryRun()) {
|
||||
if ($configuration->isDryRun()) {
|
||||
$message = \sprintf('File "%s" will be added', $addedFileWithNode->getFilePath());
|
||||
$this->symfonyStyle->note($message);
|
||||
} else {
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '27c2c736e38ccbd0c5b7c1bf8cdf2a9e703b6b30';
|
||||
public const PACKAGE_VERSION = 'ea11625cfb69e7f5a0438ef8391dc9177fdb7f1d';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-06-22 17:16:19';
|
||||
public const RELEASE_DATE = '2021-06-22 21:22:30';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210622\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Configuration;
|
||||
|
||||
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
|
||||
use Rector\Core\Exception\Configuration\InvalidConfigurationException;
|
||||
use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs;
|
||||
use RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface;
|
||||
use RectorPrefix20210622\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
final class Configuration
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isDryRun = \false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showProgressBar = \true;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $shouldClearCache = \false;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $outputFormat;
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $fileExtensions = [];
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $paths = [];
|
||||
/**
|
||||
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
|
||||
*/
|
||||
private $parameterProvider;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showDiffs = \true;
|
||||
/**
|
||||
* @var \Rector\Core\ValueObject\Bootstrap\BootstrapConfigs|null
|
||||
*/
|
||||
private $bootstrapConfigs;
|
||||
public function __construct(\RectorPrefix20210622\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider)
|
||||
{
|
||||
$this->fileExtensions = (array) $parameterProvider->provideParameter(\Rector\Core\Configuration\Option::FILE_EXTENSIONS);
|
||||
$this->paths = (array) $parameterProvider->provideParameter(\Rector\Core\Configuration\Option::PATHS);
|
||||
$this->parameterProvider = $parameterProvider;
|
||||
}
|
||||
/**
|
||||
* Needs to run in the start of the life cycle, since the rest of workflow uses it.
|
||||
*/
|
||||
public function resolveFromInput(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : void
|
||||
{
|
||||
$this->isDryRun = (bool) $input->getOption(\Rector\Core\Configuration\Option::DRY_RUN);
|
||||
$this->shouldClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::CLEAR_CACHE);
|
||||
$this->showProgressBar = $this->canShowProgressBar($input);
|
||||
$this->showDiffs = !(bool) $input->getOption(\Rector\Core\Configuration\Option::NO_DIFFS);
|
||||
$this->outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT);
|
||||
$commandLinePaths = (array) $input->getArgument(\Rector\Core\Configuration\Option::SOURCE);
|
||||
// manual command line value has priority
|
||||
if ($commandLinePaths !== []) {
|
||||
$commandLinePaths = $this->correctBashSpacePaths($commandLinePaths);
|
||||
$this->paths = $commandLinePaths;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @forTests
|
||||
*/
|
||||
public function setIsDryRun(bool $isDryRun) : void
|
||||
{
|
||||
$this->isDryRun = $isDryRun;
|
||||
}
|
||||
public function isDryRun() : bool
|
||||
{
|
||||
return $this->isDryRun;
|
||||
}
|
||||
public function shouldShowProgressBar() : bool
|
||||
{
|
||||
return $this->showProgressBar;
|
||||
}
|
||||
public function shouldClearCache() : bool
|
||||
{
|
||||
return $this->shouldClearCache;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFileExtensions() : array
|
||||
{
|
||||
return $this->fileExtensions;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPaths() : array
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
public function getOutputFormat() : string
|
||||
{
|
||||
return $this->outputFormat;
|
||||
}
|
||||
public function validateConfigParameters() : void
|
||||
{
|
||||
$symfonyContainerXmlPath = (string) $this->parameterProvider->provideParameter(\Rector\Core\Configuration\Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER);
|
||||
if ($symfonyContainerXmlPath === '') {
|
||||
return;
|
||||
}
|
||||
if (\file_exists($symfonyContainerXmlPath)) {
|
||||
return;
|
||||
}
|
||||
$message = \sprintf('Path "%s" for "$parameters->set(Option::%s, ...);" in your config was not found. Correct it', $symfonyContainerXmlPath, 'SYMFONY_CONTAINER_XML_PATH_PARAMETER');
|
||||
throw new \Rector\Core\Exception\Configuration\InvalidConfigurationException($message);
|
||||
}
|
||||
public function shouldHideClutter() : bool
|
||||
{
|
||||
return $this->outputFormat !== \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME;
|
||||
}
|
||||
public function shouldShowDiffs() : bool
|
||||
{
|
||||
return $this->showDiffs;
|
||||
}
|
||||
public function setBootstrapConfigs(\Rector\Core\ValueObject\Bootstrap\BootstrapConfigs $bootstrapConfigs) : void
|
||||
{
|
||||
$this->bootstrapConfigs = $bootstrapConfigs;
|
||||
}
|
||||
public function getMainConfigFilePath() : ?string
|
||||
{
|
||||
if ($this->bootstrapConfigs === null) {
|
||||
return null;
|
||||
}
|
||||
$mainConfigFileInfo = $this->bootstrapConfigs->getMainConfigFileInfo();
|
||||
if (!$mainConfigFileInfo instanceof \Symplify\SmartFileSystem\SmartFileInfo) {
|
||||
return null;
|
||||
}
|
||||
return $mainConfigFileInfo->getRelativeFilePathFromCwd();
|
||||
}
|
||||
private function canShowProgressBar(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : bool
|
||||
{
|
||||
$noProgressBar = (bool) $input->getOption(\Rector\Core\Configuration\Option::NO_PROGRESS_BAR);
|
||||
if ($noProgressBar) {
|
||||
return \false;
|
||||
}
|
||||
$optionOutputFormat = $input->getOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT);
|
||||
return $optionOutputFormat === \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME;
|
||||
}
|
||||
/**
|
||||
* @param string[] $commandLinePaths
|
||||
* @return string[]
|
||||
*/
|
||||
private function correctBashSpacePaths(array $commandLinePaths) : array
|
||||
{
|
||||
// fixes bash edge-case that to merges string with space to one
|
||||
foreach ($commandLinePaths as $commandLinePath) {
|
||||
if (\strpos($commandLinePath, ' ') !== \false) {
|
||||
$commandLinePaths = \explode(' ', $commandLinePath);
|
||||
}
|
||||
}
|
||||
return $commandLinePaths;
|
||||
}
|
||||
}
|
69
src/Configuration/ConfigurationFactory.php
Normal file
69
src/Configuration/ConfigurationFactory.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Configuration;
|
||||
|
||||
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface;
|
||||
use RectorPrefix20210622\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
final class ConfigurationFactory
|
||||
{
|
||||
/**
|
||||
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
|
||||
*/
|
||||
private $parameterProvider;
|
||||
public function __construct(\RectorPrefix20210622\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider)
|
||||
{
|
||||
$this->parameterProvider = $parameterProvider;
|
||||
}
|
||||
/**
|
||||
* Needs to run in the start of the life cycle, since the rest of workflow uses it.
|
||||
*/
|
||||
public function createFromInput(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : \Rector\Core\ValueObject\Configuration
|
||||
{
|
||||
$isDryRun = (bool) $input->getOption(\Rector\Core\Configuration\Option::DRY_RUN);
|
||||
$shouldClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::CLEAR_CACHE);
|
||||
$outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT);
|
||||
$showProgressBar = $this->shouldShowProgressBar($input, $outputFormat);
|
||||
$showDiffs = !(bool) $input->getOption(\Rector\Core\Configuration\Option::NO_DIFFS);
|
||||
$paths = $this->resolvePaths($input);
|
||||
$fileExtensions = $this->parameterProvider->provideArrayParameter(\Rector\Core\Configuration\Option::FILE_EXTENSIONS);
|
||||
return new \Rector\Core\ValueObject\Configuration($isDryRun, $showProgressBar, $shouldClearCache, $outputFormat, $fileExtensions, $paths, $showDiffs);
|
||||
}
|
||||
private function shouldShowProgressBar(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input, string $outputFormat) : bool
|
||||
{
|
||||
$noProgressBar = (bool) $input->getOption(\Rector\Core\Configuration\Option::NO_PROGRESS_BAR);
|
||||
if ($noProgressBar) {
|
||||
return \false;
|
||||
}
|
||||
return $outputFormat === \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME;
|
||||
}
|
||||
/**
|
||||
* @param string[] $commandLinePaths
|
||||
* @return string[]
|
||||
*/
|
||||
private function correctBashSpacePaths(array $commandLinePaths) : array
|
||||
{
|
||||
// fixes bash edge-case that to merges string with space to one
|
||||
foreach ($commandLinePaths as $commandLinePath) {
|
||||
if (\strpos($commandLinePath, ' ') !== \false) {
|
||||
$commandLinePaths = \explode(' ', $commandLinePath);
|
||||
}
|
||||
}
|
||||
return $commandLinePaths;
|
||||
}
|
||||
/**
|
||||
* @return string[]|mixed[]
|
||||
*/
|
||||
private function resolvePaths(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : array
|
||||
{
|
||||
$commandLinePaths = (array) $input->getArgument(\Rector\Core\Configuration\Option::SOURCE);
|
||||
// command line has priority
|
||||
if ($commandLinePaths !== []) {
|
||||
return $this->correctBashSpacePaths($commandLinePaths);
|
||||
}
|
||||
// fallback to parameter
|
||||
return $this->parameterProvider->provideArrayParameter(\Rector\Core\Configuration\Option::PATHS);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\Core\Configuration;
|
||||
|
||||
use RectorPrefix20210622\JetBrains\PhpStorm\Immutable;
|
||||
use RectorPrefix20210622\Symplify\Skipper\ValueObject\Option as SkipperOption;
|
||||
#[Immutable]
|
||||
final class Option
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -9,13 +9,14 @@ use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
|
|||
use Rector\Core\Application\ApplicationFileProcessor;
|
||||
use Rector\Core\Autoloading\AdditionalAutoloader;
|
||||
use Rector\Core\Autoloading\BootstrapFilesIncluder;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Configuration\ConfigurationFactory;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Console\Output\OutputFormatterCollector;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Reporting\MissingRectorRulesReporter;
|
||||
use Rector\Core\StaticReflection\DynamicSourceLocatorDecorator;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\ProcessResult;
|
||||
use Rector\Core\ValueObjectFactory\Application\FileFactory;
|
||||
use Rector\Core\ValueObjectFactory\ProcessResultFactory;
|
||||
|
@ -36,10 +37,6 @@ final class ProcessCommand extends \RectorPrefix20210622\Symfony\Component\Conso
|
|||
* @var \Rector\Caching\Detector\ChangedFilesDetector
|
||||
*/
|
||||
private $changedFilesDetector;
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Rector\Core\Console\Output\OutputFormatterCollector
|
||||
*/
|
||||
|
@ -72,11 +69,14 @@ final class ProcessCommand extends \RectorPrefix20210622\Symfony\Component\Conso
|
|||
* @var \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator
|
||||
*/
|
||||
private $dynamicSourceLocatorDecorator;
|
||||
public function __construct(\Rector\Core\Autoloading\AdditionalAutoloader $additionalAutoloader, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Core\Configuration\Configuration $configuration, \Rector\Core\Console\Output\OutputFormatterCollector $outputFormatterCollector, \Rector\Core\Reporting\MissingRectorRulesReporter $missingRectorRulesReporter, \Rector\Core\Application\ApplicationFileProcessor $applicationFileProcessor, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \Rector\Core\Autoloading\BootstrapFilesIncluder $bootstrapFilesIncluder, \Rector\Core\ValueObjectFactory\ProcessResultFactory $processResultFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator)
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\ConfigurationFactory
|
||||
*/
|
||||
private $configurationFactory;
|
||||
public function __construct(\Rector\Core\Autoloading\AdditionalAutoloader $additionalAutoloader, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Core\Console\Output\OutputFormatterCollector $outputFormatterCollector, \Rector\Core\Reporting\MissingRectorRulesReporter $missingRectorRulesReporter, \Rector\Core\Application\ApplicationFileProcessor $applicationFileProcessor, \Rector\Core\ValueObjectFactory\Application\FileFactory $fileFactory, \Rector\Core\Autoloading\BootstrapFilesIncluder $bootstrapFilesIncluder, \Rector\Core\ValueObjectFactory\ProcessResultFactory $processResultFactory, \PHPStan\Analyser\NodeScopeResolver $nodeScopeResolver, \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, \Rector\Core\Configuration\ConfigurationFactory $configurationFactory)
|
||||
{
|
||||
$this->additionalAutoloader = $additionalAutoloader;
|
||||
$this->changedFilesDetector = $changedFilesDetector;
|
||||
$this->configuration = $configuration;
|
||||
$this->outputFormatterCollector = $outputFormatterCollector;
|
||||
$this->missingRectorRulesReporter = $missingRectorRulesReporter;
|
||||
$this->applicationFileProcessor = $applicationFileProcessor;
|
||||
|
@ -85,6 +85,7 @@ final class ProcessCommand extends \RectorPrefix20210622\Symfony\Component\Conso
|
|||
$this->processResultFactory = $processResultFactory;
|
||||
$this->nodeScopeResolver = $nodeScopeResolver;
|
||||
$this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator;
|
||||
$this->configurationFactory = $configurationFactory;
|
||||
parent::__construct();
|
||||
}
|
||||
protected function configure() : void
|
||||
|
@ -106,28 +107,27 @@ final class ProcessCommand extends \RectorPrefix20210622\Symfony\Component\Conso
|
|||
if ($exitCode !== null) {
|
||||
return $exitCode;
|
||||
}
|
||||
$this->configuration->resolveFromInput($input);
|
||||
$this->configuration->validateConfigParameters();
|
||||
$configuration = $this->configurationFactory->createFromInput($input);
|
||||
// register autoloaded and included files
|
||||
$this->bootstrapFilesIncluder->includeBootstrapFiles();
|
||||
$this->additionalAutoloader->autoloadInput($input);
|
||||
$this->additionalAutoloader->autoloadPaths();
|
||||
$paths = $this->configuration->getPaths();
|
||||
$paths = $configuration->getPaths();
|
||||
// 0. add files and directories to static locator
|
||||
$this->dynamicSourceLocatorDecorator->addPaths($paths);
|
||||
$files = $this->fileFactory->createFromPaths($paths);
|
||||
$files = $this->fileFactory->createFromPaths($paths, $configuration);
|
||||
// PHPStan has to know about all files!
|
||||
$this->configurePHPStanNodeScopeResolver($files);
|
||||
$this->applicationFileProcessor->run($files);
|
||||
$this->applicationFileProcessor->run($files, $configuration);
|
||||
// report diffs and errors
|
||||
$outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT);
|
||||
$outputFormatter = $this->outputFormatterCollector->getByName($outputFormat);
|
||||
// here should be value obect factory
|
||||
$processResult = $this->processResultFactory->create($files);
|
||||
$outputFormatter->report($processResult);
|
||||
$outputFormatter->report($processResult, $configuration);
|
||||
// invalidate affected files
|
||||
$this->invalidateCacheChangedFiles($processResult);
|
||||
return $this->resolveReturnCode($processResult);
|
||||
return $this->resolveReturnCode($processResult, $configuration);
|
||||
}
|
||||
protected function initialize(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20210622\Symfony\Component\Console\Output\OutputInterface $output) : void
|
||||
{
|
||||
|
@ -154,14 +154,14 @@ final class ProcessCommand extends \RectorPrefix20210622\Symfony\Component\Conso
|
|||
$this->changedFilesDetector->invalidateFile($changedFileInfo);
|
||||
}
|
||||
}
|
||||
private function resolveReturnCode(\Rector\Core\ValueObject\ProcessResult $processResult) : int
|
||||
private function resolveReturnCode(\Rector\Core\ValueObject\ProcessResult $processResult, \Rector\Core\ValueObject\Configuration $configuration) : int
|
||||
{
|
||||
// some errors were found → fail
|
||||
if ($processResult->getErrors() !== []) {
|
||||
return \RectorPrefix20210622\Symplify\PackageBuilder\Console\ShellCode::ERROR;
|
||||
}
|
||||
// inverse error code for CI dry-run
|
||||
if (!$this->configuration->isDryRun()) {
|
||||
if (!$configuration->isDryRun()) {
|
||||
return \RectorPrefix20210622\Symplify\PackageBuilder\Console\ShellCode::SUCCESS;
|
||||
}
|
||||
return $processResult->getFileDiffs() === [] ? \RectorPrefix20210622\Symplify\PackageBuilder\Console\ShellCode::SUCCESS : \RectorPrefix20210622\Symplify\PackageBuilder\Console\ShellCode::ERROR;
|
||||
|
|
|
@ -4,13 +4,12 @@ declare (strict_types=1);
|
|||
namespace Rector\Core\Contract\Processor;
|
||||
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
interface FileProcessorInterface
|
||||
{
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file) : bool;
|
||||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
public function process(array $files) : void;
|
||||
// @todo wait for implementers to adapt with 2nd parameters of Configuration $configuration
|
||||
// public function supports(File $file, Configuration $configuration): bool;
|
||||
// public function process(array $files, Configuration $configuration): void;
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
|
|
|
@ -4,10 +4,10 @@ declare (strict_types=1);
|
|||
namespace Rector\Core\DependencyInjection;
|
||||
|
||||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\HttpKernel\RectorKernel;
|
||||
use Rector\Core\Stubs\PHPStanStubLoader;
|
||||
use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use RectorPrefix20210622\Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use RectorPrefix20210622\Symplify\PackageBuilder\Console\Input\StaticInputDetector;
|
||||
|
@ -43,9 +43,6 @@ final class RectorContainerFactory
|
|||
$changedFilesDetector = $container->get(\Rector\Caching\Detector\ChangedFilesDetector::class);
|
||||
$changedFilesDetector->setFirstResolvedConfigFileInfo($mainConfigFileInfo);
|
||||
}
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = $container->get(\Rector\Core\Configuration\Configuration::class);
|
||||
$configuration->setBootstrapConfigs($bootstrapConfigs);
|
||||
return $container;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ final class FilesFinder
|
|||
* @param string[] $suffixes
|
||||
* @return SmartFileInfo[]
|
||||
*/
|
||||
public function findInDirectoriesAndFiles(array $source, array $suffixes) : array
|
||||
public function findInDirectoriesAndFiles(array $source, array $suffixes = []) : array
|
||||
{
|
||||
$filesAndDirectories = $this->filesystemTweaker->resolveWithFnmatch($source);
|
||||
$filePaths = $this->fileSystemFilter->filterFiles($filesAndDirectories);
|
||||
|
@ -81,8 +81,11 @@ final class FilesFinder
|
|||
if ($directories === []) {
|
||||
return [];
|
||||
}
|
||||
$suffixesPattern = $this->normalizeSuffixesToPattern($suffixes);
|
||||
$finder = \RectorPrefix20210622\Symfony\Component\Finder\Finder::create()->followLinks()->files()->size('> 0')->in($directories)->name($suffixesPattern)->sortByName();
|
||||
$finder = \RectorPrefix20210622\Symfony\Component\Finder\Finder::create()->followLinks()->files()->size('> 0')->in($directories)->sortByName();
|
||||
if ($suffixes !== []) {
|
||||
$suffixesPattern = $this->normalizeSuffixesToPattern($suffixes);
|
||||
$finder->name($suffixesPattern);
|
||||
}
|
||||
$this->addFilterWithExcludedPaths($finder);
|
||||
$smartFileInfos = $this->finderSanitizer->sanitize($finder);
|
||||
return $this->unchangedFilesFilter->filterAndJoinWithDependentFileInfos($smartFileInfos);
|
||||
|
|
|
@ -4,7 +4,6 @@ declare (strict_types=1);
|
|||
namespace Rector\Core\FileSystem;
|
||||
|
||||
use Rector\Caching\UnchangedFilesFilter;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
final class PhpFilesFinder
|
||||
{
|
||||
|
@ -12,18 +11,13 @@ final class PhpFilesFinder
|
|||
* @var \Rector\Core\FileSystem\FilesFinder
|
||||
*/
|
||||
private $filesFinder;
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Rector\Caching\UnchangedFilesFilter
|
||||
*/
|
||||
private $unchangedFilesFilter;
|
||||
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Core\Configuration\Configuration $configuration, \Rector\Caching\UnchangedFilesFilter $unchangedFilesFilter)
|
||||
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Caching\UnchangedFilesFilter $unchangedFilesFilter)
|
||||
{
|
||||
$this->filesFinder = $filesFinder;
|
||||
$this->configuration = $configuration;
|
||||
$this->unchangedFilesFilter = $unchangedFilesFilter;
|
||||
}
|
||||
/**
|
||||
|
@ -32,7 +26,7 @@ final class PhpFilesFinder
|
|||
*/
|
||||
public function findInPaths(array $paths) : array
|
||||
{
|
||||
$phpFileInfos = $this->filesFinder->findInDirectoriesAndFiles($paths, $this->configuration->getFileExtensions());
|
||||
$phpFileInfos = $this->filesFinder->findInDirectoriesAndFiles($paths);
|
||||
// filter out non-PHP php files, e.g. blade templates in Laravel
|
||||
$phpFileInfos = \array_filter($phpFileInfos, function (\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool {
|
||||
return \substr_compare($smartFileInfo->getPathname(), '.blade.php', -\strlen('.blade.php')) !== 0;
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Rector\Core\NonPhpFile;
|
|||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\Contract\Rector\NonPhpRectorInterface;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
use Rector\Core\ValueObject\StaticNonPhpFileSuffixes;
|
||||
/**
|
||||
* @see \Rector\Tests\Renaming\Rector\Name\RenameClassRector\RenameNonPhpTest
|
||||
|
@ -26,26 +27,29 @@ final class NonPhpFileProcessor implements \Rector\Core\Contract\Processor\FileP
|
|||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
public function process(array $files) : void
|
||||
public function process(array $files, \Rector\Core\ValueObject\Configuration $configuration) : void
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$this->processFile($file);
|
||||
}
|
||||
}
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file) : bool
|
||||
public function supports(\Rector\Core\ValueObject\Application\File $file, \Rector\Core\ValueObject\Configuration $configuration) : bool
|
||||
{
|
||||
$smartFileInfo = $file->getSmartFileInfo();
|
||||
// early assign to variable for increase performance
|
||||
// @see https://3v4l.org/FM3vY#focus=8.0.7 vs https://3v4l.org/JZW7b#focus=8.0.7
|
||||
$pathname = $smartFileInfo->getPathname();
|
||||
// bug in path extension
|
||||
foreach ($this->getSupportedFileExtensions() as $supportedFileExtension) {
|
||||
if (\substr_compare($pathname, '.' . $supportedFileExtension, -\strlen('.' . $supportedFileExtension)) === 0) {
|
||||
foreach ($this->getSupportedFileExtensions() as $fileExtension) {
|
||||
if (\substr_compare($pathname, '.' . $fileExtension, -\strlen('.' . $fileExtension)) === 0) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSupportedFileExtensions() : array
|
||||
{
|
||||
return \Rector\Core\ValueObject\StaticNonPhpFileSuffixes::SUFFIXES;
|
||||
|
|
105
src/ValueObject/Configuration.php
Normal file
105
src/ValueObject/Configuration.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\ValueObject;
|
||||
|
||||
use RectorPrefix20210622\JetBrains\PhpStorm\Immutable;
|
||||
use Rector\ChangesReporting\Output\ConsoleOutputFormatter;
|
||||
use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
#[Immutable]
|
||||
final class Configuration
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isDryRun = \false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showProgressBar = \true;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $shouldClearCache = \false;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $outputFormat = \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME;
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $fileExtensions = ['php'];
|
||||
/**
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $paths = [];
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $showDiffs = \true;
|
||||
/**
|
||||
* @var \Rector\Core\ValueObject\Bootstrap\BootstrapConfigs|null
|
||||
*/
|
||||
private $bootstrapConfigs;
|
||||
/**
|
||||
* @param string[] $fileExtensions
|
||||
* @param string[] $paths
|
||||
*/
|
||||
public function __construct(bool $isDryRun = \false, bool $showProgressBar = \true, bool $shouldClearCache = \false, string $outputFormat = \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME, array $fileExtensions = ['php'], array $paths = [], bool $showDiffs = \true, ?\Rector\Core\ValueObject\Bootstrap\BootstrapConfigs $bootstrapConfigs = null)
|
||||
{
|
||||
$this->isDryRun = $isDryRun;
|
||||
$this->showProgressBar = $showProgressBar;
|
||||
$this->shouldClearCache = $shouldClearCache;
|
||||
$this->outputFormat = $outputFormat;
|
||||
$this->fileExtensions = $fileExtensions;
|
||||
$this->paths = $paths;
|
||||
$this->showDiffs = $showDiffs;
|
||||
$this->bootstrapConfigs = $bootstrapConfigs;
|
||||
}
|
||||
public function isDryRun() : bool
|
||||
{
|
||||
return $this->isDryRun;
|
||||
}
|
||||
public function shouldShowProgressBar() : bool
|
||||
{
|
||||
return $this->showProgressBar;
|
||||
}
|
||||
public function shouldClearCache() : bool
|
||||
{
|
||||
return $this->shouldClearCache;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getFileExtensions() : array
|
||||
{
|
||||
return $this->fileExtensions;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPaths() : array
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
public function getOutputFormat() : string
|
||||
{
|
||||
return $this->outputFormat;
|
||||
}
|
||||
public function shouldShowDiffs() : bool
|
||||
{
|
||||
return $this->showDiffs;
|
||||
}
|
||||
public function getMainConfigFilePath() : ?string
|
||||
{
|
||||
if ($this->bootstrapConfigs === null) {
|
||||
return null;
|
||||
}
|
||||
$mainConfigFileInfo = $this->bootstrapConfigs->getMainConfigFileInfo();
|
||||
if (!$mainConfigFileInfo instanceof \Symplify\SmartFileSystem\SmartFileInfo) {
|
||||
return null;
|
||||
}
|
||||
return $mainConfigFileInfo->getRelativeFilePathFromCwd();
|
||||
}
|
||||
}
|
|
@ -4,10 +4,10 @@ declare (strict_types=1);
|
|||
namespace Rector\Core\ValueObjectFactory\Application;
|
||||
|
||||
use Rector\Caching\Detector\ChangedFilesDetector;
|
||||
use Rector\Core\Configuration\Configuration;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
use Rector\Core\FileSystem\FilesFinder;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\Core\ValueObject\Configuration;
|
||||
/**
|
||||
* @see \Rector\Core\ValueObject\Application\File
|
||||
*/
|
||||
|
@ -17,10 +17,6 @@ final class FileFactory
|
|||
* @var \Rector\Core\FileSystem\FilesFinder
|
||||
*/
|
||||
private $filesFinder;
|
||||
/**
|
||||
* @var \Rector\Core\Configuration\Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
/**
|
||||
* @var \Rector\Caching\Detector\ChangedFilesDetector
|
||||
*/
|
||||
|
@ -32,10 +28,9 @@ final class FileFactory
|
|||
/**
|
||||
* @param FileProcessorInterface[] $fileProcessors
|
||||
*/
|
||||
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Core\Configuration\Configuration $configuration, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, array $fileProcessors)
|
||||
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, array $fileProcessors)
|
||||
{
|
||||
$this->filesFinder = $filesFinder;
|
||||
$this->configuration = $configuration;
|
||||
$this->changedFilesDetector = $changedFilesDetector;
|
||||
$this->fileProcessors = $fileProcessors;
|
||||
}
|
||||
|
@ -43,12 +38,12 @@ final class FileFactory
|
|||
* @param string[] $paths
|
||||
* @return File[]
|
||||
*/
|
||||
public function createFromPaths(array $paths) : array
|
||||
public function createFromPaths(array $paths, \Rector\Core\ValueObject\Configuration $configuration) : array
|
||||
{
|
||||
if ($this->configuration->shouldClearCache()) {
|
||||
if ($configuration->shouldClearCache()) {
|
||||
$this->changedFilesDetector->clear();
|
||||
}
|
||||
$supportedFileExtensions = $this->resolveSupportedFileExtensions();
|
||||
$supportedFileExtensions = $this->resolveSupportedFileExtensions($configuration);
|
||||
$fileInfos = $this->filesFinder->findInDirectoriesAndFiles($paths, $supportedFileExtensions);
|
||||
$files = [];
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
|
@ -59,12 +54,14 @@ final class FileFactory
|
|||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveSupportedFileExtensions() : array
|
||||
private function resolveSupportedFileExtensions(\Rector\Core\ValueObject\Configuration $configuration) : array
|
||||
{
|
||||
$supportedFileExtensions = [];
|
||||
foreach ($this->fileProcessors as $fileProcessor) {
|
||||
$supportedFileExtensions = \array_merge($supportedFileExtensions, $fileProcessor->getSupportedFileExtensions());
|
||||
}
|
||||
// basic PHP extensions
|
||||
$supportedFileExtensions = \array_merge($supportedFileExtensions, $configuration->getFileExtensions());
|
||||
return \array_unique($supportedFileExtensions);
|
||||
}
|
||||
}
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb::getLoader();
|
||||
return ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373::getLoader();
|
||||
|
|
3
vendor/composer/autoload_classmap.php
vendored
3
vendor/composer/autoload_classmap.php
vendored
|
@ -1784,7 +1784,7 @@ return array(
|
|||
'Rector\\Core\\Autoloading\\BootstrapFilesIncluder' => $baseDir . '/src/Autoloading/BootstrapFilesIncluder.php',
|
||||
'Rector\\Core\\Bootstrap\\ExtensionConfigResolver' => $baseDir . '/src/Bootstrap/ExtensionConfigResolver.php',
|
||||
'Rector\\Core\\Bootstrap\\RectorConfigsResolver' => $baseDir . '/src/Bootstrap/RectorConfigsResolver.php',
|
||||
'Rector\\Core\\Configuration\\Configuration' => $baseDir . '/src/Configuration/Configuration.php',
|
||||
'Rector\\Core\\Configuration\\ConfigurationFactory' => $baseDir . '/src/Configuration/ConfigurationFactory.php',
|
||||
'Rector\\Core\\Configuration\\CurrentNodeProvider' => $baseDir . '/src/Configuration/CurrentNodeProvider.php',
|
||||
'Rector\\Core\\Configuration\\Option' => $baseDir . '/src/Configuration/Option.php',
|
||||
'Rector\\Core\\Configuration\\RenamedClassesDataCollector' => $baseDir . '/src/Configuration/RenamedClassesDataCollector.php',
|
||||
|
@ -1913,6 +1913,7 @@ return array(
|
|||
'Rector\\Core\\ValueObject\\Application\\File' => $baseDir . '/src/ValueObject/Application/File.php',
|
||||
'Rector\\Core\\ValueObject\\Application\\RectorError' => $baseDir . '/src/ValueObject/Application/RectorError.php',
|
||||
'Rector\\Core\\ValueObject\\Bootstrap\\BootstrapConfigs' => $baseDir . '/src/ValueObject/Bootstrap/BootstrapConfigs.php',
|
||||
'Rector\\Core\\ValueObject\\Configuration' => $baseDir . '/src/ValueObject/Configuration.php',
|
||||
'Rector\\Core\\ValueObject\\FrameworkName' => $baseDir . '/src/ValueObject/FrameworkName.php',
|
||||
'Rector\\Core\\ValueObject\\MethodName' => $baseDir . '/src/ValueObject/MethodName.php',
|
||||
'Rector\\Core\\ValueObject\\PhpVersion' => $baseDir . '/src/ValueObject/PhpVersion.php',
|
||||
|
|
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 ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb
|
||||
class ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit8babd35b8005ae82a5ffad65b7c65373::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit8babd35b8005ae82a5ffad65b7c65373::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire02537cdb2637850b8e6e18edb9df94cb($fileIdentifier, $file);
|
||||
composerRequire8babd35b8005ae82a5ffad65b7c65373($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire02537cdb2637850b8e6e18edb9df94cb($fileIdentifier, $file)
|
||||
function composerRequire8babd35b8005ae82a5ffad65b7c65373($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
11
vendor/composer/autoload_static.php
vendored
11
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb
|
||||
class ComposerStaticInit8babd35b8005ae82a5ffad65b7c65373
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -2139,7 +2139,7 @@ class ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb
|
|||
'Rector\\Core\\Autoloading\\BootstrapFilesIncluder' => __DIR__ . '/../..' . '/src/Autoloading/BootstrapFilesIncluder.php',
|
||||
'Rector\\Core\\Bootstrap\\ExtensionConfigResolver' => __DIR__ . '/../..' . '/src/Bootstrap/ExtensionConfigResolver.php',
|
||||
'Rector\\Core\\Bootstrap\\RectorConfigsResolver' => __DIR__ . '/../..' . '/src/Bootstrap/RectorConfigsResolver.php',
|
||||
'Rector\\Core\\Configuration\\Configuration' => __DIR__ . '/../..' . '/src/Configuration/Configuration.php',
|
||||
'Rector\\Core\\Configuration\\ConfigurationFactory' => __DIR__ . '/../..' . '/src/Configuration/ConfigurationFactory.php',
|
||||
'Rector\\Core\\Configuration\\CurrentNodeProvider' => __DIR__ . '/../..' . '/src/Configuration/CurrentNodeProvider.php',
|
||||
'Rector\\Core\\Configuration\\Option' => __DIR__ . '/../..' . '/src/Configuration/Option.php',
|
||||
'Rector\\Core\\Configuration\\RenamedClassesDataCollector' => __DIR__ . '/../..' . '/src/Configuration/RenamedClassesDataCollector.php',
|
||||
|
@ -2268,6 +2268,7 @@ class ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb
|
|||
'Rector\\Core\\ValueObject\\Application\\File' => __DIR__ . '/../..' . '/src/ValueObject/Application/File.php',
|
||||
'Rector\\Core\\ValueObject\\Application\\RectorError' => __DIR__ . '/../..' . '/src/ValueObject/Application/RectorError.php',
|
||||
'Rector\\Core\\ValueObject\\Bootstrap\\BootstrapConfigs' => __DIR__ . '/../..' . '/src/ValueObject/Bootstrap/BootstrapConfigs.php',
|
||||
'Rector\\Core\\ValueObject\\Configuration' => __DIR__ . '/../..' . '/src/ValueObject/Configuration.php',
|
||||
'Rector\\Core\\ValueObject\\FrameworkName' => __DIR__ . '/../..' . '/src/ValueObject/FrameworkName.php',
|
||||
'Rector\\Core\\ValueObject\\MethodName' => __DIR__ . '/../..' . '/src/ValueObject/MethodName.php',
|
||||
'Rector\\Core\\ValueObject\\PhpVersion' => __DIR__ . '/../..' . '/src/ValueObject/PhpVersion.php',
|
||||
|
@ -3868,9 +3869,9 @@ class ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit02537cdb2637850b8e6e18edb9df94cb::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit8babd35b8005ae82a5ffad65b7c65373::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit8babd35b8005ae82a5ffad65b7c65373::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit8babd35b8005ae82a5ffad65b7c65373::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
|
|||
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
|
||||
spl_autoload_call('RectorPrefix20210622\CheckoutEntityFactory');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb', false) && !interface_exists('ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb', false) && !trait_exists('ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb', false)) {
|
||||
spl_autoload_call('RectorPrefix20210622\ComposerAutoloaderInit02537cdb2637850b8e6e18edb9df94cb');
|
||||
if (!class_exists('ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373', false) && !interface_exists('ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373', false) && !trait_exists('ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373', false)) {
|
||||
spl_autoload_call('RectorPrefix20210622\ComposerAutoloaderInit8babd35b8005ae82a5ffad65b7c65373');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210622\Doctrine\Inflector\Inflector');
|
||||
|
@ -3323,9 +3323,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210622\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire02537cdb2637850b8e6e18edb9df94cb')) {
|
||||
function composerRequire02537cdb2637850b8e6e18edb9df94cb() {
|
||||
return \RectorPrefix20210622\composerRequire02537cdb2637850b8e6e18edb9df94cb(...func_get_args());
|
||||
if (!function_exists('composerRequire8babd35b8005ae82a5ffad65b7c65373')) {
|
||||
function composerRequire8babd35b8005ae82a5ffad65b7c65373() {
|
||||
return \RectorPrefix20210622\composerRequire8babd35b8005ae82a5ffad65b7c65373(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user