You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.6 KiB

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Input;
  11. use Symfony\Component\Console\Exception\InvalidArgumentException;
  12. use Symfony\Component\Console\Exception\RuntimeException;
  13. /**
  14. * InputInterface is the interface implemented by all input classes.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. interface InputInterface
  19. {
  20. /**
  21. * Returns the first argument from the raw parameters (not parsed).
  22. *
  23. * @return string|null The value of the first argument or null otherwise
  24. */
  25. public function getFirstArgument();
  26. /**
  27. * Returns true if the raw parameters (not parsed) contain a value.
  28. *
  29. * This method is to be used to introspect the input parameters
  30. * before they have been validated. It must be used carefully.
  31. * Does not necessarily return the correct result for short options
  32. * when multiple flags are combined in the same option.
  33. *
  34. * @param string|array $values The values to look for in the raw parameters (can be an array)
  35. * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
  36. *
  37. * @return bool true if the value is contained in the raw parameters
  38. */
  39. public function hasParameterOption($values, bool $onlyParams = false);
  40. /**
  41. * Returns the value of a raw option (not parsed).
  42. *
  43. * This method is to be used to introspect the input parameters
  44. * before they have been validated. It must be used carefully.
  45. * Does not necessarily return the correct result for short options
  46. * when multiple flags are combined in the same option.
  47. *
  48. * @param string|array $values The value(s) to look for in the raw parameters (can be an array)
  49. * @param mixed $default The default value to return if no result is found
  50. * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
  51. *
  52. * @return mixed The option value
  53. */
  54. public function getParameterOption($values, $default = false, bool $onlyParams = false);
  55. /**
  56. * Binds the current Input instance with the given arguments and options.
  57. *
  58. * @throws RuntimeException
  59. */
  60. public function bind(InputDefinition $definition);
  61. /**
  62. * Validates the input.
  63. *
  64. * @throws RuntimeException When not enough arguments are given
  65. */
  66. public function validate();
  67. /**
  68. * Returns all the given arguments merged with the default values.
  69. *
  70. * @return array
  71. */
  72. public function getArguments();
  73. /**
  74. * Returns the argument value for a given argument name.
  75. *
  76. * @return string|string[]|null The argument value
  77. *
  78. * @throws InvalidArgumentException When argument given doesn't exist
  79. */
  80. public function getArgument(string $name);
  81. /**
  82. * Sets an argument value by name.
  83. *
  84. * @param string|string[]|null $value The argument value
  85. *
  86. * @throws InvalidArgumentException When argument given doesn't exist
  87. */
  88. public function setArgument(string $name, $value);
  89. /**
  90. * Returns true if an InputArgument object exists by name or position.
  91. *
  92. * @param string|int $name The InputArgument name or position
  93. *
  94. * @return bool true if the InputArgument object exists, false otherwise
  95. */
  96. public function hasArgument($name);
  97. /**
  98. * Returns all the given options merged with the default values.
  99. *
  100. * @return array
  101. */
  102. public function getOptions();
  103. /**
  104. * Returns the option value for a given option name.
  105. *
  106. * @return string|string[]|bool|null The option value
  107. *
  108. * @throws InvalidArgumentException When option given doesn't exist
  109. */
  110. public function getOption(string $name);
  111. /**
  112. * Sets an option value by name.
  113. *
  114. * @param string|string[]|bool|null $value The option value
  115. *
  116. * @throws InvalidArgumentException When option given doesn't exist
  117. */
  118. public function setOption(string $name, $value);
  119. /**
  120. * Returns true if an InputOption object exists by name.
  121. *
  122. * @return bool true if the InputOption object exists, false otherwise
  123. */
  124. public function hasOption(string $name);
  125. /**
  126. * Is this input means interactive?
  127. *
  128. * @return bool
  129. */
  130. public function isInteractive();
  131. /**
  132. * Sets the input interactivity.
  133. */
  134. public function setInteractive(bool $interactive);
  135. }