platform/api/symfony/Component/Console/Input/Input.yaml
2024-09-02 10:44:11 -07:00

105 lines
5.5 KiB
YAML

name: Input
class_comment: null
dependencies:
- name: InvalidArgumentException
type: class
source: Symfony\Component\Console\Exception\InvalidArgumentException
- name: RuntimeException
type: class
source: Symfony\Component\Console\Exception\RuntimeException
properties:
- name: stream
visibility: protected
comment: '# * Input is the base class for all concrete Input classes.
# *
# * Three concrete classes are provided by default:
# *
# * * `ArgvInput`: The input comes from the CLI arguments (argv)
# * * `StringInput`: The input is provided as a string
# * * `ArrayInput`: The input is provided as an array
# *
# * @author Fabien Potencier <fabien@symfony.com>
# */
# abstract class Input implements InputInterface, StreamableInputInterface
# {
# protected InputDefinition $definition;
# /** @var resource'
methods:
- name: escapeToken
visibility: public
parameters:
- name: token
comment: "# * Input is the base class for all concrete Input classes.\n# *\n# *\
\ Three concrete classes are provided by default:\n# *\n# * * `ArgvInput`: The\
\ input comes from the CLI arguments (argv)\n# * * `StringInput`: The input is\
\ provided as a string\n# * * `ArrayInput`: The input is provided as an array\n\
# *\n# * @author Fabien Potencier <fabien@symfony.com>\n# */\n# abstract class\
\ Input implements InputInterface, StreamableInputInterface\n# {\n# protected\
\ InputDefinition $definition;\n# /** @var resource */\n# protected $stream;\n\
# protected array $options = [];\n# protected array $arguments = [];\n# protected\
\ bool $interactive = true;\n# \n# public function __construct(?InputDefinition\
\ $definition = null)\n# {\n# if (null === $definition) {\n# $this->definition\
\ = new InputDefinition();\n# } else {\n# $this->bind($definition);\n# $this->validate();\n\
# }\n# }\n# \n# public function bind(InputDefinition $definition): void\n# {\n\
# $this->arguments = [];\n# $this->options = [];\n# $this->definition = $definition;\n\
# \n# $this->parse();\n# }\n# \n# /**\n# * Processes command line arguments.\n\
# */\n# abstract protected function parse(): void;\n# \n# public function validate():\
\ void\n# {\n# $definition = $this->definition;\n# $givenArguments = $this->arguments;\n\
# \n# $missingArguments = array_filter(array_keys($definition->getArguments()),\
\ fn ($argument) => !\\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired());\n\
# \n# if (\\count($missingArguments) > 0) {\n# throw new RuntimeException(\\sprintf('Not\
\ enough arguments (missing: \"%s\").', implode(', ', $missingArguments)));\n\
# }\n# }\n# \n# public function isInteractive(): bool\n# {\n# return $this->interactive;\n\
# }\n# \n# public function setInteractive(bool $interactive): void\n# {\n# $this->interactive\
\ = $interactive;\n# }\n# \n# public function getArguments(): array\n# {\n# return\
\ array_merge($this->definition->getArgumentDefaults(), $this->arguments);\n#\
\ }\n# \n# public function getArgument(string $name): mixed\n# {\n# if (!$this->definition->hasArgument($name))\
\ {\n# throw new InvalidArgumentException(\\sprintf('The \"%s\" argument does\
\ not exist.', $name));\n# }\n# \n# return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();\n\
# }\n# \n# public function setArgument(string $name, mixed $value): void\n# {\n\
# if (!$this->definition->hasArgument($name)) {\n# throw new InvalidArgumentException(\\\
sprintf('The \"%s\" argument does not exist.', $name));\n# }\n# \n# $this->arguments[$name]\
\ = $value;\n# }\n# \n# public function hasArgument(string $name): bool\n# {\n\
# return $this->definition->hasArgument($name);\n# }\n# \n# public function getOptions():\
\ array\n# {\n# return array_merge($this->definition->getOptionDefaults(), $this->options);\n\
# }\n# \n# public function getOption(string $name): mixed\n# {\n# if ($this->definition->hasNegation($name))\
\ {\n# if (null === $value = $this->getOption($this->definition->negationToName($name)))\
\ {\n# return $value;\n# }\n# \n# return !$value;\n# }\n# \n# if (!$this->definition->hasOption($name))\
\ {\n# throw new InvalidArgumentException(\\sprintf('The \"%s\" option does not\
\ exist.', $name));\n# }\n# \n# return \\array_key_exists($name, $this->options)\
\ ? $this->options[$name] : $this->definition->getOption($name)->getDefault();\n\
# }\n# \n# public function setOption(string $name, mixed $value): void\n# {\n\
# if ($this->definition->hasNegation($name)) {\n# $this->options[$this->definition->negationToName($name)]\
\ = !$value;\n# \n# return;\n# } elseif (!$this->definition->hasOption($name))\
\ {\n# throw new InvalidArgumentException(\\sprintf('The \"%s\" option does not\
\ exist.', $name));\n# }\n# \n# $this->options[$name] = $value;\n# }\n# \n# public\
\ function hasOption(string $name): bool\n# {\n# return $this->definition->hasOption($name)\
\ || $this->definition->hasNegation($name);\n# }\n# \n# /**\n# * Escapes a token\
\ through escapeshellarg if it contains unsafe chars."
- name: setStream
visibility: public
parameters:
- name: stream
comment: '# * @param resource $stream'
- name: getStream
visibility: public
parameters: []
comment: '# * @return resource'
traits:
- Symfony\Component\Console\Exception\InvalidArgumentException
- Symfony\Component\Console\Exception\RuntimeException
interfaces:
- InputInterface