Updated Rector to commit 8f0a09cc249e2725936a0eff3dd2651ebb10881a

8f0a09cc24 [Bridge] Add SetRectorsResolver, SetProviderCollector for easier use in 3rd-party tools (#6030)
This commit is contained in:
Tomas Votruba 2024-06-25 07:21:34 +00:00
parent c5c2d1fbd8
commit c49badceec
5 changed files with 97 additions and 2 deletions

View File

@ -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
*/

View File

@ -0,0 +1,56 @@
<?php
declare (strict_types=1);
namespace Rector\Bridge;
use Rector\Doctrine\Set\SetProvider\DoctrineSetProvider;
use Rector\PHPUnit\Set\SetProvider\PHPUnitSetProvider;
use Rector\Set\Contract\SetInterface;
use Rector\Set\Contract\SetProviderInterface;
use Rector\Set\SetProvider\CoreSetProvider;
use Rector\Set\SetProvider\PHPSetProvider;
use Rector\Symfony\Set\SetProvider\SymfonySetProvider;
use Rector\Symfony\Set\SetProvider\TwigSetProvider;
/**
* @api
* @experimental since 1.1.2
* Utils class to ease building bridges by 3rd-party tools
*/
final class SetProviderCollector
{
/**
* @var SetProviderInterface[]
* @readonly
*/
private $setProviders;
public function __construct()
{
$this->setProviders = [
// register all known set providers here
new PHPSetProvider(),
new CoreSetProvider(),
new PHPUnitSetProvider(),
new SymfonySetProvider(),
new DoctrineSetProvider(),
new TwigSetProvider(),
];
}
/**
* @return array<SetProviderInterface>
*/
public function provide() : array
{
return $this->setProviders;
}
/**
* @return array<SetInterface>
*/
public function provideSets() : array
{
$sets = [];
foreach ($this->setProviders as $setProvider) {
$sets = \array_merge($sets, $setProvider->provide());
}
return $sets;
}
}

View File

@ -0,0 +1,35 @@
<?php
declare (strict_types=1);
namespace Rector\Bridge;
use Rector\Config\RectorConfig;
use Rector\Contract\Rector\RectorInterface;
use ReflectionProperty;
use RectorPrefix202406\Webmozart\Assert\Assert;
/**
* @api
* @experimental since 1.1.2
* Utils class to ease building bridges by 3rd-party tools
*/
final class SetRectorsResolver
{
/**
* @return array<class-string<RectorInterface>>
*/
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);
}
}

View File

@ -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',

View File

@ -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',