Quellcode durchsuchen

[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 vor 14 Jahren
Ursprung
Commit
3a5d508766
1 geänderte Dateien mit 1 neuen und 1 gelöschten Zeilen
  1. 1 1
      src/Symfony/Component/Console/Helper/DialogHelper.php

+ 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);