diff --git a/composer.json b/composer.json index 1d957b1463d..bcfdc2df9cf 100644 --- a/composer.json +++ b/composer.json @@ -19,17 +19,17 @@ "symfony/dependency-injection": "^3.4|^4.1", "symfony/finder": "^3.4|^4.1", "symfony/process": "^3.4|^4.1", - "symplify/better-phpdoc-parser": "^5.1", - "symplify/easy-coding-standard": "^5.1", - "symplify/package-builder": "^5.1", + "symplify/better-phpdoc-parser": "^5.2", + "symplify/easy-coding-standard": "^5.2", + "symplify/package-builder": "^5.2", "thecodingmachine/safe": "^0.1.4" }, "require-dev": { "humbug/php-scoper": "^0.9.2", "phpunit/phpunit": "^7.3", - "symplify/changelog-linker": "^5.1", - "symplify/monorepo-builder": "^5.1", - "symplify/phpstan-extensions": "^5.1", + "symplify/changelog-linker": "^5.2", + "symplify/monorepo-builder": "^5.2", + "symplify/phpstan-extensions": "^5.2", "thecodingmachine/phpstan-safe-rule": "^0.1.0", "thecodingmachine/phpstan-strict-rules": "^0.10.3", "tracy/tracy": "^2.5" @@ -216,5 +216,7 @@ "bin": ["bin/rector"], "config": { "sort-packages": true - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/packages/NodeTypeResolver/src/NodeTypeResolver.php b/packages/NodeTypeResolver/src/NodeTypeResolver.php index 403d6891e29..8f0dd47f6a2 100644 --- a/packages/NodeTypeResolver/src/NodeTypeResolver.php +++ b/packages/NodeTypeResolver/src/NodeTypeResolver.php @@ -37,7 +37,8 @@ final class NodeTypeResolver public function __construct( TypeToStringResolver $typeToStringResolver, Broker $broker, - ClassReflectionTypesResolver $classReflectionTypesResolver + ClassReflectionTypesResolver $classReflectionTypesResolver, + array $perNodeTypeResolvers = [] ) { $this->typeToStringResolver = $typeToStringResolver; $this->broker = $broker; diff --git a/phpstan.neon b/phpstan.neon index b53e52ca03d..011c5dd5a47 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -55,8 +55,6 @@ parameters: - '#Cannot call method getAttribute\(\) on PhpParser\\Node\\Name\|null#' - '#Cannot call method getText\(\) on PhpParser\\Comment\\Doc\|null#' - - # Error php-parser token - '#Access to an undefined property PhpParser\\Node\\Expr\\Error\|PhpParser\\Node\\Expr\\Variable::\$name#' diff --git a/src/Console/Application.php b/src/Console/Application.php index f81774df9b8..4da582e6fc2 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -4,6 +4,7 @@ namespace Rector\Console; use Jean85\PrettyVersions; use Symfony\Component\Console\Application as SymfonyApplication; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; use function Safe\getcwd; @@ -15,9 +16,14 @@ final class Application extends SymfonyApplication */ private const NAME = 'Rector'; - public function __construct() + /** + * @param Command[] $commands + */ + public function __construct(array $commands = []) { parent::__construct(self::NAME, PrettyVersions::getVersion('rector/rector')->getPrettyVersion()); + + $this->addCommands($commands); } protected function getDefaultInputDefinition(): InputDefinition diff --git a/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php b/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php deleted file mode 100644 index 854efb20759..00000000000 --- a/src/DependencyInjection/CompilerPass/AutowireInterfacesCompilerPass.php +++ /dev/null @@ -1,34 +0,0 @@ -typesToAutowire = $typesToAutowire; - } - - public function process(ContainerBuilder $containerBuilder): void - { - foreach ($containerBuilder->getDefinitions() as $definition) { - foreach ($this->typesToAutowire as $typeToAutowire) { - if (is_a((string) $definition->getClass(), $typeToAutowire, true)) { - $definition->setAutowired(true); - continue 2; - } - } - } - } -} diff --git a/src/DependencyInjection/RectorKernel.php b/src/DependencyInjection/RectorKernel.php index 19aa659134f..b3e8bc78d6d 100644 --- a/src/DependencyInjection/RectorKernel.php +++ b/src/DependencyInjection/RectorKernel.php @@ -3,7 +3,6 @@ namespace Rector\DependencyInjection; use Rector\Contract\Rector\PhpRectorInterface; -use Rector\DependencyInjection\CompilerPass\AutowireInterfacesCompilerPass; use Rector\DependencyInjection\Loader\TolerantRectorYamlFileLoader; use Rector\FileSystemRector\Contract\FileSystemRectorInterface; use Rector\YamlRector\Contract\YamlRectorInterface; @@ -16,6 +15,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\Kernel; use Symplify\PackageBuilder\DependencyInjection\CompilerPass\AutoBindParametersCompilerPass; +use Symplify\PackageBuilder\DependencyInjection\CompilerPass\AutowireArrayParameterCompilerPass; +use Symplify\PackageBuilder\DependencyInjection\CompilerPass\AutowireInterfacesCompilerPass; use Symplify\PackageBuilder\DependencyInjection\CompilerPass\AutowireSinglyImplementedCompilerPass; use Symplify\PackageBuilder\DependencyInjection\CompilerPass\ConfigurableCollectorCompilerPass; use Symplify\PackageBuilder\HttpKernel\SimpleKernelTrait; @@ -58,6 +59,7 @@ final class RectorKernel extends Kernel // for defaults $containerBuilder->addCompilerPass(new AutowireSinglyImplementedCompilerPass()); + $containerBuilder->addCompilerPass(new AutowireArrayParameterCompilerPass()); // autowire Rectors by default (mainly for 3rd party code) $containerBuilder->addCompilerPass(new AutowireInterfacesCompilerPass([ diff --git a/src/config/config.yml b/src/config/config.yml index 08df69ff434..c62bc5e691d 100644 --- a/src/config/config.yml +++ b/src/config/config.yml @@ -1,9 +1,9 @@ imports: - - { resource: '../../packages/**/src/config/config.yml' } - # new config location - - { resource: '../../packages/**/config/config.yml' } - - { resource: 'services.yml' } - - { resource: 'external-services.yml' } + - { resource: '../../packages/**/src/config/config.yml' } + # new config location + - { resource: '../../packages/**/config/config.yml' } + - { resource: 'services.yml' } + - { resource: 'external-services.yml' } parameters: exclude_paths: []