@@ -28,11 +28,6 @@ class QuestionHelper extends Helper
2828 private  static  $ shell
2929 private  static  $ stty
3030
31-  public  function  __construct ()
32-  {
33-  $ this inputStream  = STDIN ;
34-  }
35- 
3631 /** 
3732 * Asks a question to the user. 
3833 * 
@@ -114,6 +109,8 @@ public function getName()
114109 */ 
115110 public  function  doAsk (OutputInterface $ outputQuestion $ question
116111 {
112+  $ inputStream$ this inputStream  ?: STDIN ;
113+ 
117114 $ message$ questiongetQuestion ();
118115 if  ($ questioninstanceof  ChoiceQuestion) {
119116 $ widthmax (array_map ('strlen ' , array_keys ($ questiongetChoices ())));
@@ -135,7 +132,7 @@ public function doAsk(OutputInterface $output, Question $question)
135132 $ retfalse ;
136133 if  ($ questionisHidden ()) {
137134 try  {
138-  $ rettrim ($ this getHiddenResponse ($ output
135+  $ rettrim ($ this getHiddenResponse ($ output,  $ inputStream 
139136 } catch  (\RuntimeException   $ e
140137 if  (!$ questionisHiddenFallback ()) {
141138 throw  $ e
@@ -144,14 +141,14 @@ public function doAsk(OutputInterface $output, Question $question)
144141 }
145142
146143 if  (false  === $ ret
147-  $ retfgets ($ this -> inputStream , 4096 );
144+  $ retfgets ($ inputStream4096 );
148145 if  (false  === $ ret
149146 throw  new  \RuntimeException ('Aborted ' );
150147 }
151148 $ rettrim ($ ret
152149 }
153150 } else  {
154-  $ rettrim ($ this autocomplete ($ output$ question
151+  $ rettrim ($ this autocomplete ($ output$ question,  $ inputStream 
155152 }
156153
157154 $ retstrlen ($ ret0  ? $ ret$ questiongetDefault ();
@@ -171,7 +168,7 @@ public function doAsk(OutputInterface $output, Question $question)
171168 * 
172169 * @return string 
173170 */ 
174-  private  function  autocomplete (OutputInterface $ outputQuestion $ question
171+  private  function  autocomplete (OutputInterface $ outputQuestion $ question,  $ inputStream 
175172 {
176173 $ autocomplete$ questiongetAutocompleterValues ();
177174 $ ret'' ;
@@ -190,8 +187,8 @@ private function autocomplete(OutputInterface $output, Question $question)
190187 $ outputgetFormatter ()->setStyle ('hl ' , new  OutputFormatterStyle ('black ' , 'white ' ));
191188
192189 // Read a keypress 
193-  while  (!feof ($ this -> inputStream )) {
194-  $ cfread ($ this -> inputStream , 1 );
190+  while  (!feof ($ inputStream
191+  $ cfread ($ inputStream1 );
195192
196193 // Backspace Character 
197194 if  ("\177"  === $ c
@@ -212,7 +209,7 @@ private function autocomplete(OutputInterface $output, Question $question)
212209 // Pop the last character off the end of our string 
213210 $ retsubstr ($ ret0 , $ i
214211 } elseif  ("\033"  === $ c// Did we read an escape sequence? 
215- $ cfread ($ this -> inputStream , 2 );
212+ $ cfread ($ inputStream2 );
216213
217214 // A = Up Arrow. B = Down Arrow 
218215 if  ('A '  === $ c2 ] || 'B '  === $ c2 ]) {
@@ -289,7 +286,7 @@ private function autocomplete(OutputInterface $output, Question $question)
289286 * 
290287 * @throws \RuntimeException In case the fallback is deactivated and the response cannot be hidden 
291288 */ 
292-  private  function  getHiddenResponse (OutputInterface $ output
289+  private  function  getHiddenResponse (OutputInterface $ output,  $ inputStream 
293290 {
294291 if  (defined ('PHP_WINDOWS_VERSION_BUILD ' )) {
295292 $ exe__DIR__ .'/../Resources/bin/hiddeninput.exe ' ;
@@ -315,7 +312,7 @@ private function getHiddenResponse(OutputInterface $output)
315312 $ sttyModeshell_exec ('stty -g ' );
316313
317314 shell_exec ('stty -echo ' );
318-  $ valuefgets ($ this -> inputStream , 4096 );
315+  $ valuefgets ($ inputStream4096 );
319316 shell_exec (sprintf ('stty %s ' , $ sttyMode
320317
321318 if  (false  === $ value
0 commit comments