ConsoleOutput.php (flow-development-collection-5.2.1) | : | ConsoleOutput.php (flow-development-collection-5.2.2) | ||
---|---|---|---|---|
skipping to change at line 179 | skipping to change at line 179 | |||
->setErrorMessage('Value "%s" is invalid'); | ->setErrorMessage('Value "%s" is invalid'); | |||
return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | |||
} | } | |||
/** | /** | |||
* Asks a question to the user | * Asks a question to the user | |||
* | * | |||
* @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question | * @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question | |||
* @param string $default The default answer if none is given by the user | * @param string $default The default answer if none is given by the user | |||
* @return string The user answer | * @return mixed The user answer | |||
* @throws \RuntimeException If there is no data to read in the input stream | * @throws \RuntimeException If there is no data to read in the input stream | |||
*/ | */ | |||
public function ask($question, string $default = null): string | public function ask($question, string $default = null) | |||
{ | { | |||
$question = new Question($this->combineQuestion($question), $default); | $question = new Question($this->combineQuestion($question), $default); | |||
return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | |||
} | } | |||
/** | /** | |||
* Asks a confirmation to the user. | * Asks a confirmation to the user. | |||
* | * | |||
* The question will be asked until the user answers by nothing, yes, or no. | * The question will be asked until the user answers by nothing, yes, or no. | |||
skipping to change at line 210 | skipping to change at line 210 | |||
$question = new ConfirmationQuestion($this->combineQuestion($question), $default); | $question = new ConfirmationQuestion($this->combineQuestion($question), $default); | |||
return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | |||
} | } | |||
/** | /** | |||
* Asks a question to the user, the response is hidden | * Asks a question to the user, the response is hidden | |||
* | * | |||
* @param string|array $question The question. If an array each array item i s turned into one line of a multi-line question | * @param string|array $question The question. If an array each array item i s turned into one line of a multi-line question | |||
* @param Boolean $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not | * @param Boolean $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not | |||
* @return string The answer | * @return mixed The answer | |||
* @throws \RuntimeException In case the fallback is deactivated and the res ponse can not be hidden | * @throws \RuntimeException In case the fallback is deactivated and the res ponse can not be hidden | |||
*/ | */ | |||
public function askHiddenResponse($question, bool $fallback = true): string | public function askHiddenResponse($question, bool $fallback = true) | |||
{ | { | |||
$question = new Question($this->combineQuestion($question)); | $question = new Question($this->combineQuestion($question)); | |||
$question | $question | |||
->setHidden(true) | ->setHidden(true) | |||
->setHiddenFallback($fallback); | ->setHiddenFallback($fallback); | |||
return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | |||
} | } | |||
/** | /** | |||
skipping to change at line 235 | skipping to change at line 235 | |||
* | * | |||
* The validator receives the data to validate. It must return the | * The validator receives the data to validate. It must return the | |||
* validated data when the data is valid and throw an exception | * validated data when the data is valid and throw an exception | |||
* otherwise. | * otherwise. | |||
* | * | |||
* @see https://symfony.com/doc/current/components/console/helpers/questionh elper.html#validating-the-answer | * @see https://symfony.com/doc/current/components/console/helpers/questionh elper.html#validating-the-answer | |||
* @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question | * @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question | |||
* @param callable $validator A PHP callback that gets a value and is expect ed to return the (transformed) value or throw an exception if it wasn't valid | * @param callable $validator A PHP callback that gets a value and is expect ed to return the (transformed) value or throw an exception if it wasn't valid | |||
* @param integer|null $attempts Max number of times to ask before giving up (null by default, which means infinite) | * @param integer|null $attempts Max number of times to ask before giving up (null by default, which means infinite) | |||
* @param string $default The default answer if none is given by the user | * @param string $default The default answer if none is given by the user | |||
* @return string The response | * @return mixed The response | |||
* @throws \Exception When any of the validators return an error | * @throws \Exception When any of the validators return an error | |||
*/ | */ | |||
public function askAndValidate($question, callable $validator, int $attempts = null, string $default = null): string | public function askAndValidate($question, callable $validator, int $attempts = null, string $default = null) | |||
{ | { | |||
$question = new Question($this->combineQuestion($question), $default); | $question = new Question($this->combineQuestion($question), $default); | |||
$question | $question | |||
->setValidator($validator) | ->setValidator($validator) | |||
->setMaxAttempts($attempts); | ->setMaxAttempts($attempts); | |||
return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | |||
} | } | |||
/** | /** | |||
* Asks for a value, hide and validates the response | * Asks for a value, hide and validates the response | |||
* | * | |||
* The validator receives the data to validate. It must return the | * The validator receives the data to validate. It must return the | |||
* validated data when the data is valid and throw an exception | * validated data when the data is valid and throw an exception | |||
* otherwise. | * otherwise. | |||
* | * | |||
* @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question | * @param string|array $question The question to ask. If an array each array item is turned into one line of a multi-line question | |||
* @param callable $validator A PHP callback that gets a value and is expect ed to return the (transformed) value or throw an exception if it wasn't valid | * @param callable $validator A PHP callback that gets a value and is expect ed to return the (transformed) value or throw an exception if it wasn't valid | |||
* @param integer|null $attempts Max number of times to ask before giving up (null by default, which means infinite) | * @param integer|null $attempts Max number of times to ask before giving up (null by default, which means infinite) | |||
* @param boolean $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not | * @param boolean $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not | |||
* @return string The response | * @return mixed The response | |||
* @throws \Exception When any of the validators return an error | * @throws \Exception When any of the validators return an error | |||
* @throws \RuntimeException In case the fallback is deactivated and the res ponse can not be hidden | * @throws \RuntimeException In case the fallback is deactivated and the res ponse can not be hidden | |||
*/ | */ | |||
public function askHiddenResponseAndValidate($question, callable $validator, int $attempts = null, bool $fallback = true): string | public function askHiddenResponseAndValidate($question, callable $validator, int $attempts = null, bool $fallback = true) | |||
{ | { | |||
$question = new Question($this->combineQuestion($question)); | $question = new Question($this->combineQuestion($question)); | |||
$question | $question | |||
->setHidden(true) | ->setHidden(true) | |||
->setHiddenFallback($fallback) | ->setHiddenFallback($fallback) | |||
->setValidator($validator) | ->setValidator($validator) | |||
->setMaxAttempts($attempts); | ->setMaxAttempts($attempts); | |||
return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | return $this->getQuestionHelper()->ask($this->input, $this->output, $que stion); | |||
} | } | |||
End of changes. 8 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added |