@@ -42,9 +42,7 @@ public function setOptions(array $options): AbstractRenderer
4242 } elseif ($ this ->options ['cliColorization ' ] === RendererConstant::CLI_COLOR_DISABLE ) {
4343 $ this ->isCliColorEnabled = false ;
4444 } else {
45- $ stream = \fopen ('php://stdout ' , 'w ' );
46- $ this ->isCliColorEnabled = \PHP_SAPI === 'cli ' && $ this ->hasColorSupport ($ stream );
47- \fclose ($ stream );
45+ $ this ->isCliColorEnabled = \PHP_SAPI === 'cli ' && $ this ->hasColorSupport (\STDOUT );
4846 }
4947
5048 return $ this ;
@@ -76,7 +74,7 @@ protected function renderArrayWorker(array $differArray): string
7674 *
7775 * @return string the (maybe) colorized string
7876 */
79- protected function cliColoredString (string $ str , ?string $ symbol = null ): string
77+ protected function cliColoredString (string $ str , ?string $ symbol ): string
8078 {
8179 static $ symbolToStyles = [
8280 '@ ' => ['f_purple ' , 'bold ' ], // header
@@ -85,11 +83,13 @@ protected function cliColoredString(string $str, ?string $symbol = null): string
8583 '! ' => ['f_yellow ' , 'bold ' ], // replaced
8684 ];
8785
88- if (null === $ symbol || !$ this ->isCliColorEnabled ) {
86+ $ styles = $ symbolToStyles [$ symbol ] ?? [];
87+
88+ if (!$ this ->isCliColorEnabled || empty ($ styles )) {
8989 return $ str ;
9090 }
9191
92- return CliColor::color ($ str , $ symbolToStyles [ $ symbol ] ?? [] );
92+ return CliColor::color ($ str , $ styles );
9393 }
9494
9595 /**
0 commit comments