isMultiline example

return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
    }

    /** * Reads one or more lines of input and returns what is read. * * @param resource $inputStream The handler resource * @param Question $question The question being asked */
    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;
        }

        

class SymfonyQuestionHelper extends QuestionHelper
{
    /** * @return void */
    protected function writePrompt(OutputInterface $output, Question $question)
    {
        $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
        $default = $question->getDefault();

        if ($question->isMultiline()) {
            $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
        }

        switch (true) {
            case null === $default:
                $text = sprintf(' <info>%s</info>:', $text);

                break;

            case $question instanceof ConfirmationQuestion:
                $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text$default ? 'yes' : 'no');

                
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
    }

    /** * Reads one or more lines of input and returns what is read. * * @param resource $inputStream The handler resource * @param Question $question The question being asked */
    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;
        }

        
public function testGetNormalizerDefault()
    {
        self::assertNull($this->question->getNormalizer());
    }

    /** * @dataProvider providerTrueFalse */
    public function testSetMultiline(bool $multiline)
    {
        self::assertSame($this->question, $this->question->setMultiline($multiline));
        self::assertSame($multiline$this->question->isMultiline());
    }

    public function testIsMultilineDefault()
    {
        self::assertFalse($this->question->isMultiline());
    }
}
final class TextInputTest extends AbstractInputTestCase
{
    public function createInput(): TextInput
    {
        return new TextInput();
    }

    public function testIsMultilineWithTrue()
    {
        $input = $this->createInput()
            ->isMultiline(true);

        $this->assertTrue($input->toArray()['isMultiline']);
    }

    public function testIsMultilineWithFalse()
    {
        $input = $this->createInput()
            ->isMultiline(false);

        $this->assertFalse($input->toArray()['isMultiline']);
    }

    

class SymfonyQuestionHelper extends QuestionHelper
{
    /** * @return void */
    protected function writePrompt(OutputInterface $output, Question $question)
    {
        $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
        $default = $question->getDefault();

        if ($question->isMultiline()) {
            $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
        }

        switch (true) {
            case null === $default:
                $text = sprintf(' <info>%s</info>:', $text);

                break;

            case $question instanceof ConfirmationQuestion:
                $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text$default ? 'yes' : 'no');

                
Home | Imprint | This part of the site doesn't use cookies.