src/Viserio/Component/Console/Command/CommandResolver.php
private function defaultsViaReflection(StringCommand $command, $callable): array
    {
        if (! \is_callable($callable)) {
            return [];
        }

        $function   = CallableReflection::create($callable);
        $definition = $command->getDefinition();
        $defaults   = [];

        foreach ($function->getParameters() as $parameter) {
            if (! $parameter->isDefaultValueAvailable()) {
                continue;
            }

            $parameterName      = $parameter->name;
            $hyphenatedCaseName = Str::snake($parameterName, '-');

            if ($definition->hasArgument($hyphenatedCaseName) || $definition->hasOption($hyphenatedCaseName)) {
                $parameterName = $hyphenatedCaseName;
            }

            if (! $definition->hasArgument($parameterName) && ! $definition->hasOption($parameterName)) {
                continue;
            }

            $defaults[$parameterName] = $parameter->getDefaultValue();
        }

        return $defaults;
    }
private function defaultsViaReflection(StringCommand $command, $callable): array
    {
        if (! \is_callable($callable)) {
            return [];
        }

        $function   = CallableReflection::create($callable);
        $definition = $command->getDefinition();
        $defaults   = [];

        foreach ($function->getParameters() as $parameter) {
            if (! $parameter->isDefaultValueAvailable()) {
                continue;
            }

            $parameterName      = $parameter->name;
            $hyphenatedCaseName = Str::snake($parameterName, '-');

            if ($definition->hasArgument($hyphenatedCaseName) || $definition->hasOption($hyphenatedCaseName)) {
                $parameterName = $hyphenatedCaseName;
            }

            if (! $definition->hasArgument($parameterName) && ! $definition->hasOption($parameterName)) {
                continue;
            }

            $defaults[$parameterName] = $parameter->getDefaultValue();
        }

        return $defaults;
    }
Reflect default values from callable.

@param \Viserio\Component\Console\Command\StringCommand $command
@param callable|string                                  $callable

@throws \Invoker\Exception\NotCallableException

@return array