// bind the input against the command specific arguments/options
try{
$input->bind($this->getDefinition());
}catch(ExceptionInterface$e){
if(!$this->ignoreValidationErrors){
throw$e;
}
}
$this->initialize($input,$output);
if(null!==$this->processTitle){
if(\function_exists('cli_set_process_title')){
if(!@cli_set_process_title($this->processTitle)){
if('Darwin'===\PHP_OS){
$output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>',OutputInterface::VERBOSITY_VERY_VERBOSE);
return$this->definition??thrownewLogicException(\sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.',static::class));
}
/**
* Adds an argument.
*
* @param $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
* @param $default The default value (for InputArgument::OPTIONAL mode only)
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
*
* @return $this
*
* @throws InvalidArgumentException When argument mode is not valid
thrownewLogicException(\sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.',$name));
}
return$this->helperSet->get($name);
}
/**
* Validates a command name.
*
* It must be non-empty and parts can optionally be separated by ":".
*
* @throws InvalidArgumentException When the name is invalid
*/
privatefunctionvalidateName(string$name):void
{
if(!preg_match('/^[^\:]++(\:[^\:]++)*$/',$name)){
thrownewInvalidArgumentException(\sprintf('Command name "%s" is invalid.',$name));