Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ return static function (ContainerConfigurator $configurator) : void {

$services->set(
'app.feature_service',
\App\Service\FeatureService::class,
App\Service\FeatureService::class,
)
->args(
[
Expand All @@ -157,7 +157,7 @@ return static function (ContainerConfigurator $configurator) : void {

$services->set(
'app.handler_registry',
\App\Service\HandlerRegistry::class,
App\Service\HandlerRegistry::class,
)
->args(
[
Expand All @@ -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(
[
Expand All @@ -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',
Expand All @@ -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');
};
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/SymfonyConfigCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('/^(?<fqcn>[\w\\\\]+) \$(?<name>\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);
}
Expand All @@ -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 '[]';
Expand Down
28 changes: 14 additions & 14 deletions tests/SymfonyConfigCodeGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function testDumpFileWithService() : void

$services->set(
'app.logger',
\Psr\Log\LoggerInterface::class,
Psr\Log\LoggerInterface::class,
)
->autowire();
};
Expand Down Expand Up @@ -147,7 +147,7 @@ public function testDumpFileWithServiceArguments() : void

$services->set(
'app.mailer',
\App\Mailer\MailerService::class,
App\Mailer\MailerService::class,
)
->args(
[
Expand Down Expand Up @@ -189,7 +189,7 @@ public function testDumpFileWithMethodCalls() : void

$services->set(
'app.listener',
\App\EventListener\UserListener::class,
App\EventListener\UserListener::class,
)
->call(
'setLogger',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -281,7 +281,7 @@ public function testDumpFileWithAutoconfigure() : void

$services->set(
'app.command',
\App\Command\ProcessCommand::class,
App\Command\ProcessCommand::class,
)
->tag('console.command')
->autoconfigure();
Expand Down Expand Up @@ -314,7 +314,7 @@ public function testDumpFileWithExpression() : void

$services->set(
'app.service',
\App\Service\DynamicService::class,
App\Service\DynamicService::class,
)
->args(
[
Expand Down Expand Up @@ -404,7 +404,7 @@ public function testDumpFileWithComplexService() : void

$services->set(
'app.complex',
\App\Service\ComplexService::class,
App\Service\ComplexService::class,
)
->args(
[
Expand Down Expand Up @@ -456,7 +456,7 @@ public function testDumpFileWithServiceDecoration() : void

$services->set(
'app.mailer_decorator',
\App\Mailer\DecoratedMailer::class,
App\Mailer\DecoratedMailer::class,
)
->decorate('mailer');
};
Expand Down Expand Up @@ -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'),
],
);
};
Expand Down Expand Up @@ -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',
);
};
Expand Down Expand Up @@ -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,
);
}
};
Expand Down Expand Up @@ -599,7 +599,7 @@ public function testDumpFileSkipsServiceContainer() : void

$services->set(
'app.service',
\App\Service\MyService::class,
App\Service\MyService::class,
);
};

Expand Down