Skip to content

Commit 34105e6

Browse files
committed
Compiler: added support for setup syntax $prop = value
1 parent 6a7c2e2 commit 34105e6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/DI/Compiler.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ public static function parseService(ServiceDefinition $definition, $config)
352352
}
353353
Validators::assertField($config, 'setup', 'list');
354354
foreach ($config['setup'] as $id => $setup) {
355-
Validators::assert($setup, 'callable|Nette\DI\Statement', "setup item #$id");
355+
Validators::assert($setup, 'callable|Nette\DI\Statement|array:1', "setup item #$id");
356+
if (is_array($setup)) {
357+
$setup = new Statement(key($setup), array_values($setup));
358+
}
356359
$definition->addSetup($setup);
357360
}
358361
}

tests/DI/files/compiler.services.setup.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ services:
2020
- ::globtest(7)
2121

2222
# local properties
23-
- @lorem::$test(null)
23+
- @lorem::$test=null
2424
- [@self, $test](true)
25-
- $test(false)
25+
- $test = false
2626
- $%property%(8)
2727

2828
# static class property

0 commit comments

Comments
 (0)