mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
remove unused RectorClassesProvider (#5482)
* remove unused RectorClassesProvider * README: remove ci-checkstyle link, marginal topic, to avoid confusion for first readers
This commit is contained in:
parent
6a6ac8332b
commit
7a3f5a8c0a
|
@ -79,10 +79,6 @@ It supports all versions of PHP from 5.3 and major open-source projects:
|
|||
- [How to work with Doc Block and Comments](/docs/how_to_work_with_doc_block_and_comments.md)
|
||||
- [How to Create New Rector Rule](/docs/create_own_rule.md)
|
||||
|
||||
### CI
|
||||
|
||||
- [Add Checkstyle with your CI](/docs/checkstyle.md)
|
||||
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
|
|
@ -48,16 +48,16 @@
|
|||
"symfony/finder": "^4.4.8|^5.1",
|
||||
"symfony/http-kernel": "^4.4.8|^5.1",
|
||||
"symfony/process": "^4.4.8|^5.1",
|
||||
"symplify/astral": "^9.1.1",
|
||||
"symplify/autowire-array-parameter": "^9.1.1",
|
||||
"symplify/console-color-diff": "^9.1.1",
|
||||
"symplify/package-builder": "^9.1.1",
|
||||
"symplify/rule-doc-generator": "^9.1.1",
|
||||
"symplify/set-config-resolver": "^9.1.1",
|
||||
"symplify/simple-php-doc-parser": "^9.1.1",
|
||||
"symplify/skipper": "^9.1.1",
|
||||
"symplify/smart-file-system": "^9.1.1",
|
||||
"symplify/symfony-php-config": "^9.1.1",
|
||||
"symplify/astral": "^9.1.4",
|
||||
"symplify/autowire-array-parameter": "^9.1.4",
|
||||
"symplify/console-color-diff": "^9.1.4",
|
||||
"symplify/package-builder": "^9.1.4",
|
||||
"symplify/rule-doc-generator": "^9.1.4",
|
||||
"symplify/set-config-resolver": "^9.1.4",
|
||||
"symplify/simple-php-doc-parser": "^9.1.4",
|
||||
"symplify/skipper": "^9.1.4",
|
||||
"symplify/smart-file-system": "^9.1.4",
|
||||
"symplify/symfony-php-config": "^9.1.4",
|
||||
"webmozart/assert": "^1.9"
|
||||
},
|
||||
"require-dev": {
|
||||
|
@ -71,13 +71,13 @@
|
|||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/security-core": "^5.2",
|
||||
"symfony/security-http": "^5.2",
|
||||
"symplify/changelog-linker": "^9.1.1",
|
||||
"symplify/coding-standard": "^9.1.1",
|
||||
"symplify/easy-coding-standard": "^9.1.1",
|
||||
"symplify/changelog-linker": "^9.1.4",
|
||||
"symplify/coding-standard": "^9.1.4",
|
||||
"symplify/easy-coding-standard": "^9.1.4",
|
||||
"symplify/easy-ci": "^9.1.0",
|
||||
"symplify/easy-testing": "^9.1.1",
|
||||
"symplify/phpstan-extensions": "^9.1.1",
|
||||
"symplify/phpstan-rules": "^9.1.1",
|
||||
"symplify/easy-testing": "^9.1.4",
|
||||
"symplify/phpstan-extensions": "^9.1.4",
|
||||
"symplify/phpstan-rules": "^9.1.4",
|
||||
"tracy/tracy": "^2.8"
|
||||
},
|
||||
"replace": {
|
||||
|
|
|
@ -12,7 +12,6 @@ use PhpParser\NodeVisitor\CloningVisitor;
|
|||
use PhpParser\Parser;
|
||||
use PhpParser\ParserFactory;
|
||||
use Rector\Core\Bootstrap\NoRectorsLoadedReporter;
|
||||
use Rector\Core\Configuration\RectorClassesProvider;
|
||||
use Rector\Core\Console\ConsoleApplication;
|
||||
use Rector\Core\PhpParser\Parser\NikicPhpParserFactory;
|
||||
use Rector\Core\PhpParser\Parser\PhpParserLexerFactory;
|
||||
|
@ -78,13 +77,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(PrivatesCaller::class);
|
||||
$services->set(FinderSanitizer::class);
|
||||
$services->set(FileSystemFilter::class);
|
||||
$services->set(ParameterProvider::class);
|
||||
$services->set(ParameterProvider::class)
|
||||
->arg('$container', service('service_container'));
|
||||
|
||||
$services->set(RectorClassesProvider::class)
|
||||
->arg('$container', service('service_container'));
|
||||
|
||||
$services->set(CommandNaming::class);
|
||||
|
||||
$services->set(SmartFileSystem::class);
|
||||
|
|
|
@ -12,7 +12,7 @@ use Rector\Core\Application\FileProcessor;
|
|||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
|
||||
use Rector\Core\Bootstrap\RectorConfigsResolver;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Contract\Rector\PhpRectorInterface;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\HttpKernel\RectorKernel;
|
||||
use Rector\Core\NonPhpFile\NonPhpFileProcessor;
|
||||
|
@ -26,8 +26,6 @@ use Rector\Testing\Guard\FixtureGuard;
|
|||
use Rector\Testing\PhpConfigPrinter\PhpConfigPrinterFactory;
|
||||
use Rector\Testing\PHPUnit\Behavior\MovingFilesTrait;
|
||||
use Rector\Testing\ValueObject\InputFilePathWithExpectedFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
|
||||
use Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
|
@ -48,7 +46,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
/**
|
||||
* @var SmartFileSystem
|
||||
*/
|
||||
protected $smartFileSystem;
|
||||
protected static $smartFileSystem;
|
||||
|
||||
/**
|
||||
* @var NonPhpFileProcessor
|
||||
|
@ -60,15 +58,10 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
*/
|
||||
protected $parameterProvider;
|
||||
|
||||
/**
|
||||
* @var RunnableRectorFactory
|
||||
*/
|
||||
protected $runnableRectorFactory;
|
||||
|
||||
/**
|
||||
* @var FixtureGuard
|
||||
*/
|
||||
protected $fixtureGuard;
|
||||
protected static $fixtureGuard;
|
||||
|
||||
/**
|
||||
* @var RemovedAndAddedFilesCollector
|
||||
|
@ -85,6 +78,16 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
*/
|
||||
protected static $allRectorContainer;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private static $isInitialized = false;
|
||||
|
||||
/**
|
||||
* @var RunnableRectorFactory
|
||||
*/
|
||||
private static $runnableRectorFactory;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
|
@ -95,16 +98,19 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
*/
|
||||
private $betterStandardPrinter;
|
||||
|
||||
/**
|
||||
* @var RectorConfigsResolver
|
||||
*/
|
||||
private static $rectorConfigsResolver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->runnableRectorFactory = new RunnableRectorFactory();
|
||||
$this->smartFileSystem = new SmartFileSystem();
|
||||
$this->fixtureGuard = new FixtureGuard();
|
||||
$this->initializeDependencies();
|
||||
|
||||
if ($this->provideConfigFileInfo() !== null) {
|
||||
$configFileInfos = $this->resolveConfigs($this->provideConfigFileInfo());
|
||||
$configFileInfos = self::$rectorConfigsResolver->resolveFromConfigFileInfo($this->provideConfigFileInfo());
|
||||
|
||||
$this->bootKernelWithConfigs(RectorKernel::class, $configFileInfos);
|
||||
$this->bootKernelWithConfigsAndStaticCache(RectorKernel::class, $configFileInfos);
|
||||
|
||||
$enabledRectorsProvider = $this->getService(EnabledRectorsProvider::class);
|
||||
$enabledRectorsProvider->reset();
|
||||
|
@ -129,17 +135,9 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
|
||||
$enabledRectorsProvider = $this->getService(EnabledRectorsProvider::class);
|
||||
$enabledRectorsProvider->reset();
|
||||
$this->configureEnabledRectors($enabledRectorsProvider);
|
||||
$enabledRectorsProvider->addEnabledRector($this->getRectorClass(), []);
|
||||
}
|
||||
|
||||
// load stubs
|
||||
$stubLoader = $this->getService(StubLoader::class);
|
||||
$stubLoader->loadStubs();
|
||||
|
||||
// disable any output
|
||||
$symfonyStyle = $this->getService(SymfonyStyle::class);
|
||||
$symfonyStyle->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||
|
||||
$this->fileProcessor = $this->getService(FileProcessor::class);
|
||||
$this->nonPhpFileProcessor = $this->getService(NonPhpFileProcessor::class);
|
||||
$this->parameterProvider = $this->getService(ParameterProvider::class);
|
||||
|
@ -148,6 +146,9 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
$this->removedAndAddedFilesCollector->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<RectorInterface>
|
||||
*/
|
||||
protected function getRectorClass(): string
|
||||
{
|
||||
// can be implemented
|
||||
|
@ -160,19 +161,6 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, null>
|
||||
*/
|
||||
protected function getCurrentTestRectorClassesWithConfiguration(): array
|
||||
{
|
||||
$rectorClass = $this->getRectorClass();
|
||||
$this->ensureRectorClassIsValid($rectorClass, 'getRectorClass');
|
||||
|
||||
return [
|
||||
$rectorClass => null,
|
||||
];
|
||||
}
|
||||
|
||||
protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php.inc'): Iterator
|
||||
{
|
||||
return StaticFixtureFinder::yieldDirectory($directory, $suffix);
|
||||
|
@ -190,7 +178,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
*/
|
||||
protected function doTestFileInfo(SmartFileInfo $fixtureFileInfo, array $extraFiles = []): void
|
||||
{
|
||||
$this->fixtureGuard->ensureFileInfoHasDifferentBeforeAndAfterContent($fixtureFileInfo);
|
||||
self::$fixtureGuard->ensureFileInfoHasDifferentBeforeAndAfterContent($fixtureFileInfo);
|
||||
|
||||
$inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
|
||||
$fixtureFileInfo,
|
||||
|
@ -271,8 +259,8 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
SmartFileInfo $originalFileInfo,
|
||||
SmartFileInfo $expectedFileInfo
|
||||
): void {
|
||||
$runnable = $this->runnableRectorFactory->createRunnableClass($originalFileInfo);
|
||||
$expectedInstance = $this->runnableRectorFactory->createRunnableClass($expectedFileInfo);
|
||||
$runnable = self::$runnableRectorFactory->createRunnableClass($originalFileInfo);
|
||||
$expectedInstance = self::$runnableRectorFactory->createRunnableClass($expectedFileInfo);
|
||||
|
||||
$actualResult = $runnable->run();
|
||||
|
||||
|
@ -280,19 +268,6 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
$this->assertSame($expectedResult, $actualResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SmartFileInfo[]
|
||||
*/
|
||||
private function resolveConfigs(SmartFileInfo $configFileInfo): array
|
||||
{
|
||||
$configFileInfos = [$configFileInfo];
|
||||
|
||||
$rectorConfigsResolver = new RectorConfigsResolver();
|
||||
$setFileInfos = $rectorConfigsResolver->resolveSetFileInfosFromConfigFileInfos($configFileInfos);
|
||||
|
||||
return array_merge($configFileInfos, $setFileInfos);
|
||||
}
|
||||
|
||||
private function createRectorRepositoryContainer(): void
|
||||
{
|
||||
if (self::$allRectorContainer === null) {
|
||||
|
@ -308,35 +283,14 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
|
||||
private function getConfigFor3rdPartyTest(): string
|
||||
{
|
||||
$rectorClassesWithConfiguration = $this->getCurrentTestRectorClassesWithConfiguration();
|
||||
|
||||
$filePath = sys_get_temp_dir() . '/rector_temp_tests/current_test.php';
|
||||
$this->createPhpConfigFileAndDumpToPath($rectorClassesWithConfiguration, $filePath);
|
||||
$this->createPhpConfigFileAndDumpToPath([
|
||||
$this->getRectorClass() => [],
|
||||
], $filePath);
|
||||
|
||||
return $filePath;
|
||||
}
|
||||
|
||||
private function configureEnabledRectors(EnabledRectorsProvider $enabledRectorsProvider): void
|
||||
{
|
||||
foreach ($this->getCurrentTestRectorClassesWithConfiguration() as $rectorClass => $configuration) {
|
||||
$enabledRectorsProvider->addEnabledRector($rectorClass, (array) $configuration);
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureRectorClassIsValid(string $rectorClass, string $methodName): void
|
||||
{
|
||||
if (is_a($rectorClass, PhpRectorInterface::class, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new ShouldNotHappenException(sprintf(
|
||||
'Class "%s" in "%s()" method must be type of "%s"',
|
||||
$rectorClass,
|
||||
$methodName,
|
||||
PhpRectorInterface::class
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputFilePathWithExpectedFile[] $extraFiles
|
||||
*/
|
||||
|
@ -414,9 +368,7 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
$listForConfig[$rectorClass] = null;
|
||||
}
|
||||
|
||||
foreach (array_keys($this->getCurrentTestRectorClassesWithConfiguration()) as $rectorClass) {
|
||||
$listForConfig[$rectorClass] = null;
|
||||
}
|
||||
$listForConfig[$this->getRectorClass()] = null;
|
||||
|
||||
$filePath = sys_get_temp_dir() . '/rector_temp_tests/all_rectors.php';
|
||||
$this->createPhpConfigFileAndDumpToPath($listForConfig, $filePath);
|
||||
|
@ -433,11 +385,32 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
|
|||
$smartPhpConfigPrinter = $phpConfigPrinterFactory->create();
|
||||
|
||||
$fileContent = $smartPhpConfigPrinter->printConfiguredServices($rectorClassesWithConfiguration);
|
||||
$this->smartFileSystem->dumpFile($filePath, $fileContent);
|
||||
self::$smartFileSystem->dumpFile($filePath, $fileContent);
|
||||
}
|
||||
|
||||
private function normalizeNewlines(string $string): string
|
||||
{
|
||||
return Strings::replace($string, '#\r\n|\r|\n#', "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Static to avoid reboot on each data fixture
|
||||
*/
|
||||
private function initializeDependencies(): void
|
||||
{
|
||||
if (self::$isInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$runnableRectorFactory = new RunnableRectorFactory();
|
||||
self::$smartFileSystem = new SmartFileSystem();
|
||||
self::$fixtureGuard = new FixtureGuard();
|
||||
self::$rectorConfigsResolver = new RectorConfigsResolver();
|
||||
|
||||
// load stubs
|
||||
$stubLoader = new StubLoader();
|
||||
$stubLoader->loadStubs();
|
||||
|
||||
self::$isInitialized = true;
|
||||
}
|
||||
}
|
||||
|
|
10
phpstan.neon
10
phpstan.neon
|
@ -212,11 +212,6 @@ parameters:
|
|||
message: '#Use value object over return of values#'
|
||||
path: 'rules/php70/src/EregToPcreTransformer.php'
|
||||
|
||||
-
|
||||
message: '#Instead of container injection, use specific service#'
|
||||
paths:
|
||||
- src/Configuration/RectorClassesProvider.php
|
||||
|
||||
-
|
||||
message: '#Nested foreach with empty statement is not allowed#'
|
||||
path: packages/better-php-doc-parser/tests/PhpDocParser/TagValueNodeReprint/TagValueNodeReprintTest.php
|
||||
|
@ -537,3 +532,8 @@ parameters:
|
|||
message: '#Use local named constant instead of inline string for regex to explain meaning by constant name#'
|
||||
paths:
|
||||
- packages/better-php-doc-parser/src/Printer/ArrayPartPhpDocTagPrinter.php
|
||||
|
||||
-
|
||||
message: '#Do not use static property#'
|
||||
paths:
|
||||
- rules/sensio/tests/Rector/ClassMethod/TemplateAnnotationToThisRenderRector/DifferentBundleNameRectorTest.php
|
||||
|
|
|
@ -7,19 +7,17 @@ namespace Rector\EarlyReturn\Rector\Return_;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\Cast\Bool_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Type\BooleanType;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use Rector\Core\NodeManipulator\IfManipulator;
|
||||
|
||||
/**
|
||||
* @see \Rector\EarlyReturn\Tests\Rector\Return_\ReturnBinaryAndToEarlyReturnRector\ReturnBinaryAndToEarlyReturnRectorTest
|
||||
|
@ -110,11 +108,16 @@ CODE_SAMPLE
|
|||
{
|
||||
while ($expr instanceof BooleanAnd) {
|
||||
$ifNegations = array_merge($ifNegations, $this->collectLeftBooleanAndToIfs($expr, $return, $ifNegations));
|
||||
$ifNegations[] = $this->ifManipulator->createIfNegation($expr->right, new Return_($this->nodeFactory->createFalse()));
|
||||
$ifNegations[] = $this->ifManipulator->createIfNegation(
|
||||
$expr->right,
|
||||
new Return_($this->nodeFactory->createFalse())
|
||||
);
|
||||
|
||||
$expr = $expr->right;
|
||||
}
|
||||
return $ifNegations + [$this->ifManipulator->createIfNegation($expr, new Return_($this->nodeFactory->createFalse()))];
|
||||
return $ifNegations + [
|
||||
$this->ifManipulator->createIfNegation($expr, new Return_($this->nodeFactory->createFalse())),
|
||||
];
|
||||
}
|
||||
|
||||
private function getLastReturnExpr(Expr $expr): Expr
|
||||
|
|
|
@ -20,11 +20,11 @@ final class DifferentBundleNameRectorTest extends AbstractRectorTestCase
|
|||
$originalBundleFilePath = __DIR__ . '/FixtureDifferentBundleName/SomeActionBundle/DifferentNameBundle.php';
|
||||
$temporaryBundleFilePath = $this->getTempPath() . '/DifferentNameBundle.php';
|
||||
|
||||
$this->smartFileSystem->copy($originalBundleFilePath, $temporaryBundleFilePath, true);
|
||||
self::$smartFileSystem->copy($originalBundleFilePath, $temporaryBundleFilePath, true);
|
||||
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
|
||||
$this->smartFileSystem->remove($temporaryBundleFilePath);
|
||||
self::$smartFileSystem->remove($temporaryBundleFilePath);
|
||||
}
|
||||
|
||||
public function provideData(): Iterator
|
||||
|
|
|
@ -7,56 +7,15 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(DimFetchAssignToMethodCallRector::class)->call('configure', [[
|
||||
DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new DimFetchAssignToMethodCall(
|
||||
'Nette\Application\Routers\RouteList',
|
||||
'Nette\Application\Routers\Route',
|
||||
'addRoute'
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
$services->set(DimFetchAssignToMethodCallRector::class)
|
||||
->call('configure', [[
|
||||
DimFetchAssignToMethodCallRector::DIM_FETCH_ASSIGN_TO_METHOD_CALL => ValueObjectInliner::inline([
|
||||
new DimFetchAssignToMethodCall(
|
||||
'Nette\Application\Routers\RouteList',
|
||||
'Nette\Application\Routers\Route',
|
||||
'addRoute'
|
||||
),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -8,56 +8,11 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(PropertyAssignToMethodCallRector::class)->call('configure', [[
|
||||
PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new PropertyAssignToMethodCall(
|
||||
ChoiceControl::class,
|
||||
'checkAllowedValues',
|
||||
'checkDefaultValue'
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
$services->set(PropertyAssignToMethodCallRector::class)
|
||||
->call('configure', [[
|
||||
PropertyAssignToMethodCallRector::PROPERTY_ASSIGNS_TO_METHODS_CALLS => ValueObjectInliner::inline([
|
||||
new PropertyAssignToMethodCall(ChoiceControl::class, 'checkAllowedValues', 'checkDefaultValue'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -11,29 +11,11 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(ParentClassToTraitsRector::class)->call('configure', [[
|
||||
ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new ParentClassToTraits(ParentObject::class, [SomeTrait::class]),
|
||||
new ParentClassToTraits(AnotherParentObject::class, [SomeTrait::class, SecondTrait::class]),
|
||||
]
|
||||
),
|
||||
]]);
|
||||
$services->set(ParentClassToTraitsRector::class)
|
||||
->call('configure', [[
|
||||
ParentClassToTraitsRector::PARENT_CLASS_TO_TRAITS => ValueObjectInliner::inline([
|
||||
new ParentClassToTraits(ParentObject::class, [SomeTrait::class]),
|
||||
new ParentClassToTraits(AnotherParentObject::class, [SomeTrait::class, SecondTrait::class]),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -8,52 +8,11 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(MethodCallToReturnRector::class)->call('configure', [[
|
||||
MethodCallToReturnRector::METHOD_CALL_WRAPS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new MethodCallToReturn(ReturnDeny::class, 'deny'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
$services->set(MethodCallToReturnRector::class)
|
||||
->call('configure', [[
|
||||
MethodCallToReturnRector::METHOD_CALL_WRAPS => ValueObjectInliner::inline([
|
||||
new MethodCallToReturn(ReturnDeny::class, 'deny'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -7,53 +7,11 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(FuncCallToStaticCallRector::class)->call('configure', [[
|
||||
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new FuncCallToStaticCall('view', 'SomeStaticClass', 'render'),
|
||||
new FuncCallToStaticCall('SomeNamespaced\view', 'AnotherStaticClass', 'render'),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
$services->set(FuncCallToStaticCallRector::class)
|
||||
->call('configure', [[
|
||||
FuncCallToStaticCallRector::FUNC_CALLS_TO_STATIC_CALLS => ValueObjectInliner::inline([
|
||||
new FuncCallToStaticCall('view', 'SomeStaticClass', 'render'),
|
||||
new FuncCallToStaticCall('SomeNamespaced\view', 'AnotherStaticClass', 'render'),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -11,10 +11,8 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
$services->set(UnsetAndIssetToMethodCallRector::class)->call('configure', [[
|
||||
UnsetAndIssetToMethodCallRector::ISSET_UNSET_TO_METHOD_CALL => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
new UnsetAndIssetToMethodCall(LocalContainer::class, 'hasService', 'removeService'),
|
||||
|
||||
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -11,18 +11,16 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
|||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$configuration = ValueObjectInliner::inline([
|
||||
new MethodCallToAnotherMethodCallWithArguments(
|
||||
NetteServiceDefinition::class,
|
||||
'setInject',
|
||||
'addTag',
|
||||
['inject']),
|
||||
]);
|
||||
|
||||
$services->set(MethodCallToAnotherMethodCallWithArgumentsRector::class)
|
||||
->call('configure', [[
|
||||
MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
|
||||
|
||||
new MethodCallToAnotherMethodCallWithArguments(
|
||||
NetteServiceDefinition::class,
|
||||
'setInject',
|
||||
'addTag',
|
||||
['inject']),
|
||||
|
||||
|
||||
]),
|
||||
MethodCallToAnotherMethodCallWithArgumentsRector::METHOD_CALL_RENAMES_WITH_ADDED_ARGUMENTS => $configuration,
|
||||
]]);
|
||||
};
|
||||
|
|
|
@ -22,6 +22,11 @@ final class RectorConfigsResolver
|
|||
*/
|
||||
private $setAwareConfigResolver;
|
||||
|
||||
/**
|
||||
* @var array<string, SmartFileInfo[]>
|
||||
*/
|
||||
private $resolvedConfigFileInfos = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->configResolver = new ConfigResolver();
|
||||
|
@ -29,6 +34,23 @@ final class RectorConfigsResolver
|
|||
$this->setAwareConfigResolver = new SetAwareConfigResolver($rectorSetProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SmartFileInfo[]
|
||||
*/
|
||||
public function resolveFromConfigFileInfo(SmartFileInfo $configFileInfo): array
|
||||
{
|
||||
$hash = sha1($configFileInfo->getRealPath());
|
||||
if (isset($this->resolvedConfigFileInfos[$hash])) {
|
||||
return $this->resolvedConfigFileInfos[$hash];
|
||||
}
|
||||
|
||||
$setFileInfos = $this->resolveSetFileInfosFromConfigFileInfos([$configFileInfo]);
|
||||
$configFileInfos = array_merge([$configFileInfo], $setFileInfos);
|
||||
|
||||
$this->resolvedConfigFileInfos[$hash] = $configFileInfos;
|
||||
return $configFileInfos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @noRector
|
||||
*/
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Core\Configuration;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
|
||||
final class RectorClassesProvider
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface&Container
|
||||
*/
|
||||
private $container;
|
||||
|
||||
/**
|
||||
* This is only to prevent circular dependencies, where this service is being used.
|
||||
* We only need list of classes.
|
||||
*
|
||||
* @param ContainerInterface&Container $container
|
||||
*/
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function provide(): array
|
||||
{
|
||||
$rectorClasses = [];
|
||||
|
||||
foreach ($this->container->getServiceIds() as $class) {
|
||||
if (! class_exists($class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_a($class, RectorInterface::class, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rectorClasses[] = $class;
|
||||
}
|
||||
|
||||
sort($rectorClasses);
|
||||
|
||||
return $rectorClasses;
|
||||
}
|
||||
}
|
|
@ -8,9 +8,6 @@ use Rector\Core\Contract\Rector\RectorInterface;
|
|||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Needed for @see \Rector\Core\Configuration\RectorClassesProvider
|
||||
*/
|
||||
final class MakeRectorsPublicCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $containerBuilder): void
|
||||
|
|
Loading…
Reference in New Issue
Block a user