Skip to content

Commit 083ba7f

Browse files
committed
minor #47370 Remove usage of empty function when possible (alamirault)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- Remove usage of empty function when possible | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> In recent code reviews we suggest to use `!$var` instead of `empty($var)` In order to keep same code style in codebase, I replaced usages of empty when it is possible and typehinted Commits ------- 026edbe601 Remove usage of empty function when possible
2 parents ae3d7d5 + 4cf2940 commit 083ba7f

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

Command/ContainerDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private function findProperServiceName(InputInterface $input, SymfonyStyle $io,
276276
}
277277

278278
$matchingServices = $this->findServiceIdsContaining($builder, $name, $showHidden);
279-
if (empty($matchingServices)) {
279+
if (!$matchingServices) {
280280
throw new InvalidArgumentException(sprintf('No services found that match "%s".', $name));
281281
}
282282

Command/DebugAutowiringCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8787
return false !== stripos(str_replace('\\', '', $serviceId), $searchNormalized) && !str_starts_with($serviceId, '.');
8888
});
8989

90-
if (empty($serviceIds)) {
90+
if (!$serviceIds) {
9191
$errorIo->error(sprintf('No autowirable classes or interfaces found matching "%s"', $search));
9292

9393
return 1;

Command/TranslationDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
186186
}
187187

188188
// No defined or extracted messages
189-
if (empty($allMessages) || null !== $domain && empty($allMessages[$domain])) {
189+
if (!$allMessages || null !== $domain && empty($allMessages[$domain])) {
190190
$outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale);
191191

192192
if (null !== $domain) {

Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ private function renderEventListenerTable(EventDispatcherInterface $eventDispatc
530530

531531
private function formatRouterConfig(array $config): string
532532
{
533-
if (empty($config)) {
533+
if (!$config) {
534534
return 'NONE';
535535
}
536536

DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function process(ContainerBuilder $container)
124124

125125
$services = array_keys($container->findTaggedServiceIds($tag));
126126
$message = sprintf('Tag "%s" was defined on service(s) "%s", but was never used.', $tag, implode('", "', $services));
127-
if (!empty($candidates)) {
127+
if ($candidates) {
128128
$message .= sprintf(' Did you mean "%s"?', implode('", "', $candidates));
129129
}
130130

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
350350
$workflows = [];
351351
}
352352

353-
if (1 === \count($workflows) && isset($workflows['workflows']) && !array_is_list($workflows['workflows']) && !empty(array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_marking', 'places', 'transitions']))) {
353+
if (1 === \count($workflows) && isset($workflows['workflows']) && !array_is_list($workflows['workflows']) && array_diff(array_keys($workflows['workflows']), ['audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_marking', 'places', 'transitions'])) {
354354
$workflows = $workflows['workflows'];
355355
}
356356

0 commit comments

Comments
 (0)