QuestionHelper
class QuestionHelper extends Helper
Класс QuestionHelper предоставляет помощники для взаимодействия с пользователем.
Свойства
| protected | $helperSet | из Helper |
Методы
| setHelperSet(HelperSet $helperSet = null) Устанавливает набор помощников, связанных с этим помощником. | из Helper | |
| HelperSet | getHelperSet() Получает набор помощников, связанных с этим помощником. | из Helper |
| static int | strlen(string $string) Возвращает длину строки, используя mb_strwidth, если он доступен. | из Helper |
| static string | substr(string $string, int $from, int|null $length = null) Возвращает подстроку строки, используя mb_substr, если он доступен. | из Helper |
| static | formatTime($secs) | из Helper |
| static | formatMemory($memory) | из Helper |
| static | strlenWithoutDecoration(OutputFormatterInterface $formatter, $string) | из Helper |
| static | removeDecoration(OutputFormatterInterface $formatter, $string) | из Helper |
| mixed | ask(InputInterface $input, OutputInterface $output, Question $question) Задает вопрос пользователю. | |
| string | getName() Возвращает каноническое имя этого помощника. | |
| static | disableStty() Запрещает использование stty. | |
| writePrompt(OutputInterface $output, Question $question) Выводит приглашение к вопросу. | ||
| writeError(OutputInterface $output, Exception $error) Выводит сообщение об ошибке. |
Подробности
setHelperSet(HelperSet $helperSet = null)
Устанавливает набор помощников, связанных с этим помощником.
Параметры
| HelperSet | $helperSet |
HelperSet getHelperSet()
Получает набор помощников, связанных с этим помощником.
Возвращаемое значение
| HelperSet | Экземпляр HelperSet |
static int strlen(string $string)
Возвращает длину строки, используя mb_strwidth, если он доступен.
Параметры
| string | $string | Строка, для которой необходимо проверить длину |
Возвращаемое значение
| int | Длина строки |
static string substr(string $string, int $from, int|null $length = null)
Возвращает подстроку строки, используя mb_substr, если он доступен.
Параметры
| string | $string | Строка для выделения подстроки |
| int | $from | Начальный смещение |
| int|null | $length | Длина подстроки |
Возвращаемое значение
| string | Подстрока |
static formatTime($secs)
Параметры
| $secs |
static formatMemory($memory)
Параметры
| $memory |
static strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
Параметры
| OutputFormatterInterface | $formatter | |
| $string |
static removeDecoration(OutputFormatterInterface $formatter, $string)
Параметры
| OutputFormatterInterface | $formatter | |
| $string |
mixed ask(InputInterface $input, OutputInterface $output, Question $question)
Задает вопрос пользователю.
Параметры
| InputInterface | $input | |
| OutputInterface | $output | |
| Question | $question |
Возвращаемое значение
| mixed | Ответ пользователя |
Исключения
| RuntimeException | Если нет данных для чтения из потока ввода |
string getName()
Возвращает каноническое имя этого помощника.
Возвращаемое значение
| string | Каноническое имя |
static disableStty()
Запрещает использование stty.
protected writePrompt(OutputInterface $output, Question $question)
Выводит приглашение к вопросу.
Параметры
| OutputInterface | $output | |
| Question | $question |
protected writeError(OutputInterface $output, Exception $error)
Выводит сообщение об ошибке.
Параметры
| OutputInterface | $output | |
| Exception | $error |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Helper/QuestionHelper.html