Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Use rector-installer to load config of extensions #6174

Merged
merged 3 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
"nette/robot-loader": "^3.4",
"nette/utils": "^3.2",
"nikic/php-parser": "^4.10.4",
"phpstan/phpstan": "^0.12.83",
"phpstan/phpdoc-parser": "^0.5.4",
"phpstan/phpstan": "^0.12.83",
"phpstan/phpstan-phpunit": "^0.12.18",
"rector/rector-symfony": "^0.10.3",
"rector/rector-nette": "^0.10.5",
"rector/rector-laravel": "^0.10.1",
"rector/rector-cakephp": "^0.10.3",
"rector/rector-phpunit": "^0.10.6",
"rector/rector-cakephp": "^0.10.4",
"rector/rector-doctrine": "^0.10.2",
"rector/rector-installer": "dev-main",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tag this one too, so we can remove min-stability dev?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also bumped it up to PHP Version 7.3

"rector/rector-laravel": "^0.10.2",
"rector/rector-nette": "^0.10.6",
"rector/rector-phpunit": "^0.10.6",
"rector/rector-symfony": "^0.10.3",
"sebastian/diff": "^4.0.4",
"symfony/console": "^4.4.8|^5.1",
"symfony/dependency-injection": "^5.1",
Expand Down Expand Up @@ -73,7 +74,7 @@
"nette/forms": "^3.0",
"phpstan/phpstan-nette": "^0.12.16",
"phpunit/phpunit": "^9.5",
"rector/rector-generator": "^0.1.5",
"rector/rector-generator": "^0.1.6",
"symplify/coding-standard": "^9.2.16",
"symplify/easy-ci": "^9.2.16",
"symplify/easy-coding-standard": "^9.2.16",
Expand Down Expand Up @@ -153,5 +154,7 @@
"config": {
"sort-packages": true,
"platform-check": false
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
32 changes: 5 additions & 27 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

declare(strict_types=1);

use Rector\Core\Bootstrap\ExtensionConfigResolver;
use Rector\Core\Configuration\Option;
use Rector\RectorGenerator\Bundle\RectorGeneratorBundle;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
Expand All @@ -12,32 +12,10 @@
$containerConfigurator->import(__DIR__ . '/services-packages.php');
$containerConfigurator->import(__DIR__ . '/parameters.php');

// rector root
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-symfony/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-nette/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-laravel/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-phpunit/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-cakephp/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../vendor/rector/rector-doctrine/config/config.php', null, 'not_found');

// rector sub-package
$containerConfigurator->import(__DIR__ . '/../../rector-symfony/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-nette/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-laravel/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-phpunit/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-cakephp/config/config.php', null, 'not_found');
$containerConfigurator->import(__DIR__ . '/../../rector-doctrine/config/config.php', null, 'not_found');

// only for dev
// only for dev
if (class_exists(RectorGeneratorBundle::class)) {
$containerConfigurator->import(
__DIR__ . '/../vendor/rector/rector-generator/config/config.php',
null,
'not_found'
);
// 3rd party dependency
$containerConfigurator->import(__DIR__ . '/../../rector-generator/config/config.php', null, 'not_found');
$extensionConfigResolver = new ExtensionConfigResolver();
$extensionConfigFiles = $extensionConfigResolver->provide();
foreach ($extensionConfigFiles as $extensionConfigFile) {
$containerConfigurator->import($extensionConfigFile->getRealPath());
}

// require only in dev
Expand Down
5 changes: 3 additions & 2 deletions src/Bootstrap/ExtensionConfigResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
final class ExtensionConfigResolver
{
/**
* @param SmartFileInfo[] $configFileInfos
* @return SmartFileInfo[]
sabbelasichon marked this conversation as resolved.
Show resolved Hide resolved
*/
public function appendExtensionsConfig(array $configFileInfos): array
public function provide(): array
sabbelasichon marked this conversation as resolved.
Show resolved Hide resolved
{
$configFileInfos = [];

if (! class_exists('Rector\RectorInstaller\GeneratedConfig')) {
return $configFileInfos;
}
Expand Down
1 change: 0 additions & 1 deletion src/Bootstrap/RectorConfigsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function provide(): BootstrapConfigs
) : [];

$configFileInfos = $this->appendRectorRecipeConfig($argvInput, $configFileInfos);
$configFileInfos = $this->extensionConfigResolver->appendExtensionsConfig($configFileInfos);

return new BootstrapConfigs($mainConfigFileInfo, $configFileInfos);
}
Expand Down