mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
Updated Rector to commit 8f0a09cc249e2725936a0eff3dd2651ebb10881a
8f0a09cc24
[Bridge] Add SetRectorsResolver, SetProviderCollector for easier use in 3rd-party tools (#6030)
This commit is contained in:
parent
c5c2d1fbd8
commit
c49badceec
@ -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
|
||||
*/
|
||||
|
56
src/Bridge/SetProviderCollector.php
Normal file
56
src/Bridge/SetProviderCollector.php
Normal 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;
|
||||
}
|
||||
}
|
35
src/Bridge/SetRectorsResolver.php
Normal file
35
src/Bridge/SetRectorsResolver.php
Normal 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);
|
||||
}
|
||||
}
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@ -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',
|
||||
|
2
vendor/composer/autoload_static.php
vendored
2
vendor/composer/autoload_static.php
vendored
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user