make use of new set from symplify

This commit is contained in:
TomasVotruba 2020-07-21 13:42:17 +02:00
parent 77ff617767
commit 2eb21e1087
14 changed files with 224 additions and 250 deletions

View File

@ -12,6 +12,7 @@ use Rector\Core\Configuration\RectorConfigsResolver;
use Rector\Core\Console\Application;
use Rector\Core\Console\Style\SymfonyStyleFactory;
use Rector\Core\DependencyInjection\RectorContainerFactory;
use Symplify\PackageBuilder\Console\ShellCode;
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
@ini_set('memory_limit', '-1'); // @ intentionally: continue anyway
@ -47,23 +48,23 @@ try {
/** @var Configuration $configuration */
$configuration = $container->get(Configuration::class);
$configuration->setFirstResolverConfig($rectorConfigsResolver->getFirstResolvedConfig());
$configuration->setFirstResolverConfigFileInfo($rectorConfigsResolver->getFirstResolvedConfig());
if ($rectorConfigsResolver->getFirstResolvedConfig()) {
/** @var ChangedFilesDetector $changedFilesDetector */
$changedFilesDetector = $container->get(ChangedFilesDetector::class);
$changedFilesDetector->setFirstUsedConfig(realpath($rectorConfigsResolver->getFirstResolvedConfig()));
$changedFilesDetector->setFirstResolvedConfigFileInfo($rectorConfigsResolver->getFirstResolvedConfig());
}
} catch (Throwable $throwable) {
$symfonyStyle = (new SymfonyStyleFactory(new PrivatesCaller()))->create();
$symfonyStyle->error($throwable->getMessage());
exit(1);
exit(ShellCode::ERROR);
}
$application = $container->get(Application::class);
exit($application->run());
final class AutoloadIncluder
{
/**

View File

@ -29,12 +29,15 @@
"symfony/dependency-injection": "^4.4.8|^5.0.6",
"symfony/finder": "^4.4.8|^5.0.6",
"symfony/process": "^4.4.8|^5.0.6",
"symplify/auto-bind-parameter": "^8.1.9",
"symplify/autowire-array-parameter": "^8.1.9",
"symplify/console-color-diff": "^8.1.9",
"symplify/package-builder": "^8.1.9",
"symplify/parameter-name-guard": "^8.1.9",
"symplify/set-config-resolver": "^8.1.9",
"symplify/auto-bind-parameter": "dev-master",
"symplify/autowire-array-parameter": "dev-master",
"symplify/console-color-diff": "dev-master",
"symplify/package-builder": "dev-master",
"symplify/parameter-name-guard": "dev-master",
"symplify/set-config-resolver": "dev-master",
"symplify/composer-json-manipulator": "dev-master",
"symplify/smart-file-system": "dev-master",
"symplify/coding-standard": "dev-master",
"tracy/tracy": "^2.7",
"phpstan/phpstan": "0.12.32"
},
@ -47,11 +50,11 @@
"psr/event-dispatcher": "^1.0",
"slam/phpstan-extensions": "^5.0",
"slevomat/coding-standard": "dev-master",
"symplify/changelog-linker": "^8.1.9",
"symplify/easy-coding-standard": "^8.1.9",
"symplify/easy-testing": "^8.1.9",
"symplify/monorepo-builder": "^8.1.9",
"symplify/phpstan-extensions": "^8.1.9",
"symplify/changelog-linker": "dev-master",
"symplify/easy-coding-standard": "dev-master",
"symplify/easy-testing": "dev-master",
"symplify/monorepo-builder": "dev-master",
"symplify/phpstan-extensions": "dev-master",
"thecodingmachine/phpstan-strict-rules": "^0.12"
},
"autoload": {

View File

@ -15,7 +15,13 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/nette-to-symfony/*.php');
$containerConfigurator->import(__DIR__ . '/nette-to-symfony-doctrine.php');
$containerConfigurator->import(__DIR__ . '/nette-control-to-symfony-controller.php');
$containerConfigurator->import(__DIR__ . '/nette-tester-to-phpunit.php');
$containerConfigurator->import(__DIR__ . '/kdyby-to-symfony.php');
$services = $containerConfigurator->services();

View File

@ -101,11 +101,11 @@ final class ChangedFilesDetector
/**
* @api
*/
public function setFirstUsedConfig(string $firstConfig): void
public function setFirstResolvedConfigFileInfo(SmartFileInfo $fileInfo): void
{
// the first config is core to all → if it was changed, just invalidate it
$configHash = $this->fileHashComputer->compute($firstConfig);
$this->storeConfigurationDataHash($firstConfig, $configHash);
$configHash = $this->fileHashComputer->compute($fileInfo);
$this->storeConfigurationDataHash($fileInfo, $configHash);
}
private function getFileInfoCacheKey(SmartFileInfo $smartFileInfo): string
@ -126,9 +126,9 @@ final class ChangedFilesDetector
$this->tagAwareAdapter->save($cacheItem);
}
private function storeConfigurationDataHash(string $configPath, string $configurationHash): void
private function storeConfigurationDataHash(SmartFileInfo $fileInfo, string $configurationHash): void
{
$key = self::CONFIGURATION_HASH_KEY . '_' . Strings::webalize($configPath);
$key = self::CONFIGURATION_HASH_KEY . '_' . Strings::webalize($fileInfo->getRealPath());
$this->invalidateCacheIfConfigurationChanged($key, $configurationHash);

View File

@ -4,7 +4,6 @@ declare(strict_types=1);
namespace Rector\Caching\Config;
use Nette\Utils\Strings;
use Rector\Core\Exception\ShouldNotHappenException;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
@ -13,33 +12,34 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symplify\SmartFileSystem\SmartFileInfo;
/**
* Inspired by https://github.com/symplify/easy-coding-standard/blob/e598ab54686e416788f28fcfe007fd08e0f371d9/packages/changed-files-detector/src/FileHashComputer.php
*/
final class FileHashComputer
{
public function compute(string $filePath): string
public function compute(SmartFileInfo $fileInfo): string
{
$this->ensureIsYamlOrPhp($filePath);
$this->ensureIsYamlOrPhp($fileInfo);
$containerBuilder = new ContainerBuilder();
$fileLoader = $this->createFileLoader($filePath, $containerBuilder);
$fileLoader = $this->createFileLoader($fileInfo, $containerBuilder);
$fileLoader->load($filePath);
$fileLoader->load($fileInfo->getRealPath());
return $this->arrayToHash($containerBuilder->getDefinitions()) .
$this->arrayToHash($containerBuilder->getParameterBag()->all());
}
private function ensureIsYamlOrPhp(string $filePath): void
private function ensureIsYamlOrPhp(SmartFileInfo $fileInfo): void
{
if (Strings::match($filePath, '#\.(yml|yaml|php)$#')) {
if ($fileInfo->hasSuffixes(['yml', 'yaml', 'php'])) {
return;
}
throw new ShouldNotHappenException(sprintf(
'Provide only YAML/PHP file, ready for Symfony Dependency Injection. "%s" given', $filePath
'Provide only YAML/PHP file, ready for Symfony Dependency Injection. "%s" given', $fileInfo
));
}
@ -51,16 +51,16 @@ final class FileHashComputer
return md5(serialize($array));
}
private function createFileLoader(string $filePath, ContainerBuilder $containerBuilder): LoaderInterface
private function createFileLoader(SmartFileInfo $fileInfo, ContainerBuilder $containerBuilder): LoaderInterface
{
$fileLocator = new FileLocator([dirname($filePath)]);
$fileLocator = new FileLocator([$fileInfo->getPath()]);
$loaderResolver = new LoaderResolver([
new GlobFileLoader($containerBuilder, $fileLocator),
new PhpFileLoader($containerBuilder, $fileLocator),
new YamlFileLoader($containerBuilder, $fileLocator),
]);
$loader = $loaderResolver->resolve($filePath);
$loader = $loaderResolver->resolve($fileInfo->getRealPath());
if (! $loader) {
throw new ShouldNotHappenException();
}

View File

@ -9,6 +9,7 @@ use Rector\Caching\Config\FileHashComputer;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\HttpKernel\RectorKernel;
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;
final class FileHashComputerTest extends AbstractKernelTestCase
{
@ -28,8 +29,8 @@ final class FileHashComputerTest extends AbstractKernelTestCase
*/
public function testHashIsIdentical(string $firstConfig, string $secondConfig): void
{
$configAHash = $this->fileHashComputer->compute($firstConfig);
$configBHash = $this->fileHashComputer->compute($secondConfig);
$configAHash = $this->fileHashComputer->compute(new SmartFileInfo($firstConfig));
$configBHash = $this->fileHashComputer->compute(new SmartFileInfo($secondConfig));
$this->assertSame($configAHash, $configBHash);
}
@ -43,6 +44,6 @@ final class FileHashComputerTest extends AbstractKernelTestCase
public function testInvalidType(): void
{
$this->expectException(ShouldNotHappenException::class);
$this->fileHashComputer->compute(__DIR__ . '/Source/file.xml');
$this->fileHashComputer->compute(new SmartFileInfo(__DIR__ . '/Source/file.xml'));
}
}

View File

@ -0,0 +1 @@
some xml

View File

@ -6,7 +6,7 @@ namespace Rector\RectorGenerator\ValueObject;
use Nette\Utils\Strings;
use Rector\Core\Util\StaticRectorStrings;
use Rector\Set\ValueObject\Set;
use Symplify\SetConfigResolver\ValueObject\Set;
final class Configuration
{
@ -164,7 +164,7 @@ final class Configuration
return null;
}
return $this->set->getFileRealPath();
return $this->set->getSetFileInfo()->getRealPath();
}
public function isPhpSnippet(): bool

View File

@ -4,184 +4,172 @@ declare(strict_types=1);
namespace Rector\Set;
use Rector\Set\ValueObject\Set;
use Rector\Set\ValueObject\SetList;
use Symplify\SetConfigResolver\Provider\AbstractSetProvider;
use Symplify\SetConfigResolver\ValueObject\Set;
use Symplify\SmartFileSystem\SmartFileInfo;
final class SetProvider
final class SetProvider extends AbstractSetProvider
{
/**
* @var array<string, string>
* @var Set[]
*/
private const SET_PATH_TO_FILEPATH = [
SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION => __DIR__ . '/../../../config/set/action-injection-to-constructor-injection.php',
SetList::ARRAY_STR_FUNCTIONS_TO_STATIC_CALL => __DIR__ . '/../../../config/set/laravel-array-str-functions-to-static-call.php',
SetList::CAKEPHP_30 => __DIR__ . '/../../../config/set/cakephp30.php',
SetList::CAKEPHP_34 => __DIR__ . '/../../../config/set/cakephp34.php',
SetList::CAKEPHP_35 => __DIR__ . '/../../../config/set/cakephp35.php',
SetList::CAKEPHP_36 => __DIR__ . '/../../../config/set/cakephp36.php',
SetList::CAKEPHP_37 => __DIR__ . '/../../../config/set/cakephp37.php',
SetList::CAKEPHP_38 => __DIR__ . '/../../../config/set/cakephp38.php',
SetList::CAKEPHP_40 => __DIR__ . '/../../../config/set/cakephp40.php',
SetList::CAKEPHP_FLUENT_OPTIONS => __DIR__ . '/../../../config/set/cakephp-fluent-options.php',
SetList::CELEBRITY => __DIR__ . '/../../../config/set/celebrity.php',
SetList::CODEIGNITER_40 => __DIR__ . '/../../../config/set/codeigniter-40.php',
SetList::CODE_QUALITY => __DIR__ . '/../../../config/set/code-quality.php',
SetList::CODING_STYLE => __DIR__ . '/../../../config/set/coding-style.php',
SetList::CONSTRUCTOR_INJECTIN_TO_ACTION_INJECTION => __DIR__ . '/../../../config/set/constructor-injectin-to-action-injection.php',
SetList::CONTRIBUTTE_TO_SYMFONY => __DIR__ . '/../../../config/set/contributte-to-symfony.php',
SetList::DEAD_CLASSES => __DIR__ . '/../../../config/set/dead-classes.php',
SetList::DEAD_CODE => __DIR__ . '/../../../config/set/dead-code.php',
SetList::DOCTRINE_25 => __DIR__ . '/../../../config/set/doctrine25.php',
SetList::DOCTRINE_BEHAVIORS_20 => __DIR__ . '/../../../config/set/doctrine-behaviors-20.php',
SetList::DOCTRINE_CODE_QUALITY => __DIR__ . '/../../../config/set/doctrine-code-quality.php',
SetList::DOCTRINE_COMMON_20 => __DIR__ . '/../../../config/set/doctrine-common-20.php',
SetList::DOCTRINE_DBAL_210 => __DIR__ . '/../../../config/set/doctrine-dbal-210.php',
SetList::DOCTRINE_DBAL_30 => __DIR__ . '/../../../config/set/doctrine-dbal-30.php',
SetList::DOCTRINE_GEDMO_TO_KNPLABS => __DIR__ . '/../../../config/set/doctrine-gedmo-to-knplabs.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_1 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-1.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_2 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-2.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_3 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-3.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_4 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-4.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_5 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-5.php',
SetList::DOCTRINE_REPOSITORY_AS_SERVICE => __DIR__ . '/../../../config/set/doctrine-repository-as-service.php',
SetList::DOCTRINE_SERVICES => __DIR__ . '/../../../config/set/doctrine-services.php',
SetList::DOWNGRADE => __DIR__ . '/../../../config/set/downgrade.php',
SetList::EASY_ADMIN_BUNDLE_20 => __DIR__ . '/../../../config/set/easy-admin-bundle20.php',
SetList::ELASTICSEARCH_DSL_50 => __DIR__ . '/../../../config/set/elasticsearch-dsl50.php',
SetList::FRAMEWORK_EXTRA_BUNDLE_40 => __DIR__ . '/../../../config/set/framework-extra-bundle-40.php',
SetList::FRAMEWORK_EXTRA_BUNDLE_50 => __DIR__ . '/../../../config/set/framework-extra-bundle-50.php',
SetList::GMAGICK_TO_IMAGICK => __DIR__ . '/../../../config/set/gmagick_to_imagick.php',
SetList::GUZZLE_50 => __DIR__ . '/../../../config/set/guzzle50.php',
SetList::JMS_DECOUPLE => __DIR__ . '/../../../config/set/jms-decouple.php',
SetList::KDYBY_EVENTS_TO_CONTRIBUTTE_EVENT_DISPATCHER => __DIR__ . '/../../../config/set/kdyby-events-to-contributte-event-dispatcher.php',
SetList::KDYBY_TO_SYMFONY => __DIR__ . '/../../../config/set/kdyby-to-symfony.php',
SetList::KDYBY_TRANSLATOR_TO_CONTRIBUTTE_TRANSLATION => __DIR__ . '/../../../config/set/kdyby-translator-to-contributte-translation.php',
SetList::LARAVEL_50 => __DIR__ . '/../../../config/set/laravel50.php',
SetList::LARAVEL_51 => __DIR__ . '/../../../config/set/laravel51.php',
SetList::LARAVEL_52 => __DIR__ . '/../../../config/set/laravel52.php',
SetList::LARAVEL_53 => __DIR__ . '/../../../config/set/laravel53.php',
SetList::LARAVEL_54 => __DIR__ . '/../../../config/set/laravel54.php',
SetList::LARAVEL_55 => __DIR__ . '/../../../config/set/laravel55.php',
SetList::LARAVEL_56 => __DIR__ . '/../../../config/set/laravel56.php',
SetList::LARAVEL_57 => __DIR__ . '/../../../config/set/laravel57.php',
SetList::LARAVEL_58 => __DIR__ . '/../../../config/set/laravel58.php',
SetList::LARAVEL_60 => __DIR__ . '/../../../config/set/laravel60.php',
SetList::LARAVEL_STATIC_TO_INJECTION => __DIR__ . '/../../../config/set/laravel-static-to-injection.php',
SetList::MOCKISTA_TO_MOCKERY => __DIR__ . '/../../../config/set/mockista-to-mockery.php',
SetList::MONOLOG_20 => __DIR__ . '/../../../config/set/monolog20.php',
SetList::MYSQL_TO_MYSQLI => __DIR__ . '/../../../config/set/mysql-to-mysqli.php',
SetList::NAMING => __DIR__ . '/../../../config/set/naming.php',
SetList::NETTE_30 => __DIR__ . '/../../../config/set/nette-30.php',
SetList::NETTE_APPLICATION_CODE_QUALITY => __DIR__ . '/../../../config/set/nette-application-code-quality.php',
SetList::NETTE_CONTROL_TO_SYMFONY_CONTROLLER => __DIR__ . '/../../../config/set/nette-control-to-symfony-controller.php',
SetList::NETTE_FORMS_TO_SYMFONY => __DIR__ . '/../../../config/set/nette-forms-to-symfony.php',
SetList::NETTE_PARAM_TYPES => __DIR__ . '/../../../config/set/nette-30-param-types.php',
SetList::NETTE_RETURN_TYPES => __DIR__ . '/../../../config/set/nette-30-return-types.php',
SetList::NETTE_TESTER_TO_PHPUNIT => __DIR__ . '/../../../config/set/nette-tester-to-phpunit.php',
SetList::NETTE_TO_SYMFONY => __DIR__ . '/../../../config/set/nette-to-symfony.php',
SetList::NETTE_UTILS_CODE_QUALITY => __DIR__ . '/../../../config/set/nette-utils-code-quality.php',
SetList::ORDER => __DIR__ . '/../../../config/set/order.php',
SetList::PERFORMANCE => __DIR__ . '/../../../config/set/performance.php',
SetList::PHALCON_40 => __DIR__ . '/../../../config/set/phalcon40.php',
SetList::PHPEXCEL_TO_PHPSPREADSHEET => __DIR__ . '/../../../config/set/phpexcel-to-phpspreadsheet.php',
SetList::PHPSPEC_30 => __DIR__ . '/../../../config/set/phpspec30.php',
SetList::PHPSPEC_40 => __DIR__ . '/../../../config/set/phpspec40.php',
SetList::PHPSPEC_TO_PHPUNIT => __DIR__ . '/../../../config/set/phpspec-to-phpunit.php',
SetList::PHPSTAN => __DIR__ . '/../../../config/set/phpstan.php',
SetList::PHPUNIT80_DMS => __DIR__ . '/../../../config/set/phpunit80-dms.php',
SetList::PHPUNIT_40 => __DIR__ . '/../../../config/set/phpunit40.php',
SetList::PHPUNIT_50 => __DIR__ . '/../../../config/set/phpunit50.php',
SetList::PHPUNIT_60 => __DIR__ . '/../../../config/set/phpunit60.php',
SetList::PHPUNIT_70 => __DIR__ . '/../../../config/set/phpunit70.php',
SetList::PHPUNIT_75 => __DIR__ . '/../../../config/set/phpunit75.php',
SetList::PHPUNIT_80 => __DIR__ . '/../../../config/set/phpunit80.php',
SetList::PHPUNIT_90 => __DIR__ . '/../../../config/set/phpunit90.php',
SetList::PHPUNIT_91 => __DIR__ . '/../../../config/set/phpunit91.php',
SetList::PHPUNIT_CODE_QUALITY => __DIR__ . '/../../../config/set/phpunit-code-quality.php',
SetList::PHPUNIT_EXCEPTION => __DIR__ . '/../../../config/set/phpunit-exception.php',
SetList::PHPUNIT_INJECTOR => __DIR__ . '/../../../config/set/phpunit-injector.php',
SetList::PHPUNIT_MOCK => __DIR__ . '/../../../config/set/phpunit-mock.php',
SetList::PHPUNIT_SPECIFIC_METHOD => __DIR__ . '/../../../config/set/phpunit-specific-method.php',
SetList::PHPUNIT_YIELD_DATA_PROVIDER => __DIR__ . '/../../../config/set/phpunit-yield-data-provider.php',
SetList::PHP_52 => __DIR__ . '/../../../config/set/php52.php',
SetList::PHP_53 => __DIR__ . '/../../../config/set/php53.php',
SetList::PHP_54 => __DIR__ . '/../../../config/set/php54.php',
SetList::PHP_55 => __DIR__ . '/../../../config/set/php55.php',
SetList::PHP_56 => __DIR__ . '/../../../config/set/php56.php',
SetList::PHP_70 => __DIR__ . '/../../../config/set/php70.php',
SetList::PHP_71 => __DIR__ . '/../../../config/set/php71.php',
SetList::PHP_72 => __DIR__ . '/../../../config/set/php72.php',
SetList::PHP_73 => __DIR__ . '/../../../config/set/php73.php',
SetList::PHP_74 => __DIR__ . '/../../../config/set/php74.php',
SetList::PHP_80 => __DIR__ . '/../../../config/set/php80.php',
SetList::PHP_CODE_SNIFFER_30 => __DIR__ . '/../../../config/set/php-code-sniffer30.php',
SetList::PHP_DI_DECOUPLE => __DIR__ . '/../../../config/set/php-di-decouple.php',
SetList::PRIVATIZATION => __DIR__ . '/../../../config/set/privatization.php',
SetList::PSR_4 => __DIR__ . '/../../../config/set/psr-4.php',
SetList::SAFE_07 => __DIR__ . '/../../../config/set/safe07.php',
SetList::SHOPWARE_55 => __DIR__ . '/../../../config/set/shopware55.php',
SetList::SHOPWARE_56 => __DIR__ . '/../../../config/set/shopware56.php',
SetList::SOLID => __DIR__ . '/../../../config/set/solid.php',
SetList::SWIFTMAILER_60 => __DIR__ . '/../../../config/set/swiftmailer60.php',
SetList::SYLIUS_10 => __DIR__ . '/../../../config/set/sylius10.php',
SetList::SYLIUS_102 => __DIR__ . '/../../../config/set/sylius102.php',
SetList::SYLIUS_109 => __DIR__ . '/../../../config/set/sylius109.php',
SetList::SYMFONY50_TYPES => __DIR__ . '/../../../config/set/symfony50-types.php',
SetList::SYMFONY_26 => __DIR__ . '/../../../config/set/symfony26.php',
SetList::SYMFONY_28 => __DIR__ . '/../../../config/set/symfony28.php',
SetList::SYMFONY_30 => __DIR__ . '/../../../config/set/symfony30.php',
SetList::SYMFONY_31 => __DIR__ . '/../../../config/set/symfony31.php',
SetList::SYMFONY_32 => __DIR__ . '/../../../config/set/symfony32.php',
SetList::SYMFONY_33 => __DIR__ . '/../../../config/set/symfony33.php',
SetList::SYMFONY_34 => __DIR__ . '/../../../config/set/symfony34.php',
SetList::SYMFONY_40 => __DIR__ . '/../../../config/set/symfony40.php',
SetList::SYMFONY_41 => __DIR__ . '/../../../config/set/symfony41.php',
SetList::SYMFONY_42 => __DIR__ . '/../../../config/set/symfony42.php',
SetList::SYMFONY_43 => __DIR__ . '/../../../config/set/symfony43.php',
SetList::SYMFONY_44 => __DIR__ . '/../../../config/set/symfony44.php',
SetList::SYMFONY_50 => __DIR__ . '/../../../config/set/symfony50.php',
SetList::SYMFONY_CODE_QUALITY => __DIR__ . '/../../../config/set/symfony-code-quality.php',
SetList::SYMFONY_CONSTRUCTOR_INJECTION => __DIR__ . '/../../../config/set/symfony-constructor-injection.php',
SetList::SYMFONY_PHPUNIT => __DIR__ . '/../../../config/set/symfony-phpunit.php',
SetList::TWIG_112 => __DIR__ . '/../../../config/set/twig112.php',
SetList::TWIG_127 => __DIR__ . '/../../../config/set/twig127.php',
SetList::TWIG_134 => __DIR__ . '/../../../config/set/twig134.php',
SetList::TWIG_140 => __DIR__ . '/../../../config/set/twig140.php',
SetList::TWIG_20 => __DIR__ . '/../../../config/set/twig20.php',
SetList::TWIG_240 => __DIR__ . '/../../../config/set/twig240.php',
SetList::TWIG_UNDERSCORE_TO_NAMESPACE => __DIR__ . '/../../../config/set/twig-underscore-to-namespace.php',
SetList::TYPE_DECLARATION => __DIR__ . '/../../../config/set/type-declaration.php',
SetList::UNWRAP_COMPAT => __DIR__ . '/../../../config/set/unwrap-compat.php',
];
private $sets = [];
public function __construct()
{
$this->validateSetFilePaths();
$setNamesToSetPaths = [
SetList::ACTION_INJECTION_TO_CONSTRUCTOR_INJECTION => __DIR__ . '/../../../config/set/action-injection-to-constructor-injection.php',
SetList::ARRAY_STR_FUNCTIONS_TO_STATIC_CALL => __DIR__ . '/../../../config/set/laravel-array-str-functions-to-static-call.php',
SetList::CAKEPHP_30 => __DIR__ . '/../../../config/set/cakephp30.php',
SetList::CAKEPHP_34 => __DIR__ . '/../../../config/set/cakephp34.php',
SetList::CAKEPHP_35 => __DIR__ . '/../../../config/set/cakephp35.php',
SetList::CAKEPHP_36 => __DIR__ . '/../../../config/set/cakephp36.php',
SetList::CAKEPHP_37 => __DIR__ . '/../../../config/set/cakephp37.php',
SetList::CAKEPHP_38 => __DIR__ . '/../../../config/set/cakephp38.php',
SetList::CAKEPHP_40 => __DIR__ . '/../../../config/set/cakephp40.php',
SetList::CAKEPHP_FLUENT_OPTIONS => __DIR__ . '/../../../config/set/cakephp-fluent-options.php',
SetList::CELEBRITY => __DIR__ . '/../../../config/set/celebrity.php',
SetList::CODEIGNITER_40 => __DIR__ . '/../../../config/set/codeigniter-40.php',
SetList::CODE_QUALITY => __DIR__ . '/../../../config/set/code-quality.php',
SetList::CODING_STYLE => __DIR__ . '/../../../config/set/coding-style.php',
SetList::CONSTRUCTOR_INJECTIN_TO_ACTION_INJECTION => __DIR__ . '/../../../config/set/constructor-injectin-to-action-injection.php',
SetList::CONTRIBUTTE_TO_SYMFONY => __DIR__ . '/../../../config/set/contributte-to-symfony.php',
SetList::DEAD_CLASSES => __DIR__ . '/../../../config/set/dead-classes.php',
SetList::DEAD_CODE => __DIR__ . '/../../../config/set/dead-code.php',
SetList::DOCTRINE_25 => __DIR__ . '/../../../config/set/doctrine25.php',
SetList::DOCTRINE_BEHAVIORS_20 => __DIR__ . '/../../../config/set/doctrine-behaviors-20.php',
SetList::DOCTRINE_CODE_QUALITY => __DIR__ . '/../../../config/set/doctrine-code-quality.php',
SetList::DOCTRINE_COMMON_20 => __DIR__ . '/../../../config/set/doctrine-common-20.php',
SetList::DOCTRINE_DBAL_210 => __DIR__ . '/../../../config/set/doctrine-dbal-210.php',
SetList::DOCTRINE_DBAL_30 => __DIR__ . '/../../../config/set/doctrine-dbal-30.php',
SetList::DOCTRINE_GEDMO_TO_KNPLABS => __DIR__ . '/../../../config/set/doctrine-gedmo-to-knplabs.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_1 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-1.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_2 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-2.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_3 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-3.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_4 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-4.php',
SetList::DOCTRINE_ID_TO_UUID_STEP_5 => __DIR__ . '/../../../config/set/doctrine-id-to-uuid-step-5.php',
SetList::DOCTRINE_REPOSITORY_AS_SERVICE => __DIR__ . '/../../../config/set/doctrine-repository-as-service.php',
SetList::DOCTRINE_SERVICES => __DIR__ . '/../../../config/set/doctrine-services.php',
SetList::DOWNGRADE => __DIR__ . '/../../../config/set/downgrade.php',
SetList::EASY_ADMIN_BUNDLE_20 => __DIR__ . '/../../../config/set/easy-admin-bundle20.php',
SetList::ELASTICSEARCH_DSL_50 => __DIR__ . '/../../../config/set/elasticsearch-dsl50.php',
SetList::FRAMEWORK_EXTRA_BUNDLE_40 => __DIR__ . '/../../../config/set/framework-extra-bundle-40.php',
SetList::FRAMEWORK_EXTRA_BUNDLE_50 => __DIR__ . '/../../../config/set/framework-extra-bundle-50.php',
SetList::GMAGICK_TO_IMAGICK => __DIR__ . '/../../../config/set/gmagick_to_imagick.php',
SetList::GUZZLE_50 => __DIR__ . '/../../../config/set/guzzle50.php',
SetList::JMS_DECOUPLE => __DIR__ . '/../../../config/set/jms-decouple.php',
SetList::KDYBY_EVENTS_TO_CONTRIBUTTE_EVENT_DISPATCHER => __DIR__ . '/../../../config/set/kdyby-events-to-contributte-event-dispatcher.php',
SetList::KDYBY_TO_SYMFONY => __DIR__ . '/../../../config/set/kdyby-to-symfony.php',
SetList::KDYBY_TRANSLATOR_TO_CONTRIBUTTE_TRANSLATION => __DIR__ . '/../../../config/set/kdyby-translator-to-contributte-translation.php',
SetList::LARAVEL_50 => __DIR__ . '/../../../config/set/laravel50.php',
SetList::LARAVEL_51 => __DIR__ . '/../../../config/set/laravel51.php',
SetList::LARAVEL_52 => __DIR__ . '/../../../config/set/laravel52.php',
SetList::LARAVEL_53 => __DIR__ . '/../../../config/set/laravel53.php',
SetList::LARAVEL_54 => __DIR__ . '/../../../config/set/laravel54.php',
SetList::LARAVEL_55 => __DIR__ . '/../../../config/set/laravel55.php',
SetList::LARAVEL_56 => __DIR__ . '/../../../config/set/laravel56.php',
SetList::LARAVEL_57 => __DIR__ . '/../../../config/set/laravel57.php',
SetList::LARAVEL_58 => __DIR__ . '/../../../config/set/laravel58.php',
SetList::LARAVEL_60 => __DIR__ . '/../../../config/set/laravel60.php',
SetList::LARAVEL_STATIC_TO_INJECTION => __DIR__ . '/../../../config/set/laravel-static-to-injection.php',
SetList::MOCKISTA_TO_MOCKERY => __DIR__ . '/../../../config/set/mockista-to-mockery.php',
SetList::MONOLOG_20 => __DIR__ . '/../../../config/set/monolog20.php',
SetList::MYSQL_TO_MYSQLI => __DIR__ . '/../../../config/set/mysql-to-mysqli.php',
SetList::NAMING => __DIR__ . '/../../../config/set/naming.php',
SetList::NETTE_30 => __DIR__ . '/../../../config/set/nette-30.php',
SetList::NETTE_APPLICATION_CODE_QUALITY => __DIR__ . '/../../../config/set/nette-application-code-quality.php',
SetList::NETTE_CONTROL_TO_SYMFONY_CONTROLLER => __DIR__ . '/../../../config/set/nette-control-to-symfony-controller.php',
SetList::NETTE_FORMS_TO_SYMFONY => __DIR__ . '/../../../config/set/nette-forms-to-symfony.php',
SetList::NETTE_PARAM_TYPES => __DIR__ . '/../../../config/set/nette-30-param-types.php',
SetList::NETTE_RETURN_TYPES => __DIR__ . '/../../../config/set/nette-30-return-types.php',
SetList::NETTE_TESTER_TO_PHPUNIT => __DIR__ . '/../../../config/set/nette-tester-to-phpunit.php',
SetList::NETTE_TO_SYMFONY => __DIR__ . '/../../../config/set/nette-to-symfony.php',
SetList::NETTE_UTILS_CODE_QUALITY => __DIR__ . '/../../../config/set/nette-utils-code-quality.php',
SetList::ORDER => __DIR__ . '/../../../config/set/order.php',
SetList::PERFORMANCE => __DIR__ . '/../../../config/set/performance.php',
SetList::PHALCON_40 => __DIR__ . '/../../../config/set/phalcon40.php',
SetList::PHPEXCEL_TO_PHPSPREADSHEET => __DIR__ . '/../../../config/set/phpexcel-to-phpspreadsheet.php',
SetList::PHPSPEC_30 => __DIR__ . '/../../../config/set/phpspec30.php',
SetList::PHPSPEC_40 => __DIR__ . '/../../../config/set/phpspec40.php',
SetList::PHPSPEC_TO_PHPUNIT => __DIR__ . '/../../../config/set/phpspec-to-phpunit.php',
SetList::PHPSTAN => __DIR__ . '/../../../config/set/phpstan.php',
SetList::PHPUNIT80_DMS => __DIR__ . '/../../../config/set/phpunit80-dms.php',
SetList::PHPUNIT_40 => __DIR__ . '/../../../config/set/phpunit40.php',
SetList::PHPUNIT_50 => __DIR__ . '/../../../config/set/phpunit50.php',
SetList::PHPUNIT_60 => __DIR__ . '/../../../config/set/phpunit60.php',
SetList::PHPUNIT_70 => __DIR__ . '/../../../config/set/phpunit70.php',
SetList::PHPUNIT_75 => __DIR__ . '/../../../config/set/phpunit75.php',
SetList::PHPUNIT_80 => __DIR__ . '/../../../config/set/phpunit80.php',
SetList::PHPUNIT_90 => __DIR__ . '/../../../config/set/phpunit90.php',
SetList::PHPUNIT_91 => __DIR__ . '/../../../config/set/phpunit91.php',
SetList::PHPUNIT_CODE_QUALITY => __DIR__ . '/../../../config/set/phpunit-code-quality.php',
SetList::PHPUNIT_EXCEPTION => __DIR__ . '/../../../config/set/phpunit-exception.php',
SetList::PHPUNIT_INJECTOR => __DIR__ . '/../../../config/set/phpunit-injector.php',
SetList::PHPUNIT_MOCK => __DIR__ . '/../../../config/set/phpunit-mock.php',
SetList::PHPUNIT_SPECIFIC_METHOD => __DIR__ . '/../../../config/set/phpunit-specific-method.php',
SetList::PHPUNIT_YIELD_DATA_PROVIDER => __DIR__ . '/../../../config/set/phpunit-yield-data-provider.php',
SetList::PHP_52 => __DIR__ . '/../../../config/set/php52.php',
SetList::PHP_53 => __DIR__ . '/../../../config/set/php53.php',
SetList::PHP_54 => __DIR__ . '/../../../config/set/php54.php',
SetList::PHP_55 => __DIR__ . '/../../../config/set/php55.php',
SetList::PHP_56 => __DIR__ . '/../../../config/set/php56.php',
SetList::PHP_70 => __DIR__ . '/../../../config/set/php70.php',
SetList::PHP_71 => __DIR__ . '/../../../config/set/php71.php',
SetList::PHP_72 => __DIR__ . '/../../../config/set/php72.php',
SetList::PHP_73 => __DIR__ . '/../../../config/set/php73.php',
SetList::PHP_74 => __DIR__ . '/../../../config/set/php74.php',
SetList::PHP_80 => __DIR__ . '/../../../config/set/php80.php',
SetList::PHP_CODE_SNIFFER_30 => __DIR__ . '/../../../config/set/php-code-sniffer30.php',
SetList::PHP_DI_DECOUPLE => __DIR__ . '/../../../config/set/php-di-decouple.php',
SetList::PRIVATIZATION => __DIR__ . '/../../../config/set/privatization.php',
SetList::PSR_4 => __DIR__ . '/../../../config/set/psr-4.php',
SetList::SAFE_07 => __DIR__ . '/../../../config/set/safe07.php',
SetList::SHOPWARE_55 => __DIR__ . '/../../../config/set/shopware55.php',
SetList::SHOPWARE_56 => __DIR__ . '/../../../config/set/shopware56.php',
SetList::SOLID => __DIR__ . '/../../../config/set/solid.php',
SetList::SWIFTMAILER_60 => __DIR__ . '/../../../config/set/swiftmailer60.php',
SetList::SYLIUS_10 => __DIR__ . '/../../../config/set/sylius10.php',
SetList::SYLIUS_102 => __DIR__ . '/../../../config/set/sylius102.php',
SetList::SYLIUS_109 => __DIR__ . '/../../../config/set/sylius109.php',
SetList::SYMFONY50_TYPES => __DIR__ . '/../../../config/set/symfony50-types.php',
SetList::SYMFONY_26 => __DIR__ . '/../../../config/set/symfony26.php',
SetList::SYMFONY_28 => __DIR__ . '/../../../config/set/symfony28.php',
SetList::SYMFONY_30 => __DIR__ . '/../../../config/set/symfony30.php',
SetList::SYMFONY_31 => __DIR__ . '/../../../config/set/symfony31.php',
SetList::SYMFONY_32 => __DIR__ . '/../../../config/set/symfony32.php',
SetList::SYMFONY_33 => __DIR__ . '/../../../config/set/symfony33.php',
SetList::SYMFONY_34 => __DIR__ . '/../../../config/set/symfony34.php',
SetList::SYMFONY_40 => __DIR__ . '/../../../config/set/symfony40.php',
SetList::SYMFONY_41 => __DIR__ . '/../../../config/set/symfony41.php',
SetList::SYMFONY_42 => __DIR__ . '/../../../config/set/symfony42.php',
SetList::SYMFONY_43 => __DIR__ . '/../../../config/set/symfony43.php',
SetList::SYMFONY_44 => __DIR__ . '/../../../config/set/symfony44.php',
SetList::SYMFONY_50 => __DIR__ . '/../../../config/set/symfony50.php',
SetList::SYMFONY_CODE_QUALITY => __DIR__ . '/../../../config/set/symfony-code-quality.php',
SetList::SYMFONY_CONSTRUCTOR_INJECTION => __DIR__ . '/../../../config/set/symfony-constructor-injection.php',
SetList::SYMFONY_PHPUNIT => __DIR__ . '/../../../config/set/symfony-phpunit.php',
SetList::TWIG_112 => __DIR__ . '/../../../config/set/twig112.php',
SetList::TWIG_127 => __DIR__ . '/../../../config/set/twig127.php',
SetList::TWIG_134 => __DIR__ . '/../../../config/set/twig134.php',
SetList::TWIG_140 => __DIR__ . '/../../../config/set/twig140.php',
SetList::TWIG_20 => __DIR__ . '/../../../config/set/twig20.php',
SetList::TWIG_240 => __DIR__ . '/../../../config/set/twig240.php',
SetList::TWIG_UNDERSCORE_TO_NAMESPACE => __DIR__ . '/../../../config/set/twig-underscore-to-namespace.php',
SetList::TYPE_DECLARATION => __DIR__ . '/../../../config/set/type-declaration.php',
SetList::UNWRAP_COMPAT => __DIR__ . '/../../../config/set/unwrap-compat.php',
];
foreach ($setNamesToSetPaths as $setName => $setPath) {
$this->sets[] = new Set($setName, new SmartFileInfo($setPath));
}
}
/**
* @return string[]
* @return Set[]
*/
public function provideSetNames(): array
public function provide(): array
{
return array_keys(self::SET_PATH_TO_FILEPATH);
}
public function provideFilePathByName(string $setName): ?Set
{
if (! isset(self::SET_PATH_TO_FILEPATH[$setName])) {
return null;
}
$setFilePath = self::SET_PATH_TO_FILEPATH[$setName];
return new Set($setFilePath);
}
private function validateSetFilePaths(): void
{
foreach (self::SET_PATH_TO_FILEPATH as $setFilePath) {
new SmartFileInfo($setFilePath);
}
return $this->sets;
}
}

View File

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Set\ValueObject;
use Symplify\SmartFileSystem\SmartFileInfo;
final class Set
{
/**
* @var SmartFileInfo
*/
private $fileInfo;
public function __construct(string $filePath)
{
$this->fileInfo = new SmartFileInfo($filePath);
}
public function getFileRealPath(): string
{
return $this->fileInfo->getRealPath();
}
public function getFileInfo(): SmartFileInfo
{
return $this->fileInfo;
}
}

View File

@ -22,9 +22,9 @@ final class Configuration
private $isDryRun = false;
/**
* @var string|null
* @var SmartFileInfo|null
*/
private $configFilePath;
private $configFileInfo;
/**
* @var bool
@ -153,14 +153,18 @@ final class Configuration
/**
* @api
*/
public function setFirstResolverConfig(?string $firstResolvedConfig): void
public function setFirstResolverConfigFileInfo(?SmartFileInfo $firstResolvedConfigFileInfo): void
{
$this->configFilePath = $firstResolvedConfig;
$this->configFileInfo = $firstResolvedConfigFileInfo;
}
public function getConfigFilePath(): ?string
{
return $this->configFilePath;
if ($this->configFileInfo === null) {
return null;
}
return $this->configFileInfo->getRealPath();
}
public function getPrettyVersion(): string

View File

@ -33,9 +33,9 @@ final class RectorConfigsResolver
/**
* @noRector
*/
public function getFirstResolvedConfig(): ?string
public function getFirstResolvedConfig(): ?SmartFileInfo
{
return $this->configResolver->getFirstResolvedConfig();
return $this->configResolver->getFirstResolvedConfigFileInfo();
}
/**
@ -69,17 +69,17 @@ final class RectorConfigsResolver
$set = $this->setResolver->resolveSetFromInput($argvInput);
if ($set !== null) {
$configFileInfos[] = $set->getFileInfo();
$configFileInfos[] = $set->getSetFileInfo();
}
// And from --config or default one
$inputOrFallbackConfig = $this->configResolver->resolveFromInputWithFallback(
$inputOrFallbackConfigFileInfo = $this->configResolver->resolveFromInputWithFallback(
$argvInput,
['rector.php', 'rector.yml', 'rector.yaml']
);
if ($inputOrFallbackConfig !== null) {
$configFileInfos[] = new SmartFileInfo($inputOrFallbackConfig);
if ($inputOrFallbackConfigFileInfo !== null) {
$configFileInfos[] = $inputOrFallbackConfigFileInfo;
}
$setFileInfos = $this->resolveSetFileInfosFromConfigFileInfos($configFileInfos);

View File

@ -6,8 +6,8 @@ namespace Rector\Core\Set;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Set\SetProvider;
use Rector\Set\ValueObject\Set;
use Symfony\Component\Console\Input\InputInterface;
use Symplify\SetConfigResolver\ValueObject\Set;
use Symplify\SmartFileSystem\SmartFileInfo;
final class SetResolver
@ -29,21 +29,21 @@ final class SetResolver
return null;
}
return $this->setProvider->provideFilePathByName($setOption);
return $this->setProvider->provideByName($setOption);
}
public function resolveSetByName(string $name): ?Set
{
return $this->setProvider->provideFilePathByName($name);
return $this->setProvider->provideByName($name);
}
public function resolveSetFileInfoByName(string $name): SmartFileInfo
{
$set = $this->setProvider->provideFilePathByName($name);
$set = $this->setProvider->provideByName($name);
if ($set === null) {
throw new ShouldNotHappenException();
}
return $set->getFileInfo();
return $set->getSetFileInfo();
}
}

View File

@ -41,13 +41,13 @@ abstract class AbstractGenericRectorTestCase extends AbstractKernelTestCase
{
if ($this->provideSet() !== '') {
$setProvider = new SetProvider();
$set = $setProvider->provideFilePathByName($this->provideSet());
$set = $setProvider->provideByName($this->provideSet());
if ($set === null) {
$message = sprintf('Invalid set name provided "%s"', $this->provideSet());
throw new ShouldNotHappenException($message);
}
return $set->getFileInfo();
return $set->getSetFileInfo();
}
// can be implemented