mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
6c20d257e3
d3d18d442c
keep relative paths
35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace RectorPrefix202209\Symplify\PackageBuilder\DependencyInjection\CompilerPass;
|
|
|
|
use RectorPrefix202209\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
use RectorPrefix202209\Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
final class AutowireInterfacesCompilerPass implements CompilerPassInterface
|
|
{
|
|
/**
|
|
* @var string[]
|
|
*/
|
|
private $typesToAutowire;
|
|
/**
|
|
* @param string[] $typesToAutowire
|
|
*/
|
|
public function __construct(array $typesToAutowire)
|
|
{
|
|
$this->typesToAutowire = $typesToAutowire;
|
|
}
|
|
public function process(ContainerBuilder $containerBuilder) : void
|
|
{
|
|
$definitions = $containerBuilder->getDefinitions();
|
|
foreach ($definitions as $definition) {
|
|
foreach ($this->typesToAutowire as $typeToAutowire) {
|
|
if (!\is_a((string) $definition->getClass(), $typeToAutowire, \true)) {
|
|
continue;
|
|
}
|
|
$definition->setAutowired(\true);
|
|
continue 2;
|
|
}
|
|
}
|
|
}
|
|
}
|