From 98ca09597d43a2f99ca967c5223fc4d0b0ff2b54 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 22 Jun 2021 15:56:17 +0000 Subject: [PATCH] Updated Rector to commit 0c035c390d4afd73b76f186313d4b7f7d906e072 https://github.com/rectorphp/rector-src/commit/5689cbe017b00e01278c75ebe6a03d3be8c3e029 remove passing extra fileInfo with file, already included https://github.com/rectorphp/rector-src/commit/7bba40aa32fd48ed16af71ea7ab6a8ed4fdde198 remove OPTION_ prefix https://github.com/rectorphp/rector-src/commit/c2ce6104d3f7f15434f947aa6842e0bccb0d9964 remove extra parma in value object https://github.com/rectorphp/rector-src/commit/77a90c5fd4a61435b757aeca7275a09764ddb656 remove is cache debug https://github.com/rectorphp/rector-src/commit/ff3de640d4e4a705ba49cfee748451cfed96f17c add shot options constant https://github.com/rectorphp/rector-src/commit/0c035c390d4afd73b76f186313d4b7f7d906e072 misc --- config/set/downgrade-php80.php | 2 +- .../Parser/FileInfoParser.php | 2 +- .../NodeScopeAndMetadataDecorator.php | 5 +-- .../Scope/PHPStanNodeScopeResolver.php | 15 --------- .../Testing/TestingParser/TestingParser.php | 2 +- .../DowngradeAttributeToAnnotationRector.php | 2 +- .../DowngradeAttributeToAnnotation.php | 9 ++++-- src/Application/FileProcessor.php | 2 +- src/Application/VersionResolver.php | 4 +-- src/Autoloading/AdditionalAutoloader.php | 7 ++-- src/Configuration/Configuration.php | 24 ++++---------- src/Configuration/Option.php | 32 ++++++++++++------- src/Console/Command/ProcessCommand.php | 19 ++++++----- src/Console/Command/ShowCommand.php | 4 +-- src/Console/ConsoleApplication.php | 6 ++-- .../FunctionLikeReflectionParser.php | 2 +- .../DynamicSourceLocatorDecorator.php | 3 ++ vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 14 ++++---- vendor/composer/autoload_static.php | 8 ++--- vendor/scoper-autoload.php | 10 +++--- 21 files changed, 79 insertions(+), 95 deletions(-) diff --git a/config/set/downgrade-php80.php b/config/set/downgrade-php80.php index 54c7beefc18a..f13722439f0e 100644 --- a/config/set/downgrade-php80.php +++ b/config/set/downgrade-php80.php @@ -30,7 +30,7 @@ // @see https://wiki.php.net/rfc/stringable 'Stringable', ]]]); - $services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class)->call('configure', [[\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Attribute', 'Attribute')])]]); + $services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class)->call('configure', [[\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Attribute')])]]); $services->set(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class); $services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class); $services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class); diff --git a/packages/FileSystemRector/Parser/FileInfoParser.php b/packages/FileSystemRector/Parser/FileInfoParser.php index 4df2c183ebfc..034539adecc0 100644 --- a/packages/FileSystemRector/Parser/FileInfoParser.php +++ b/packages/FileSystemRector/Parser/FileInfoParser.php @@ -30,6 +30,6 @@ public function parseFileInfoToNodesAndDecorate(\Symplify\SmartFileSystem\SmartF { $oldStmts = $this->parser->parseFileInfo($smartFileInfo); $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); - return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts, $smartFileInfo); + return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts); } } diff --git a/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php b/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php index 67e6882ba0df..5ad385252570 100644 --- a/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php +++ b/packages/NodeTypeResolver/NodeScopeAndMetadataDecorator.php @@ -16,7 +16,6 @@ use Rector\NodeTypeResolver\NodeVisitor\NamespaceNodeVisitor; use Rector\NodeTypeResolver\NodeVisitor\StatementNodeVisitor; use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver; -use Symplify\SmartFileSystem\SmartFileInfo; final class NodeScopeAndMetadataDecorator { /** @@ -66,7 +65,7 @@ public function __construct(\PhpParser\NodeVisitor\CloningVisitor $cloningVisito * @param Stmt[] $nodes * @return Stmt[] */ - public function decorateNodesFromFile(\Rector\Core\ValueObject\Application\File $file, array $nodes, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array + public function decorateNodesFromFile(\Rector\Core\ValueObject\Application\File $file, array $nodes) : array { $nodeTraverser = new \PhpParser\NodeTraverser(); $nodeTraverser->addVisitor(new \PhpParser\NodeVisitor\NameResolver(null, [ @@ -74,7 +73,9 @@ public function decorateNodesFromFile(\Rector\Core\ValueObject\Application\File // required by PHPStan 'replaceNodes' => \true, ])); + /** @var Stmt[] $nodes */ $nodes = $nodeTraverser->traverse($nodes); + $smartFileInfo = $file->getSmartFileInfo(); $nodes = $this->phpStanNodeScopeResolver->processNodes($nodes, $smartFileInfo); $nodeTraverser = new \PhpParser\NodeTraverser(); $preservingNameResolver = new \PhpParser\NodeVisitor\NameResolver(null, [ diff --git a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index f67d06239e8e..2cff2a30e55c 100644 --- a/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/packages/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -178,7 +178,6 @@ private function reportCacheDebugAndSaveDependentFiles(\Symplify\SmartFileSystem if (!$this->configuration->isCacheEnabled()) { return; } - $this->reportCacheDebug($smartFileInfo, $dependentFiles); // save for cache $this->changedFilesDetector->addFileWithDependencies($smartFileInfo, $dependentFiles); } @@ -195,18 +194,4 @@ private function resolveClassName($classLike) : string } return $classLike->name->toString(); } - /** - * @param string[] $dependentFiles - */ - private function reportCacheDebug(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo, array $dependentFiles) : void - { - if (!$this->configuration->isCacheDebug()) { - return; - } - $message = \sprintf('[debug] %d dependencies for "%s" file', \count($dependentFiles), $smartFileInfo->getRealPath()); - $this->symfonyStyle->note($message); - if ($dependentFiles !== []) { - $this->symfonyStyle->listing($dependentFiles); - } - } } diff --git a/packages/Testing/TestingParser/TestingParser.php b/packages/Testing/TestingParser/TestingParser.php index e4c9367ef977..55fa2b1f7120 100644 --- a/packages/Testing/TestingParser/TestingParser.php +++ b/packages/Testing/TestingParser/TestingParser.php @@ -47,7 +47,7 @@ public function parseFileToDecoratedNodes(string $file) : array $this->parameterProvider->changeParameter(\Rector\Core\Configuration\Option::SOURCE, [$file]); $nodes = $this->parser->parseFileInfo($smartFileInfo); $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); - return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $nodes, $smartFileInfo); + return $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $nodes); } /** * @template T of Node diff --git a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php index 52c5eabf81f6..d9b9f5af4848 100644 --- a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php +++ b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php @@ -66,7 +66,7 @@ public function action() } } CODE_SAMPLE -, [self::ATTRIBUTE_TO_ANNOTATION => [new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Component\\Routing\\Annotation\\Route', 'Symfony\\Component\\Routing\\Annotation\\Route')]])]); +, [self::ATTRIBUTE_TO_ANNOTATION => [new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Component\\Routing\\Annotation\\Route')]])]); } /** * @return array> diff --git a/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php b/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php index e1e36e9de146..a3bed80a05a7 100644 --- a/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php +++ b/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php @@ -10,14 +10,14 @@ final class DowngradeAttributeToAnnotation */ private $attributeClass; /** - * @var string + * @var string|null */ private $tag; /** * @param class-string $attributeClass - * @param class-string|string $tag + * @param class-string|string|null $tag */ - public function __construct(string $attributeClass, string $tag) + public function __construct(string $attributeClass, ?string $tag = null) { $this->attributeClass = $attributeClass; $this->tag = $tag; @@ -28,6 +28,9 @@ public function getAttributeClass() : string } public function getTag() : string { + if ($this->tag === null) { + return $this->attributeClass; + } return $this->tag; } } diff --git a/src/Application/FileProcessor.php b/src/Application/FileProcessor.php index bdb911a0bb7f..7e3c704c28ec 100644 --- a/src/Application/FileProcessor.php +++ b/src/Application/FileProcessor.php @@ -45,7 +45,7 @@ public function parseFileInfoToLocalCache(\Rector\Core\ValueObject\Application\F $smartFileInfo = $file->getSmartFileInfo(); $oldStmts = $this->parser->parseFileInfo($smartFileInfo); $oldTokens = $this->lexer->getTokens(); - $newStmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts, $smartFileInfo); + $newStmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $oldStmts); $file->hydrateStmtsAndTokens($newStmts, $oldStmts, $oldTokens); } public function refactor(\Rector\Core\ValueObject\Application\File $file) : void diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 2212e8dd9299..20a65f5368a6 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '28891ea62d7ee55dd7a247668b43aa10e6aec4ae'; + public const PACKAGE_VERSION = '0c035c390d4afd73b76f186313d4b7f7d906e072'; /** * @var string */ - public const RELEASE_DATE = '2021-06-22 17:24:53'; + public const RELEASE_DATE = '2021-06-22 17:45:36'; public static function resolvePackageVersion() : string { $process = new \RectorPrefix20210622\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); diff --git a/src/Autoloading/AdditionalAutoloader.php b/src/Autoloading/AdditionalAutoloader.php index dcb84b403fbe..9d1cff0c6bef 100644 --- a/src/Autoloading/AdditionalAutoloader.php +++ b/src/Autoloading/AdditionalAutoloader.php @@ -33,11 +33,11 @@ public function __construct(\RectorPrefix20210622\Symplify\SmartFileSystem\FileS } public function autoloadInput(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : void { - if (!$input->hasOption(\Rector\Core\Configuration\Option::OPTION_AUTOLOAD_FILE)) { + if (!$input->hasOption(\Rector\Core\Configuration\Option::AUTOLOAD_FILE)) { return; } /** @var string|null $autoloadFile */ - $autoloadFile = $input->getOption(\Rector\Core\Configuration\Option::OPTION_AUTOLOAD_FILE); + $autoloadFile = $input->getOption(\Rector\Core\Configuration\Option::AUTOLOAD_FILE); if ($autoloadFile === null) { return; } @@ -47,9 +47,6 @@ public function autoloadInput(\RectorPrefix20210622\Symfony\Component\Console\In public function autoloadPaths() : void { $autoloadPaths = $this->parameterProvider->provideArrayParameter(\Rector\Core\Configuration\Option::AUTOLOAD_PATHS); - if ($autoloadPaths === []) { - return; - } $this->dynamicSourceLocatorDecorator->addPaths($autoloadPaths); } } diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index 1a523a39cf3a..e64a4ae4706e 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -27,10 +27,6 @@ final class Configuration * @var string */ private $outputFormat; - /** - * @var bool - */ - private $isCacheDebug = \false; /** * @var bool */ @@ -67,12 +63,11 @@ public function __construct(\RectorPrefix20210622\Symplify\PackageBuilder\Parame */ public function resolveFromInput(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : void { - $this->isDryRun = (bool) $input->getOption(\Rector\Core\Configuration\Option::OPTION_DRY_RUN); - $this->shouldClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::OPTION_CLEAR_CACHE); + $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::OPTION_NO_DIFFS); - $this->isCacheDebug = (bool) $input->getOption(\Rector\Core\Configuration\Option::CACHE_DEBUG); - $this->outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OPTION_OUTPUT_FORMAT); + $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 !== []) { @@ -93,19 +88,12 @@ public function isDryRun() : bool } public function shouldShowProgressBar() : bool { - if ($this->isCacheDebug) { - return \false; - } return $this->showProgressBar; } public function shouldClearCache() : bool { return $this->shouldClearCache; } - public function isCacheDebug() : bool - { - return $this->isCacheDebug; - } public function isCacheEnabled() : bool { return $this->isCacheEnabled; @@ -165,11 +153,11 @@ public function getMainConfigFilePath() : ?string } private function canShowProgressBar(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input) : bool { - $noProgressBar = (bool) $input->getOption(\Rector\Core\Configuration\Option::OPTION_NO_PROGRESS_BAR); + $noProgressBar = (bool) $input->getOption(\Rector\Core\Configuration\Option::NO_PROGRESS_BAR); if ($noProgressBar) { return \false; } - $optionOutputFormat = $input->getOption(\Rector\Core\Configuration\Option::OPTION_OUTPUT_FORMAT); + $optionOutputFormat = $input->getOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT); return $optionOutputFormat === \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME; } /** diff --git a/src/Configuration/Option.php b/src/Configuration/Option.php index a0983dc66f7b..0ff346297fcb 100644 --- a/src/Configuration/Option.php +++ b/src/Configuration/Option.php @@ -13,7 +13,7 @@ final class Option /** * @var string */ - public const OPTION_AUTOLOAD_FILE = 'autoload-file'; + public const AUTOLOAD_FILE = 'autoload-file'; /** * @var string */ @@ -21,15 +21,19 @@ final class Option /** * @var string */ - public const OPTION_DRY_RUN = 'dry-run'; + public const DRY_RUN = 'dry-run'; /** * @var string */ - public const OPTION_OUTPUT_FORMAT = 'output-format'; + public const DRY_RUN_SHORT = 'n'; /** * @var string */ - public const OPTION_NO_PROGRESS_BAR = 'no-progress-bar'; + public const OUTPUT_FORMAT = 'output-format'; + /** + * @var string + */ + public const NO_PROGRESS_BAR = 'no-progress-bar'; /** * @var string */ @@ -53,15 +57,11 @@ final class Option /** * @var string */ - public const OPTION_CLEAR_CACHE = 'clear-cache'; + public const CLEAR_CACHE = 'clear-cache'; /** * @var string */ public const ENABLE_CACHE = 'enable_cache'; - /** - * @var string - */ - public const CACHE_DEBUG = 'cache-debug'; /** * @var string */ @@ -89,7 +89,7 @@ final class Option /** * @var string */ - public const OPTION_DEBUG = 'debug'; + public const DEBUG = 'debug'; /** * @var string */ @@ -97,7 +97,7 @@ final class Option /** * @var string */ - public const OPTION_CONFIG = 'config'; + public const CONFIG = 'config'; /** * @var string */ @@ -109,7 +109,7 @@ final class Option /** * @var string */ - public const OPTION_NO_DIFFS = 'no-diffs'; + public const NO_DIFFS = 'no-diffs'; /** * @var string */ @@ -118,4 +118,12 @@ final class Option * @var string */ public const ENABLE_EDITORCONFIG = 'enable_editorconfig'; + /** + * @var string + */ + public const AUTOLOAD_FILE_SHORT = 'a'; + /** + * @var string + */ + public const OUTPUT_FORMAT_SHORT = 'o'; } diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index 62eff160fdc9..44b6229061be 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -91,15 +91,14 @@ protected function configure() : void { $this->setDescription('Upgrade or refactor source code with provided rectors'); $this->addArgument(\Rector\Core\Configuration\Option::SOURCE, \RectorPrefix20210622\Symfony\Component\Console\Input\InputArgument::OPTIONAL | \RectorPrefix20210622\Symfony\Component\Console\Input\InputArgument::IS_ARRAY, 'Files or directories to be upgraded.'); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_DRY_RUN, 'n', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'See diff of changes, do not save them to files.'); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_AUTOLOAD_FILE, 'a', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'File with extra autoload'); + $this->addOption(\Rector\Core\Configuration\Option::DRY_RUN, \Rector\Core\Configuration\Option::DRY_RUN_SHORT, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'See diff of changes, do not save them to files.'); + $this->addOption(\Rector\Core\Configuration\Option::AUTOLOAD_FILE, \Rector\Core\Configuration\Option::AUTOLOAD_FILE_SHORT, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'File with extra autoload'); $names = $this->outputFormatterCollector->getNames(); $description = \sprintf('Select output format: "%s".', \implode('", "', $names)); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_OUTPUT_FORMAT, 'o', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, $description, \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_NO_PROGRESS_BAR, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Hide progress bar. Useful e.g. for nicer CI output.'); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_NO_DIFFS, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Hide diffs of changed files. Useful e.g. for nicer CI output.'); - $this->addOption(\Rector\Core\Configuration\Option::CACHE_DEBUG, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Debug changed file cache'); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_CLEAR_CACHE, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Clear unchaged files cache'); + $this->addOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT, \Rector\Core\Configuration\Option::OUTPUT_FORMAT_SHORT, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, $description, \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME); + $this->addOption(\Rector\Core\Configuration\Option::NO_PROGRESS_BAR, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Hide progress bar. Useful e.g. for nicer CI output.'); + $this->addOption(\Rector\Core\Configuration\Option::NO_DIFFS, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Hide diffs of changed files. Useful e.g. for nicer CI output.'); + $this->addOption(\Rector\Core\Configuration\Option::CLEAR_CACHE, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Clear unchaged files cache'); } protected function execute(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20210622\Symfony\Component\Console\Output\OutputInterface $output) : int { @@ -121,7 +120,7 @@ protected function execute(\RectorPrefix20210622\Symfony\Component\Console\Input $this->configurePHPStanNodeScopeResolver($files); $this->applicationFileProcessor->run($files); // report diffs and errors - $outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OPTION_OUTPUT_FORMAT); + $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); @@ -136,7 +135,7 @@ protected function initialize(\RectorPrefix20210622\Symfony\Component\Console\In if (!$application instanceof \RectorPrefix20210622\Symfony\Component\Console\Application) { throw new \Rector\Core\Exception\ShouldNotHappenException(); } - $optionDebug = (bool) $input->getOption(\Rector\Core\Configuration\Option::OPTION_DEBUG); + $optionDebug = (bool) $input->getOption(\Rector\Core\Configuration\Option::DEBUG); if ($optionDebug) { $application->setCatchExceptions(\false); // clear cache @@ -144,7 +143,7 @@ protected function initialize(\RectorPrefix20210622\Symfony\Component\Console\In return; } // clear cache - $optionClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::OPTION_CLEAR_CACHE); + $optionClearCache = (bool) $input->getOption(\Rector\Core\Configuration\Option::CLEAR_CACHE); if ($optionClearCache) { $this->changedFilesDetector->clear(); } diff --git a/src/Console/Command/ShowCommand.php b/src/Console/Command/ShowCommand.php index 21056f347a5d..93d48e237337 100644 --- a/src/Console/Command/ShowCommand.php +++ b/src/Console/Command/ShowCommand.php @@ -43,11 +43,11 @@ protected function configure() : void $this->setDescription('Show loaded Rectors with their configuration'); $names = $this->showOutputFormatterCollector->getNames(); $description = \sprintf('Select output format: "%s".', \implode('", "', $names)); - $this->addOption(\Rector\Core\Configuration\Option::OPTION_OUTPUT_FORMAT, 'o', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, $description, \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME); + $this->addOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT, 'o', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_OPTIONAL, $description, \Rector\ChangesReporting\Output\ConsoleOutputFormatter::NAME); } protected function execute(\RectorPrefix20210622\Symfony\Component\Console\Input\InputInterface $input, \RectorPrefix20210622\Symfony\Component\Console\Output\OutputInterface $output) : int { - $outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OPTION_OUTPUT_FORMAT); + $outputFormat = (string) $input->getOption(\Rector\Core\Configuration\Option::OUTPUT_FORMAT); $this->reportLoadedRectors($outputFormat); return \RectorPrefix20210622\Symplify\PackageBuilder\Console\ShellCode::SUCCESS; } diff --git a/src/Console/ConsoleApplication.php b/src/Console/ConsoleApplication.php index 48e03be14b18..4bf3a50f35c0 100644 --- a/src/Console/ConsoleApplication.php +++ b/src/Console/ConsoleApplication.php @@ -103,10 +103,10 @@ private function removeUnusedOptions(\RectorPrefix20210622\Symfony\Component\Con } private function addCustomOptions(\RectorPrefix20210622\Symfony\Component\Console\Input\InputDefinition $inputDefinition) : void { - $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::OPTION_CONFIG, 'c', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Path to config file', $this->getDefaultConfigPath())); - $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::OPTION_DEBUG, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Enable debug verbosity (-vvv)')); + $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::CONFIG, 'c', \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'Path to config file', $this->getDefaultConfigPath())); + $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::DEBUG, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Enable debug verbosity (-vvv)')); $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::XDEBUG, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Allow running xdebug')); - $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::OPTION_CLEAR_CACHE, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Clear cache')); + $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption(\Rector\Core\Configuration\Option::CLEAR_CACHE, null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_NONE, 'Clear cache')); $inputDefinition->addOption(new \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption('working-dir', null, \RectorPrefix20210622\Symfony\Component\Console\Input\InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.')); } private function getDefaultConfigPath() : string diff --git a/src/Reflection/FunctionLikeReflectionParser.php b/src/Reflection/FunctionLikeReflectionParser.php index 2eae968de1c8..982055c35ebf 100644 --- a/src/Reflection/FunctionLikeReflectionParser.php +++ b/src/Reflection/FunctionLikeReflectionParser.php @@ -77,7 +77,7 @@ public function parseMethodReflection(\PHPStan\Reflection\MethodReflection $meth $nodes = (array) $this->parser->parse($fileContent); $smartFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($fileName); $file = new \Rector\Core\ValueObject\Application\File($smartFileInfo, $smartFileInfo->getContents()); - $nodes = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $nodes, $smartFileInfo); + $nodes = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($file, $nodes); $class = $this->nodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Class_::class); if (!$class instanceof \PhpParser\Node\Stmt\Class_) { return null; diff --git a/src/StaticReflection/DynamicSourceLocatorDecorator.php b/src/StaticReflection/DynamicSourceLocatorDecorator.php index 5fff3cd249d9..3cd284508dfc 100644 --- a/src/StaticReflection/DynamicSourceLocatorDecorator.php +++ b/src/StaticReflection/DynamicSourceLocatorDecorator.php @@ -35,6 +35,9 @@ public function __construct(\RectorPrefix20210622\Symplify\SmartFileSystem\FileS */ public function addPaths(array $paths) : void { + if ($paths === []) { + return; + } $files = $this->fileSystemFilter->filterFiles($paths); $this->dynamicSourceLocatorProvider->addFiles($files); $directories = $this->fileSystemFilter->filterDirectories($paths); diff --git a/vendor/autoload.php b/vendor/autoload.php index 425ec10e5bfb..4a0e4ef2f477 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f::getLoader(); +return ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 15a8ad31154e..5e23a8c00435 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f +class ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b { private static $loader; @@ -22,15 +22,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b', '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\ComposerStaticInitd80854e8a6fe965ca7944db3a256157f::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit3fbf0929cc1ff1fc5e070dfc2b26765b::getInitializer($loader)); } else { $classMap = require __DIR__ . '/autoload_classmap.php'; if ($classMap) { @@ -42,19 +42,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitd80854e8a6fe965ca7944db3a256157f::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit3fbf0929cc1ff1fc5e070dfc2b26765b::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequired80854e8a6fe965ca7944db3a256157f($fileIdentifier, $file); + composerRequire3fbf0929cc1ff1fc5e070dfc2b26765b($fileIdentifier, $file); } return $loader; } } -function composerRequired80854e8a6fe965ca7944db3a256157f($fileIdentifier, $file) +function composerRequire3fbf0929cc1ff1fc5e070dfc2b26765b($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 03e1da95bc3b..01dd5c40e7d3 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitd80854e8a6fe965ca7944db3a256157f +class ComposerStaticInit3fbf0929cc1ff1fc5e070dfc2b26765b { public static $files = array ( 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', @@ -3869,9 +3869,9 @@ class ComposerStaticInitd80854e8a6fe965ca7944db3a256157f public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitd80854e8a6fe965ca7944db3a256157f::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitd80854e8a6fe965ca7944db3a256157f::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitd80854e8a6fe965ca7944db3a256157f::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit3fbf0929cc1ff1fc5e070dfc2b26765b::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit3fbf0929cc1ff1fc5e070dfc2b26765b::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit3fbf0929cc1ff1fc5e070dfc2b26765b::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index b6e05fa261d2..c987b1178dd2 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -21,8 +21,8 @@ if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) { spl_autoload_call('RectorPrefix20210622\CheckoutEntityFactory'); } -if (!class_exists('ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f', false) && !interface_exists('ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f', false) && !trait_exists('ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f', false)) { - spl_autoload_call('RectorPrefix20210622\ComposerAutoloaderInitd80854e8a6fe965ca7944db3a256157f'); +if (!class_exists('ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b', false) && !interface_exists('ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b', false) && !trait_exists('ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b', false)) { + spl_autoload_call('RectorPrefix20210622\ComposerAutoloaderInit3fbf0929cc1ff1fc5e070dfc2b26765b'); } 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 @@ function print_node() { return \RectorPrefix20210622\print_node(...func_get_args()); } } -if (!function_exists('composerRequired80854e8a6fe965ca7944db3a256157f')) { - function composerRequired80854e8a6fe965ca7944db3a256157f() { - return \RectorPrefix20210622\composerRequired80854e8a6fe965ca7944db3a256157f(...func_get_args()); +if (!function_exists('composerRequire3fbf0929cc1ff1fc5e070dfc2b26765b')) { + function composerRequire3fbf0929cc1ff1fc5e070dfc2b26765b() { + return \RectorPrefix20210622\composerRequire3fbf0929cc1ff1fc5e070dfc2b26765b(...func_get_args()); } } if (!function_exists('parseArgs')) {