Skip to content

Commit 45feb16

Browse files
bug symfony#17253 [Console] HHVM read input stream bug (mbutkereit)
This PR was squashed before being merged into the 2.8 branch (closes symfony#17253). Discussion ---------- [Console] HHVM read input stream bug | Q | A | ------------- | --- | Bug fix? | [yes] | New feature? | [no] | BC breaks? | [no] | Deprecations? | [no] | Tests pass? | [yes] | License | MIT HHVM readline() function requires a parameter see: https://github.com/facebook/hhvm/blob/master/hphp/runtime/ext/readline/ext_readline.php But the php readline does not require one. ``` In Symfony\Component\Console\Helper\QuestionHelper … readFromInput($stream) … ``` we use readline() without a parameter. HHVM Version: ``` HipHop VM 3.10.1 (rel) Compiler: tags/HHVM-3.10.1-0-g689b4969a141620ee5a282ce0dbf72278c84d44b Repo schema: 6c99ee1f98340f6f3ef397a332583f0e843a627d ``` Docker Container: ``` docker run --rm -it -v `pwd`:`pwd` -w `pwd` brunoric/hhvm:deb hhvm test.php ls ``` Test.php ``` <?php use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Helper\QuestionHelper; require_once "vendor/autoload.php"; $console = new Application(); $console ->register('ls') ->setDescription('Try input') ->setCode(function (InputInterface $input, OutputInterface $output) { $question = new Question('Your email address: '); $question->setValidator( function ($answer) { return $answer; } ); $question->setMaxAttempts(5); $helper = new QuestionHelper(); $email = $helper->ask($input, $output, $question); $output->writeln(sprintf('Email Adress: <info>%s</info>', $email)); }) ; $console->run(); ``` composer.json ``` { "require": { "symfony/console": "^3.0" } } ``` Result: No input is possible and you got a warning ``` Your email address: Warning: readline() expects exactly 1 parameter, 0 given in /clitest/vendor/symfony/console/Helper/QuestionHelper.php on line 436 Email Adress: ``` Fix: Add a empty string parameter to readline() or use fgets() for hhvm. Commits ------- e7f17a7 [Console] HHVM read input stream bug
2 parents 8d53763 + e7f17a7 commit 45feb16

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ private function getShell()
439439
private function readFromInput($stream)
440440
{
441441
if (STDIN === $stream && function_exists('readline')) {
442-
$ret = readline();
442+
$ret = readline('');
443443
} else {
444444
$ret = fgets($stream, 4096);
445445
}

0 commit comments

Comments
 (0)