@@ -512,7 +512,7 @@ private function readInput($inputStream, Question $question)
512
512
$ cp = $ this ->setIOCodepage ();
513
513
$ ret = fgets ($ inputStream , 4096 );
514
514
515
- return false !== $ ret ? $ this ->resetIOCodepage ($ cp , $ ret ) : false ;
515
+ return $ this ->resetIOCodepage ($ cp , $ ret );
516
516
}
517
517
518
518
$ multiLineStreamReader = $ this ->cloneInputStream ($ inputStream );
@@ -533,7 +533,7 @@ private function readInput($inputStream, Question $question)
533
533
}
534
534
535
535
/**
536
- * Set console I/O to the host code page.
536
+ * Sets console I/O to the host code page.
537
537
*
538
538
* @return int Previous code page in IBM/EBCDIC format
539
539
*/
@@ -550,13 +550,20 @@ private function setIOCodepage(): int
550
550
}
551
551
552
552
/**
553
- * Set console I/O to the specified code page and convert the user input.
553
+ * Sets console I/O to the specified code page and converts the user input.
554
+ *
555
+ * @param string|false $input
556
+ *
557
+ * @return string|false
554
558
*/
555
- private function resetIOCodepage (int $ cp , string $ input ): string
559
+ private function resetIOCodepage (int $ cp , $ input )
556
560
{
557
- if (\function_exists ( ' sapi_windows_cp_set ' ) && 0 < $ cp ) {
561
+ if (0 !== $ cp ) {
558
562
sapi_windows_cp_set ($ cp );
559
- $ input = sapi_windows_cp_conv (sapi_windows_cp_get ('oem ' ), $ cp , $ input );
563
+
564
+ if (false !== $ input && '' !== $ input ) {
565
+ $ input = sapi_windows_cp_conv (sapi_windows_cp_get ('oem ' ), $ cp , $ input );
566
+ }
560
567
}
561
568
562
569
return $ input ;
0 commit comments