Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b95e86a

Browse files
Merge branch '6.4' into 7.0
* 6.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 revert to native PHP union types [Validator] Missing translations for Russian (ru) #53775 fix syntax errors on PHP 7
2 parents 2900969 + faaaa5e commit b95e86a

3 files changed

Lines changed: 8 additions & 61 deletions

File tree

Helper/QuestionHelper.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -495,19 +495,7 @@ private function isInteractiveInput($inputStream): bool
495495
return self::$stdinIsInteractive;
496496
}
497497

498-
if (\function_exists('stream_isatty')) {
499-
return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
500-
}
501-
502-
if (\function_exists('posix_isatty')) {
503-
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
504-
}
505-
506-
if (!\function_exists('shell_exec')) {
507-
return self::$stdinIsInteractive = true;
508-
}
509-
510-
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
498+
return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
511499
}
512500

513501
/**

Output/StreamOutput.php

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ protected function hasColorSupport(): bool
9494
return false;
9595
}
9696

97-
if (!$this->isTty()) {
97+
// Detect msysgit/mingw and assume this is a tty because detection
98+
// does not work correctly, see https://github.com/composer/composer/issues/9690
99+
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
98100
return false;
99101
}
100102

101-
if (\DIRECTORY_SEPARATOR === '\\'
102-
&& \function_exists('sapi_windows_vt100_support')
103-
&& @sapi_windows_vt100_support($this->stream)
104-
) {
103+
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($this->stream)) {
105104
return true;
106105
}
107106

@@ -113,43 +112,11 @@ protected function hasColorSupport(): bool
113112
return true;
114113
}
115114

116-
$term = (string) getenv('TERM');
117-
118-
if ('dumb' === $term) {
115+
if ('dumb' === $term = (string) getenv('TERM')) {
119116
return false;
120117
}
121118

122119
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
123-
return 1 === @preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
124-
}
125-
126-
/**
127-
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
128-
*
129-
* Reference: Composer\Util\Platform::isTty
130-
* https://github.com/composer/composer
131-
*/
132-
private function isTty(): bool
133-
{
134-
// Detect msysgit/mingw and assume this is a tty because detection
135-
// does not work correctly, see https://github.com/composer/composer/issues/9690
136-
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
137-
return true;
138-
}
139-
140-
// Modern cross-platform function, includes the fstat fallback so if it is present we trust it
141-
if (\function_exists('stream_isatty')) {
142-
return stream_isatty($this->stream);
143-
}
144-
145-
// Only trusting this if it is positive, otherwise prefer fstat fallback.
146-
if (\function_exists('posix_isatty') && posix_isatty($this->stream)) {
147-
return true;
148-
}
149-
150-
$stat = @fstat($this->stream);
151-
152-
// Check if formatted mode is S_IFCHR
153-
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
120+
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
154121
}
155122
}

Terminal.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private static function initDimensions(): void
140140
// or [w, h] from "wxh"
141141
self::$width = (int) $matches[1];
142142
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
143-
} elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
143+
} elseif (!sapi_windows_vt100_support(fopen('php://stdout', 'w')) && self::hasSttyAvailable()) {
144144
// only use stty on Windows if the terminal does not support vt100 (e.g. Windows 7 + git-bash)
145145
// testing for stty in a Windows 10 vt100-enabled console will implicitly disable vt100 support on STDOUT
146146
self::initDimensionsUsingStty();
@@ -154,14 +154,6 @@ private static function initDimensions(): void
154154
}
155155
}
156156

157-
/**
158-
* Returns whether STDOUT has vt100 support (some Windows 10+ configurations).
159-
*/
160-
private static function hasVt100Support(): bool
161-
{
162-
return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
163-
}
164-
165157
/**
166158
* Initializes dimensions using the output of an stty columns line.
167159
*/

0 commit comments

Comments
 (0)