@@ -106,7 +106,7 @@ private function doAsk(OutputInterface $output, Question $question)
106106 {
107107 $ this ->writePrompt ($ output , $ question );
108108
109- $ inputStream = $ this ->inputStream ?: STDIN ;
109+ $ inputStream = $ this ->inputStream ?: fopen ( ' php://stdin ' , ' r ' ) ;
110110 $ autocomplete = $ question ->getAutocompleterCallback ();
111111
112112 if (null === $ autocomplete || !self ::$ stty || !Terminal::hasSttyAvailable ()) {
@@ -473,7 +473,7 @@ private function validateAttempts(callable $interviewer, OutputInterface $output
473473 } catch (\Exception $ error ) {
474474 }
475475
476- $ attempts = $ attempts ?? -(int ) $ this ->isTty ();
476+ $ attempts = $ attempts ?? -(int ) $ this ->askForever ();
477477 }
478478
479479 throw $ error ;
@@ -506,18 +506,20 @@ private function getShell()
506506 return self ::$ shell ;
507507 }
508508
509- private function isTty (): bool
509+ private function askForever (): bool
510510 {
511- if (!\defined ('STDIN ' )) {
511+ $ inputStream = $ this ->inputStream ?: fopen ('php://stdin ' , 'r ' );
512+
513+ if ('php://stdin ' !== (stream_get_meta_data ($ inputStream )['url ' ] ?? null )) {
512514 return true ;
513515 }
514516
515517 if (\function_exists ('stream_isatty ' )) {
516- return stream_isatty (fopen ( ' php://input ' , ' r ' ) );
518+ return stream_isatty ($ inputStream );
517519 }
518520
519521 if (\function_exists ('posix_isatty ' )) {
520- return posix_isatty (fopen ( ' php://input ' , ' r ' ) );
522+ return posix_isatty ($ inputStream );
521523 }
522524
523525 return true ;
0 commit comments