Skip to content

Commit 78619d8

Browse files
committed
minor #47654 Convert switch cases to match expression (tigitz)
This PR was merged into the 6.2 branch. Discussion ---------- Convert switch cases to match expression | 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 | - | License | MIT | Doc PR | Continuation of symfony/symfony#45433 using [rector rule ](https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#changeswitchtomatchrector) `@fancyweb` friendly ping as you've worked on it previously. Commits ------- f3ec7ac324 Convert switch cases to match expression
2 parents add1d40 + df29c37 commit 78619d8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Command/DebugCommand.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
101101
throw new InvalidArgumentException(sprintf('Argument "name" not supported, it requires the Twig loader "%s".', FilesystemLoader::class));
102102
}
103103

104-
switch ($input->getOption('format')) {
105-
case 'text':
106-
$name ? $this->displayPathsText($io, $name) : $this->displayGeneralText($io, $filter);
107-
break;
108-
case 'json':
109-
$name ? $this->displayPathsJson($io, $name) : $this->displayGeneralJson($io, $filter);
110-
break;
111-
default:
112-
throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format')));
113-
}
104+
match ($input->getOption('format')) {
105+
'text' => $name ? $this->displayPathsText($io, $name) : $this->displayGeneralText($io, $filter),
106+
'json' => $name ? $this->displayPathsJson($io, $name) : $this->displayGeneralJson($io, $filter),
107+
default => throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $input->getOption('format'))),
108+
};
114109

115110
return 0;
116111
}

0 commit comments

Comments
 (0)