diff --git a/README.md b/README.md index 9dc8f22..62a474e 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ return static function (ContainerConfigurator $configurator) : void { $services->set( 'app.feature_service', - \App\Service\FeatureService::class, + App\Service\FeatureService::class, ) ->args( [ @@ -157,7 +157,7 @@ return static function (ContainerConfigurator $configurator) : void { $services->set( 'app.handler_registry', - \App\Service\HandlerRegistry::class, + App\Service\HandlerRegistry::class, ) ->args( [ @@ -167,13 +167,13 @@ return static function (ContainerConfigurator $configurator) : void { $services->set( 'app.logger', - \Psr\Log\LoggerInterface::class, + Psr\Log\LoggerInterface::class, ) ->autowire(); $services->set( 'app.mailer', - \App\Service\MailerService::class, + App\Service\MailerService::class, ) ->args( [ @@ -198,7 +198,7 @@ return static function (ContainerConfigurator $configurator) : void { $services->set( 'app.request_listener', - \App\EventListener\RequestListener::class, + App\EventListener\RequestListener::class, ) ->tag( 'kernel.event_listener', @@ -210,7 +210,7 @@ return static function (ContainerConfigurator $configurator) : void { $services->set( 'app.user_handler', - \App\Handler\UserHandler::class, + App\Handler\UserHandler::class, ) ->tag('app.handler'); }; diff --git a/composer.json b/composer.json index fe96fef..8eeb5e3 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": "^8.4", - "ruudk/code-generator": "^0.4.0", + "ruudk/code-generator": "^0.4.5", "symfony/dependency-injection": "^7.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 5c8cbe6..1e4b7ca 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "46db37a4bea9d4806a7f3e6fab6167a6", + "content-hash": "dac45048505b925120b429102831081f", "packages": [ { "name": "psr/container", @@ -61,16 +61,16 @@ }, { "name": "ruudk/code-generator", - "version": "0.4.3", + "version": "0.4.5", "source": { "type": "git", "url": "https://github.com/ruudk/code-generator.git", - "reference": "743473506794b20a8954c5805cb2fd5bdac735b4" + "reference": "02c895c49f545ecb21e26f92508b520694dd82eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ruudk/code-generator/zipball/743473506794b20a8954c5805cb2fd5bdac735b4", - "reference": "743473506794b20a8954c5805cb2fd5bdac735b4", + "url": "https://api.github.com/repos/ruudk/code-generator/zipball/02c895c49f545ecb21e26f92508b520694dd82eb", + "reference": "02c895c49f545ecb21e26f92508b520694dd82eb", "shasum": "" }, "require": { @@ -112,7 +112,7 @@ ], "support": { "issues": "https://github.com/ruudk/code-generator/issues", - "source": "https://github.com/ruudk/code-generator/tree/0.4.3" + "source": "https://github.com/ruudk/code-generator/tree/0.4.5" }, "funding": [ { @@ -120,7 +120,7 @@ "type": "github" } ], - "time": "2025-08-23T08:34:17+00:00" + "time": "2025-10-08T13:27:26+00:00" }, { "name": "symfony/dependency-injection", diff --git a/src/SymfonyConfigCodeGenerator.php b/src/SymfonyConfigCodeGenerator.php index 3e74161..5ebf4dd 100644 --- a/src/SymfonyConfigCodeGenerator.php +++ b/src/SymfonyConfigCodeGenerator.php @@ -249,10 +249,10 @@ private function export(mixed $input) : Generator yield from $this->dumpParam(substr($input, 1, -1)); } elseif (is_string($input) && ($this->isFqcn($input) || $this->fqcnExists($input))) { // The class could not yet exist at compile time, so we need to check if it starts with TicketSwap\ - yield '\\' . $input . '::class'; + yield $input . '::class'; } elseif (is_scalar($input)) { if (is_string($input) && preg_match('/^(?[\w\\\\]+) \$(?\w+)$/', $input, $matches) === 1) { - yield sprintf("\\%s::class . ' \$%s'", $matches['fqcn'], $matches['name']); + yield sprintf("%s::class . ' \$%s'", $matches['fqcn'], $matches['name']); } else { yield var_export($input, true); } @@ -275,7 +275,7 @@ private function export(mixed $input) : Generator } elseif ($input instanceof Definition) { yield from $this->dumpInlineService($input); } elseif ($input instanceof UnitEnum) { - yield '\\' . $input::class . '::' . $input->name; + yield $input::class . '::' . $input->name; } elseif (is_array($input)) { if ($input === []) { yield '[]'; diff --git a/tests/SymfonyConfigCodeGeneratorTest.php b/tests/SymfonyConfigCodeGeneratorTest.php index 4a2f319..c817276 100644 --- a/tests/SymfonyConfigCodeGeneratorTest.php +++ b/tests/SymfonyConfigCodeGeneratorTest.php @@ -109,7 +109,7 @@ public function testDumpFileWithService() : void $services->set( 'app.logger', - \Psr\Log\LoggerInterface::class, + Psr\Log\LoggerInterface::class, ) ->autowire(); }; @@ -147,7 +147,7 @@ public function testDumpFileWithServiceArguments() : void $services->set( 'app.mailer', - \App\Mailer\MailerService::class, + App\Mailer\MailerService::class, ) ->args( [ @@ -189,7 +189,7 @@ public function testDumpFileWithMethodCalls() : void $services->set( 'app.listener', - \App\EventListener\UserListener::class, + App\EventListener\UserListener::class, ) ->call( 'setLogger', @@ -237,7 +237,7 @@ public function testDumpFileWithTags() : void $services->set( 'app.event_listener', - \App\EventListener\RequestListener::class, + App\EventListener\RequestListener::class, ) ->tag( 'kernel.event_listener', @@ -281,7 +281,7 @@ public function testDumpFileWithAutoconfigure() : void $services->set( 'app.command', - \App\Command\ProcessCommand::class, + App\Command\ProcessCommand::class, ) ->tag('console.command') ->autoconfigure(); @@ -314,7 +314,7 @@ public function testDumpFileWithExpression() : void $services->set( 'app.service', - \App\Service\DynamicService::class, + App\Service\DynamicService::class, ) ->args( [ @@ -404,7 +404,7 @@ public function testDumpFileWithComplexService() : void $services->set( 'app.complex', - \App\Service\ComplexService::class, + App\Service\ComplexService::class, ) ->args( [ @@ -456,7 +456,7 @@ public function testDumpFileWithServiceDecoration() : void $services->set( 'app.mailer_decorator', - \App\Mailer\DecoratedMailer::class, + App\Mailer\DecoratedMailer::class, ) ->decorate('mailer'); }; @@ -488,11 +488,11 @@ public function testDumpFileWithTypedReference() : void $services->set( 'app.handler', - \App\Handler\MessageHandler::class, + App\Handler\MessageHandler::class, ) ->args( [ - service(\Psr\Log\LoggerInterface::class . ' $logger'), + service(Psr\Log\LoggerInterface::class . ' $logger'), ], ); }; @@ -527,11 +527,11 @@ public function testDumpFileWithServiceAlias() : void $services->set( 'app.custom_logger', - \App\Logger\CustomLogger::class, + App\Logger\CustomLogger::class, ); $services->alias( - \Psr\Log\LoggerInterface::class, + Psr\Log\LoggerInterface::class, 'app.custom_logger', ); }; @@ -567,7 +567,7 @@ public function testDumpFileWithEnvironmentSpecificService() : void if ($configurator->env() === 'dev') { $services->set( 'app.debug_logger', - \App\Logger\DebugLogger::class, + App\Logger\DebugLogger::class, ); } }; @@ -599,7 +599,7 @@ public function testDumpFileSkipsServiceContainer() : void $services->set( 'app.service', - \App\Service\MyService::class, + App\Service\MyService::class, ); };