From c49badceec0348d7c43e934bbead7235f96a3ca1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 25 Jun 2024 07:21:34 +0000 Subject: [PATCH] Updated Rector to commit 8f0a09cc249e2725936a0eff3dd2651ebb10881a https://github.com/rectorphp/rector-src/commit/8f0a09cc249e2725936a0eff3dd2651ebb10881a [Bridge] Add SetRectorsResolver, SetProviderCollector for easier use in 3rd-party tools (#6030) --- src/Application/VersionResolver.php | 4 +- src/Bridge/SetProviderCollector.php | 56 +++++++++++++++++++++++++++ src/Bridge/SetRectorsResolver.php | 35 +++++++++++++++++ vendor/composer/autoload_classmap.php | 2 + vendor/composer/autoload_static.php | 2 + 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 src/Bridge/SetProviderCollector.php create mode 100644 src/Bridge/SetRectorsResolver.php diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 4bdda5da902..75bdec2b2dd 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 = '221aa01fe23a3b998768e9461cf75e8be0a9d67d'; + public const PACKAGE_VERSION = '8f0a09cc249e2725936a0eff3dd2651ebb10881a'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-06-25 13:19:20'; + public const RELEASE_DATE = '2024-06-25 07:19:16'; /** * @var int */ diff --git a/src/Bridge/SetProviderCollector.php b/src/Bridge/SetProviderCollector.php new file mode 100644 index 00000000000..35b6ccd42f6 --- /dev/null +++ b/src/Bridge/SetProviderCollector.php @@ -0,0 +1,56 @@ +setProviders = [ + // register all known set providers here + new PHPSetProvider(), + new CoreSetProvider(), + new PHPUnitSetProvider(), + new SymfonySetProvider(), + new DoctrineSetProvider(), + new TwigSetProvider(), + ]; + } + /** + * @return array + */ + public function provide() : array + { + return $this->setProviders; + } + /** + * @return array + */ + public function provideSets() : array + { + $sets = []; + foreach ($this->setProviders as $setProvider) { + $sets = \array_merge($sets, $setProvider->provide()); + } + return $sets; + } +} diff --git a/src/Bridge/SetRectorsResolver.php b/src/Bridge/SetRectorsResolver.php new file mode 100644 index 00000000000..9971267f30d --- /dev/null +++ b/src/Bridge/SetRectorsResolver.php @@ -0,0 +1,35 @@ +> + */ + public function resolveFromFilePath(string $configFilePath) : array + { + Assert::fileExists($configFilePath); + $rectorConfig = new RectorConfig(); + /** @var callable $configCallable */ + $configCallable = (require $configFilePath); + $configCallable($rectorConfig); + // get tagged class-names + $tagsReflectionProperty = new ReflectionProperty($rectorConfig, 'tags'); + $tagsReflectionProperty->setAccessible(\true); + $tags = $tagsReflectionProperty->getValue($rectorConfig); + $rectorClasses = $tags[RectorInterface::class] ?? []; + \sort($rectorClasses); + return \array_unique($rectorClasses); + } +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index ec4e6ef959b..0ebcccf737b 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -1038,6 +1038,8 @@ return array( 'Rector\\BetterPhpDocParser\\ValueObject\\Type\\SpacingAwareCallableTypeNode' => $baseDir . '/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php', 'Rector\\Bootstrap\\ExtensionConfigResolver' => $baseDir . '/src/Bootstrap/ExtensionConfigResolver.php', 'Rector\\Bootstrap\\RectorConfigsResolver' => $baseDir . '/src/Bootstrap/RectorConfigsResolver.php', + 'Rector\\Bridge\\SetProviderCollector' => $baseDir . '/src/Bridge/SetProviderCollector.php', + 'Rector\\Bridge\\SetRectorsResolver' => $baseDir . '/src/Bridge/SetRectorsResolver.php', 'Rector\\Caching\\Cache' => $baseDir . '/src/Caching/Cache.php', 'Rector\\Caching\\CacheFactory' => $baseDir . '/src/Caching/CacheFactory.php', 'Rector\\Caching\\Config\\FileHashComputer' => $baseDir . '/src/Caching/Config/FileHashComputer.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index f129e440b16..4b3842f9f9f 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -1257,6 +1257,8 @@ class ComposerStaticInitd98d3a989b9f99591f8f5a74c164268a 'Rector\\BetterPhpDocParser\\ValueObject\\Type\\SpacingAwareCallableTypeNode' => __DIR__ . '/../..' . '/src/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php', 'Rector\\Bootstrap\\ExtensionConfigResolver' => __DIR__ . '/../..' . '/src/Bootstrap/ExtensionConfigResolver.php', 'Rector\\Bootstrap\\RectorConfigsResolver' => __DIR__ . '/../..' . '/src/Bootstrap/RectorConfigsResolver.php', + 'Rector\\Bridge\\SetProviderCollector' => __DIR__ . '/../..' . '/src/Bridge/SetProviderCollector.php', + 'Rector\\Bridge\\SetRectorsResolver' => __DIR__ . '/../..' . '/src/Bridge/SetRectorsResolver.php', 'Rector\\Caching\\Cache' => __DIR__ . '/../..' . '/src/Caching/Cache.php', 'Rector\\Caching\\CacheFactory' => __DIR__ . '/../..' . '/src/Caching/CacheFactory.php', 'Rector\\Caching\\Config\\FileHashComputer' => __DIR__ . '/../..' . '/src/Caching/Config/FileHashComputer.php',