Skip to content

Commit d966e61

Browse files
author
Jan Pintr
committed
Prefer using null coalesce over empty condition check
1 parent 98b8baa commit d966e61

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/Scheduler/DependencyInjection/AddScheduleMessengerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function process(ContainerBuilder $container): void
6060
$attribute = ($container->getReflectionClass($serviceDefinition->getClass())->getAttributes(AsCommand::class)[0] ?? null)?->newInstance();
6161
$commandName = $attribute?->name ?? $serviceDefinition->getClass()::getDefaultName();
6262

63-
$message = new Definition(RunCommandMessage::class, [$commandName.(!empty($tagAttributes['arguments']) ? " {$tagAttributes['arguments']}" : '')]);
63+
$message = new Definition(RunCommandMessage::class, [$commandName.(($tagAttributes['arguments'] ?? null) ? " {$tagAttributes['arguments']}" : '')]);
6464
} else {
6565
$message = new Definition(ServiceCallMessage::class, [$serviceId, $tagAttributes['method'] ?? '__invoke', (array) ($tagAttributes['arguments'] ?? [])]);
6666
}

src/Symfony/Component/Scheduler/Tests/DependencyInjection/AddScheduleMessengerPassTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static function processSchedulerTaskCommandProvider(): iterable
5050
{
5151
yield 'no arguments' => [['trigger' => 'every', 'frequency' => '1 hour'], 'schedulable'];
5252
yield 'null arguments' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => null], 'schedulable'];
53+
yield 'empty arguments' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => ''], 'schedulable'];
5354
yield 'test argument' => [['trigger' => 'every', 'frequency' => '1 hour', 'arguments' => 'test'], 'schedulable test'];
5455
}
5556
}

0 commit comments

Comments
 (0)