X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fconsole%2FHelper%2FQuestionHelper.php;h=d8b373cc1757bb2ae3651c760579326ff0a8bf69;hp=8998f7b0f3c217f0ccf7a09d35d790bdd35c2d98;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/symfony/console/Helper/QuestionHelper.php b/vendor/symfony/console/Helper/QuestionHelper.php index 8998f7b0f..d8b373cc1 100644 --- a/vendor/symfony/console/Helper/QuestionHelper.php +++ b/vendor/symfony/console/Helper/QuestionHelper.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\StreamableInputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Formatter\OutputFormatterStyle; @@ -52,14 +53,16 @@ class QuestionHelper extends Helper return $question->getDefault(); } + if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) { + $this->inputStream = $stream; + } + if (!$question->getValidator()) { return $this->doAsk($output, $question); } - $that = $this; - - $interviewer = function () use ($output, $question, $that) { - return $that->doAsk($output, $question); + $interviewer = function () use ($output, $question) { + return $this->doAsk($output, $question); }; return $this->validateAttempts($interviewer, $output, $question); @@ -70,12 +73,17 @@ class QuestionHelper extends Helper * * This is mainly useful for testing purpose. * + * @deprecated since version 3.2, to be removed in 4.0. Use + * StreamableInputInterface::setStream() instead. + * * @param resource $stream The input stream * * @throws InvalidArgumentException In case the stream is not a resource */ public function setInputStream($stream) { + @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); + if (!is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); } @@ -86,10 +94,17 @@ class QuestionHelper extends Helper /** * Returns the helper's input stream. * + * @deprecated since version 3.2, to be removed in 4.0. Use + * StreamableInputInterface::getStream() instead. + * * @return resource */ public function getInputStream() { + if (0 === func_num_args() || func_get_arg(0)) { + @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); + } + return $this->inputStream; } @@ -104,17 +119,14 @@ class QuestionHelper extends Helper /** * Asks the question to the user. * - * This method is public for PHP 5.3 compatibility, it should be private. - * * @param OutputInterface $output * @param Question $question * * @return bool|mixed|null|string * - * @throws \Exception - * @throws \RuntimeException + * @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden */ - public function doAsk(OutputInterface $output, Question $question) + private function doAsk(OutputInterface $output, Question $question) { $this->writePrompt($output, $question); @@ -126,7 +138,7 @@ class QuestionHelper extends Helper if ($question->isHidden()) { try { $ret = trim($this->getHiddenResponse($output, $inputStream)); - } catch (\RuntimeException $e) { + } catch (RuntimeException $e) { if (!$question->isHiddenFallback()) { throw $e; } @@ -388,7 +400,7 @@ class QuestionHelper extends Helper * * @throws \Exception In case the max number of attempts has been reached and no valid response has been given */ - private function validateAttempts($interviewer, OutputInterface $output, Question $question) + private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) { $error = null; $attempts = $question->getMaxAttempts();