Repository: symfony/symfony
File: src/Symfony/Bundle/SecurityBundle/Command/SecurityRoleHierarchyDumpCommand.php (PHP)

Code before:

/**
 * Command to dump the role hierarchy as a Mermaid flowchart.
 *
 * @author Damien Fernandes <damien.fernandes24@gmail.com>
 */
#[AsCommand(name: 'debug:security:role-hierarchy', description: 'Dump the role hierarchy as a Mermaid flowchart')]
class SecurityRoleHierarchyDumpCommand extends Command
{
    public function __construct(
        private readonly RoleHierarchyInterface $roleHierarchy,
    ) {
        parent::__construct();
    }

    protected function configure(): void
    {
        $this
            ->setDefinition([
                new InputOption(
                    name: 'direction',
                    shortcut: 'd',
                    mode: InputOption::VALUE_REQUIRED,
                    description: 'The direction of the flowchart ['.implode('|', $this->getAvailableDirections()).']',
                    default: MermaidDirectionEnum::TOP_TO_BOTTOM->value,
                    suggestedValues: $this->getAvailableDirections()
                ),
            ])
            ->setHelp(<<<'USAGE'
                The <info>%command.name%</info> command dumps the role hierarchy in Mermaid format.

                <info>Mermaid</info>: %command.full_name% > roles.mmd
                <info>Mermaid with direction</info>: %command.full_name% --direction=BT > roles.mmd
                USAGE
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);

        if (null === $this->roleHierarchy) {
            $io->getErrorStyle()->writeln('<comment>No role hierarchy is configured.</comment>');

            return Command::SUCCESS;
        }

        $direction = $input->getOption('direction');

        if (!MermaidDirectionEnum::tryFrom($direction)) {

Review comment (suggestion):
Please don't use named arguments. Argument names are not covered by our BC promise, so relying on argument names of a class belonging to another component would create issues (we rely on semver guarantees between components to allow us to use `^` in constraints)

Code after:

/**
 * Command to dump the role hierarchy as a Mermaid flowchart.
 *
 * @author Damien Fernandes <damien.fernandes24@gmail.com>
 */
#[AsCommand(name: 'debug:security:role-hierarchy', description: 'Dump the role hierarchy as a Mermaid flowchart')]
class SecurityRoleHierarchyDumpCommand extends Command
{
    public function __construct(
        private readonly RoleHierarchyInterface $roleHierarchy,
    ) {
        parent::__construct();
    }

    protected function configure(): void
    {
        $this
            ->setDefinition([
                new InputOption(
                    'direction',
                    'd',
                    InputOption::VALUE_REQUIRED,
                    'The direction of the flowchart ['.implode('|', $this->getAvailableDirections()).']',
                    MermaidDirectionEnum::TOP_TO_BOTTOM->value,
                    $this->getAvailableDirections()
                ),
            ])
            ->setHelp(<<<'USAGE'
                The <info>%command.name%</info> command dumps the role hierarchy in Mermaid format.

                <info>Mermaid</info>: %command.full_name% > roles.mmd
                <info>Mermaid with direction</info>: %command.full_name% --direction=BT > roles.mmd
                USAGE
            )
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);

        if (null === $this->roleHierarchy) {
            $io->getErrorStyle()->writeln('<comment>No role hierarchy is configured.</comment>');

            return Command::SUCCESS;
        }

        $direction = $input->getOption('direction');

        if (!MermaidDirectionEnum::tryFrom($direction)) {