Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. QuestionHelper.php

function QuestionHelper::readInput

Reads one or more lines of input and returns what is read.

Parameters

resource $inputStream The handler resource:

Question $question The question being asked:

1 call to QuestionHelper::readInput()
QuestionHelper::doAsk in vendor/symfony/console/Helper/QuestionHelper.php
Asks the question to the user.

File

vendor/symfony/console/Helper/QuestionHelper.php, line 502

Class

QuestionHelper
The QuestionHelper class provides helpers to interact with the user.

Namespace

Symfony\Component\Console\Helper

Code

private function readInput($inputStream, Question $question) : string|false {
    if (!$question->isMultiline()) {
        $cp = $this->setIOCodepage();
        $ret = fgets($inputStream, 4096);
        return $this->resetIOCodepage($cp, $ret);
    }
    $multiLineStreamReader = $this->cloneInputStream($inputStream);
    if (null === $multiLineStreamReader) {
        return false;
    }
    $ret = '';
    $cp = $this->setIOCodepage();
    while (false !== ($char = fgetc($multiLineStreamReader))) {
        if (\PHP_EOL === "{$ret}{$char}") {
            break;
        }
        $ret .= $char;
    }
    return $this->resetIOCodepage($cp, $ret);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal