function ArgvInput::getFirstArgument
Overrides InputInterface::getFirstArgument
1 call to ArgvInput::getFirstArgument()
- ArgvInput::getRawTokens in vendor/
symfony/ console/ Input/ ArgvInput.php - Returns un-parsed and not validated tokens.
File
-
vendor/
symfony/ console/ Input/ ArgvInput.php, line 272
Class
- ArgvInput
- ArgvInput represents an input coming from the CLI arguments.
Namespace
Symfony\Component\Console\InputCode
public function getFirstArgument() : ?string {
$isOption = false;
foreach ($this->tokens as $i => $token) {
if ($token && '-' === $token[0]) {
if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
continue;
}
// If it's a long option, consider that everything after "--" is the option name.
// Otherwise, use the last char (if it's a short option set, only the last one can take a value with space separator)
$name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
if (!isset($this->options[$name]) && !$this->definition
->hasShortcut($name)) {
// noop
}
elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition
->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
$isOption = true;
}
continue;
}
if ($isOption) {
$isOption = false;
continue;
}
return $token;
}
return null;
}