add AutowireDefaultCompilerPass

This commit is contained in:
Tomas Votruba 2018-07-26 15:31:58 +02:00
parent e20d8692ca
commit 58d8775221
3 changed files with 3 additions and 36 deletions

View File

@ -1,28 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\YamlRector\DependencyInjection\CompilerPass;
use Rector\YamlRector\Contract\YamlRectorInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @todo use AutowireDefaultCompilerPass instead
*/
final class AutowireYamlRectorCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $containerBuilder): void
{
foreach ($containerBuilder->getDefinitions() as $definition) {
if ($definition->getClass() === null) {
continue;
}
if (! is_a($definition->getClass(), YamlRectorInterface::class, true)) {
continue;
}
$definition->setAutowired(true);
}
}
}

View File

@ -2,11 +2,10 @@
namespace Rector\DependencyInjection\CompilerPass;
use Rector\Contract\Rector\RectorInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class AutowireRectorCompilerPass implements CompilerPassInterface
final class AutowireDefaultCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $containerBuilder): void
{
@ -15,10 +14,6 @@ final class AutowireRectorCompilerPass implements CompilerPassInterface
continue;
}
if (! is_a($definition->getClass(), RectorInterface::class, true)) {
continue;
}
$definition->setAutowired(true);
}
}

View File

@ -3,6 +3,7 @@
namespace Rector\DependencyInjection;
use Rector\DependencyInjection\CompilerPass\AutoBindParametersCompilerPass;
use Rector\DependencyInjection\CompilerPass\AutowireDefaultCompilerPass;
use Rector\DependencyInjection\CompilerPass\AutowireRectorCompilerPass;
use Rector\DependencyInjection\CompilerPass\CollectorCompilerPass;
use Rector\NodeTypeResolver\DependencyInjection\CompilerPass\NodeTypeResolverCollectorCompilerPass;
@ -64,8 +65,7 @@ final class RectorKernel extends Kernel
{
$containerBuilder->addCompilerPass(new CollectorCompilerPass());
$containerBuilder->addCompilerPass(new YamlRectorCollectorCompilerPass());
$containerBuilder->addCompilerPass(new AutowireRectorCompilerPass());
$containerBuilder->addCompilerPass(new AutowireYamlRectorCompilerPass());
$containerBuilder->addCompilerPass(new AutowireDefaultCompilerPass());
$containerBuilder->addCompilerPass(new NodeTypeResolverCollectorCompilerPass());
$containerBuilder->addCompilerPass(new AutowireSinglyImplementedCompilerPass());