Skip to content

Commit 56ceef4

Browse files
committed
Processor::filterArguments() translates @service to object Reference
1 parent 8de093b commit 56ceef4

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/DI/Config/Processor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ public static function filterArguments(array $args): array
435435
unset($args[$k]);
436436
} elseif (is_string($v) && preg_match('#^[\w\\\\]*::[A-Z][A-Z0-9_]*\z#', $v, $m)) {
437437
$args[$k] = constant(ltrim($v, ':'));
438+
} elseif (is_string($v) && preg_match('#^@[\w\\\\]+\z#', $v)) {
439+
$args[$k] = new Definitions\Reference(substr($v, 1));
438440
} elseif (is_array($v)) {
439441
$args[$k] = self::filterArguments($v);
440442
} elseif ($v instanceof Statement) {

tests/DI/Config.Processor.filterArguments.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Assert::same(
2626
Processor::filterArguments(['a', 'b', 'Nette\DI\ContainerBuilder::THIS_CONTAINER'])
2727
);
2828

29+
Assert::equal(
30+
['a', 'b', new Nette\DI\Definitions\Reference('service')],
31+
Processor::filterArguments(['a', 'b', '@service'])
32+
);
33+
2934
Assert::equal(
3035
[new Statement('class', ['a', 2 => Nette\DI\ContainerBuilder::THIS_CONTAINER])],
3136
Processor::filterArguments([new Statement('class', ['a', '...', 'Nette\DI\ContainerBuilder::THIS_CONTAINER'])])

0 commit comments

Comments
 (0)