diff --git a/src/DI/ConsoleExtension.php b/src/DI/ConsoleExtension.php index 96b65b9..211adbc 100644 --- a/src/DI/ConsoleExtension.php +++ b/src/DI/ConsoleExtension.php @@ -46,7 +46,7 @@ public function getConfigSchema(): Schema { return Expect::structure([ 'url' => Expect::anyOf(Expect::string(), Expect::null())->dynamic(), - 'name' => Expect::string(), + 'name' => Expect::string()->dynamic(), 'version' => Expect::anyOf(Expect::string(), Expect::int(), Expect::float()), 'catchExceptions' => Expect::bool(), 'autoExit' => Expect::bool(), diff --git a/tests/cases/DI/ConsoleExtension.phpt b/tests/cases/DI/ConsoleExtension.phpt index f4ee053..5dc161f 100644 --- a/tests/cases/DI/ConsoleExtension.phpt +++ b/tests/cases/DI/ConsoleExtension.phpt @@ -209,3 +209,24 @@ test(function (): void { Assert::type(Application::class, $container->getByType(Application::class)); Assert::equal('https://contributte.org/', (string) $container->getService('http.request')->getUrl()); }); + +// Name as Dynamic parameter +test(function (): void { + $loader = new ContainerLoader(TEMP_DIR, true); + $class = $loader->load(function (Compiler $compiler): void { + $compiler->setDynamicParameterNames(['name']); + $compiler->addExtension('console', new ConsoleExtension(true)); + $compiler->loadConfig(FileMock::create(' + console: + name: %name% + parameters: + name: Hello world + ', 'neon')); + }, [getmypid(), 10]); + + /** @var Container $container */ + $container = new $class(); + + $application = $container->getByType(Application::class); + Assert::equal('Hello world', $application->getName()); +});