Przeglądaj źródła

[Console] replaced fgets by stream_get_line in DialogHelper

Problem with fgets is that false means two things: an error or the end of the stream.
That's ok for STDIN, but it becomes a problem when using another stream (in a unit test for instance).
Fabien Potencier 14 lat temu
rodzic
commit
3a5d508766

+ 1 - 1
src/Symfony/Component/Console/Helper/DialogHelper.php

@@ -35,7 +35,7 @@ class DialogHelper extends Helper
     {
         $output->write($question);
 
-        if (false === $ret = fgets(null === $this->inputStream ? STDIN : $this->inputStream)) {
+        if (false === stream_get_line(null === $this->inputStream ? STDIN : $this->inputStream, 4096, "\n")) {
             throw new \Exception('Aborted');
         }
         $ret = trim($ret);