Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  Skip Twig v3.9-dev for now
  [Validator] Update Dutch (nl) translation
  Update Albanian translations
  [Validator] Update translation
  [FrameworkBundle] Prevent silenced warning by checking if /proc/mount exists
  [VarDumper][PhpUnitBridge] Fix color detection
  prevent throwing NOT_FOUND error when tube is empty
  [Validator] Update missing validator translation for Swedish
  [FrameworkBundle] Fix eager-loading of env vars in ConfigBuilderCacheWarmer
  [Messenger] Fix failing Redis test
  [Validator] Update Italian (it) translations
  [Validator] Missing translations for Hungarian (hu) #53769
  • Loading branch information
nicolas-grekas committed Feb 7, 2024
2 parents ec17108 + f5436ad commit faaaa5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
14 changes: 1 addition & 13 deletions Helper/QuestionHelper.php
Expand Up @@ -501,19 +501,7 @@ private function isInteractiveInput($inputStream): bool
return self::$stdinIsInteractive;
}

if (\function_exists('stream_isatty')) {
return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
}

if (\function_exists('posix_isatty')) {
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
}

if (!\function_exists('shell_exec')) {
return self::$stdinIsInteractive = true;
}

return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
}

/**
Expand Down
26 changes: 4 additions & 22 deletions Output/StreamOutput.php
Expand Up @@ -101,10 +101,7 @@ protected function hasColorSupport(): bool
return false;
}

if (\DIRECTORY_SEPARATOR === '\\'
&& \function_exists('sapi_windows_vt100_support')
&& @sapi_windows_vt100_support($this->stream)
) {
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($this->stream)) {
return true;
}

Expand All @@ -116,14 +113,12 @@ protected function hasColorSupport(): bool
return true;
}

$term = (string) getenv('TERM');

if ('dumb' === $term) {
if ('dumb' === $term = (string) getenv('TERM')) {
return false;
}

// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
return 1 === @preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
}

/**
Expand All @@ -140,19 +135,6 @@ private function isTty(): bool
return true;
}

// Modern cross-platform function, includes the fstat fallback so if it is present we trust it
if (\function_exists('stream_isatty')) {
return stream_isatty($this->stream);
}

// Only trusting this if it is positive, otherwise prefer fstat fallback.
if (\function_exists('posix_isatty') && posix_isatty($this->stream)) {
return true;
}

$stat = @fstat($this->stream);

// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
return @stream_isatty($this->stream);
}
}

0 comments on commit faaaa5e

Please sign in to comment.