Lines
100.00%
5 / 5
Functions and Methods
100.00%
2 / 2
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| NamedArgumentsPass | 100.00% | 5 / 5 | 100.00% | 2 / 2 | 5 | 100.00% | 1 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| process | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 4 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Kernel; | |
| 6 | ||
| 7 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |
| 8 | use Symfony\Component\DependencyInjection\ContainerBuilder; | |
| 9 | ||
| 10 | // The config DSL rejects object values, so runtime values are bound here, not under _defaults. | |
| 11 | final readonly class NamedArgumentsPass implements CompilerPassInterface | |
| 12 | { | |
| 13 | public function __construct(private NamedArguments $arguments) {} | |
| 14 | ||
| 15 | public function process(ContainerBuilder $container): void | |
| 16 | { | |
| 17 | $bindings = $this->arguments->toBoundArguments(); | |
| 18 | ||
| 19 | foreach ($container->getDefinitions() as $definition) { | |
| 20 | if ($definition->isAutowired() && !$definition->isSynthetic()) { | |
| 21 | $definition->setBindings([...$bindings, ...$definition->getBindings()]); | |
| 22 | } | |
| 23 | } | |
| 24 | } | |
| 25 | } |