diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 0a8f652a315..720e6e85fbd 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '373747cef4e013317763c78df56f370203e33d4b'; + public const PACKAGE_VERSION = 'fb18cc7970063c5a08351767e3af3a7461e34b5b'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-11-14 18:08:41'; + public const RELEASE_DATE = '2024-11-14 19:08:30'; /** * @var int */ diff --git a/src/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php b/src/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php deleted file mode 100644 index b6c0cdc71e0..00000000000 --- a/src/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php +++ /dev/null @@ -1,35 +0,0 @@ -tokenIteratorFactory = $tokenIteratorFactory; - parent::__construct($constExprParser); - } - public function parse(TokenIterator $tokenIterator) : TypeNode - { - $betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator); - $startPosition = $betterTokenIterator->currentPosition(); - $typeNode = parent::parse($betterTokenIterator); - $endPosition = $betterTokenIterator->currentPosition(); - $startAndEnd = new StartAndEnd($startPosition, $endPosition); - $typeNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd); - return $typeNode; - } -} diff --git a/src/Configuration/Option.php b/src/Configuration/Option.php index f5ea0d23ffa..a1c545bc96a 100644 --- a/src/Configuration/Option.php +++ b/src/Configuration/Option.php @@ -222,4 +222,10 @@ final class Option * @var string */ public const EDITOR_URL = 'editor_url'; + /** + * @internal To report composer based loaded sets + * @see \Rector\Configuration\RectorConfigBuilder::withComposerBased() + * @var string + */ + public const COMPOSER_BASED_SETS = 'composer_based_sets'; } diff --git a/src/Configuration/RectorConfigBuilder.php b/src/Configuration/RectorConfigBuilder.php index 4da6fbdfbf9..762e59a2a1b 100644 --- a/src/Configuration/RectorConfigBuilder.php +++ b/src/Configuration/RectorConfigBuilder.php @@ -14,6 +14,7 @@ use Rector\Config\Level\TypeDeclarationLevel; use Rector\Config\RectorConfig; use Rector\Config\RegisteredService; use Rector\Configuration\Levels\LevelRulesResolver; +use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Console\Notifier; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\Contract\Rector\RectorInterface; @@ -197,6 +198,7 @@ final class RectorConfigBuilder if ($this->setGroups !== []) { $setManager = new SetManager(new SetProviderCollector(), new InstalledPackageResolver(\getcwd())); $this->groupLoadedSets = $setManager->matchBySetGroups($this->setGroups); + SimpleParameterProvider::addParameter(\Rector\Configuration\Option::COMPOSER_BASED_SETS, $this->groupLoadedSets); } // merge sets together $this->sets = \array_merge($this->sets, $this->groupLoadedSets); diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index 173b77f6879..9f4d0248005 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -10,6 +10,7 @@ use Rector\ChangesReporting\Output\JsonOutputFormatter; use Rector\Configuration\ConfigInitializer; use Rector\Configuration\ConfigurationFactory; use Rector\Configuration\Option; +use Rector\Configuration\Parameter\SimpleParameterProvider; use Rector\Console\ExitCode; use Rector\Console\Output\OutputFormatterCollector; use Rector\Console\ProcessConfigureDecorator; @@ -151,6 +152,10 @@ EOF $this->symfonyStyle->error(\sprintf('The following given path%s do%s not match any file%s or director%s: %s%s', $isSingular ? '' : 's', $isSingular ? 'es' : '', $isSingular ? '' : 's', $isSingular ? 'y' : 'ies', \PHP_EOL . \PHP_EOL . ' - ', \implode(\PHP_EOL . ' - ', $paths))); return ExitCode::FAILURE; } + // show debug info + if ($configuration->isDebug()) { + $this->reportLoadedComposerBasedSets(); + } // MAIN PHASE // 2. run Rector $processResult = $this->applicationFileProcessor->run($configuration, $input); @@ -199,4 +204,16 @@ EOF } return ExitCode::SUCCESS; } + private function reportLoadedComposerBasedSets() : void + { + if (!SimpleParameterProvider::hasParameter(Option::COMPOSER_BASED_SETS)) { + return; + } + $composerBasedSets = SimpleParameterProvider::provideArrayParameter(Option::COMPOSER_BASED_SETS); + if ($composerBasedSets === []) { + return; + } + $this->symfonyStyle->writeln('[info] Sets loaded based on installed packages:'); + $this->symfonyStyle->listing($composerBasedSets); + } } diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index aef82bf6340..676e43f417e 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -28,7 +28,6 @@ use Rector\BetterPhpDocParser\PhpDocNodeVisitor\TemplatePhpDocNodeVisitor; use Rector\BetterPhpDocParser\PhpDocNodeVisitor\UnionTypeNodePhpDocNodeVisitor; use Rector\BetterPhpDocParser\PhpDocParser\ArrayItemClassNameDecorator; use Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser; -use Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser; use Rector\BetterPhpDocParser\PhpDocParser\ConstExprClassNameDecorator; use Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator; use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser; @@ -265,7 +264,6 @@ final class LazyContainerFactory // phpdoc-parser $rectorConfig->when(TypeParser::class)->needs('$usedAttributes')->give(['lines' => \true, 'indexes' => \true]); $rectorConfig->when(ConstExprParser::class)->needs('$usedAttributes')->give(['lines' => \true, 'indexes' => \true]); - $rectorConfig->alias(TypeParser::class, BetterTypeParser::class); $rectorConfig->when(RectorNodeTraverser::class)->needs('$rectors')->giveTagged(RectorInterface::class); $rectorConfig->when(ConfigInitializer::class)->needs('$rectors')->giveTagged(RectorInterface::class); $rectorConfig->when(ClassNameImportSkipper::class)->needs('$classNameImportSkipVoters')->giveTagged(ClassNameImportSkipVoterInterface::class); diff --git a/templates/rector.php.dist b/templates/rector.php.dist index 66de15a7c1f..93ac7276613 100644 --- a/templates/rector.php.dist +++ b/templates/rector.php.dist @@ -10,4 +10,6 @@ __PATHS__ ]) // uncomment to reach your current PHP version // ->withPhpSets() - ->withTypeCoverageLevel(0); + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 207c899978f..1741179a136 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1032,7 +1032,6 @@ return array( 'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\UnionTypeNodePhpDocNodeVisitor' => $baseDir . '/src/BetterPhpDocParser/PhpDocNodeVisitor/UnionTypeNodePhpDocNodeVisitor.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\ArrayItemClassNameDecorator' => $baseDir . '/src/BetterPhpDocParser/PhpDocParser/ArrayItemClassNameDecorator.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\BetterPhpDocParser' => $baseDir . '/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php', - 'Rector\\BetterPhpDocParser\\PhpDocParser\\BetterTypeParser' => $baseDir . '/src/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\ClassAnnotationMatcher' => $baseDir . '/src/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\ConstExprClassNameDecorator' => $baseDir . '/src/BetterPhpDocParser/PhpDocParser/ConstExprClassNameDecorator.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\DoctrineAnnotationDecorator' => $baseDir . '/src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 36de83d908e..6896099a978 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -1251,7 +1251,6 @@ class ComposerStaticInit58d677395c7d7c6a1b0f093c876515de 'Rector\\BetterPhpDocParser\\PhpDocNodeVisitor\\UnionTypeNodePhpDocNodeVisitor' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocNodeVisitor/UnionTypeNodePhpDocNodeVisitor.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\ArrayItemClassNameDecorator' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocParser/ArrayItemClassNameDecorator.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\BetterPhpDocParser' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocParser/BetterPhpDocParser.php', - 'Rector\\BetterPhpDocParser\\PhpDocParser\\BetterTypeParser' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocParser/BetterTypeParser.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\ClassAnnotationMatcher' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\ConstExprClassNameDecorator' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocParser/ConstExprClassNameDecorator.php', 'Rector\\BetterPhpDocParser\\PhpDocParser\\DoctrineAnnotationDecorator' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/PhpDocParser/DoctrineAnnotationDecorator.php',