@@ -17,6 +17,7 @@ public function __construct( $prompt ) {
1717 }
1818
1919 public function start () {
20+ // @phpstan-ignore while.alwaysTrue
2021 while ( true ) {
2122 $ line = $ this ->prompt ();
2223
@@ -30,7 +31,7 @@ public function start() {
3031 ob_start ();
3132 // phpcs:ignore Squiz.PHP.Eval.Discouraged -- This is meant to be a REPL, no way to avoid eval.
3233 eval ( $ line );
33- $ out = ob_get_clean ();
34+ $ out = ( string ) ob_get_clean ();
3435 if ( 0 < strlen ( $ out ) ) {
3536 $ out = rtrim ( $ out , "\n" ) . "\n" ;
3637 }
@@ -44,13 +45,13 @@ public function start() {
4445 ob_start ();
4546 // phpcs:ignore Squiz.PHP.Eval.Discouraged -- This is meant to be a REPL, no way to avoid eval.
4647 $ evl = eval ( $ line );
47- $ out = ob_get_clean ();
48+ $ out = ( string ) ob_get_clean ();
4849 if ( 0 < strlen ( $ out ) ) {
4950 echo rtrim ( $ out , "\n" ) . "\n" ;
5051 }
5152 echo '=> ' ;
5253 var_dump ( $ evl );
53- fwrite ( STDOUT , ob_get_clean () );
54+ fwrite ( STDOUT , ( string ) ob_get_clean () );
5455 }
5556 }
5657 }
@@ -82,13 +83,16 @@ private function prompt() {
8283
8384 $ done = false ;
8485 do {
86+ // @phpstan-ignore booleanNot.alwaysTrue
8587 $ prompt = ( ! $ done && false !== $ full_line ) ? '--> ' : $ this ->prompt ;
8688
8789 $ fp = popen ( self ::create_prompt_cmd ( $ prompt , $ this ->history_file ), 'r ' );
8890
89- $ line = fgets ( $ fp );
91+ $ line = $ fp ? fgets ( $ fp ) : '' ;
9092
91- pclose ( $ fp );
93+ if ( $ fp ) {
94+ pclose ( $ fp );
95+ }
9296
9397 if ( ! $ line ) {
9498 break ;
0 commit comments