modif comtabilite
This commit is contained in:
+9
-8
@@ -14,15 +14,16 @@ namespace Symfony\Component\Console\Output;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
|
||||
/**
|
||||
* ConsoleOutput is the default class for all CLI output. It uses STDOUT.
|
||||
* ConsoleOutput is the default class for all CLI output. It uses STDOUT and STDERR.
|
||||
*
|
||||
* This class is a convenient wrapper around `StreamOutput`.
|
||||
* This class is a convenient wrapper around `StreamOutput` for both STDOUT and STDERR.
|
||||
*
|
||||
* $output = new ConsoleOutput();
|
||||
*
|
||||
* This is equivalent to:
|
||||
*
|
||||
* $output = new StreamOutput(fopen('php://stdout', 'w'));
|
||||
* $stdErr = new StreamOutput(fopen('php://stderr', 'w'));
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
@@ -121,7 +122,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
private function isRunningOS400()
|
||||
{
|
||||
$checks = array(
|
||||
function_exists('php_uname') ? php_uname('s') : '',
|
||||
\function_exists('php_uname') ? php_uname('s') : '',
|
||||
getenv('OSTYPE'),
|
||||
PHP_OS,
|
||||
);
|
||||
@@ -134,9 +135,11 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
*/
|
||||
private function openOutputStream()
|
||||
{
|
||||
$outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
|
||||
if (!$this->hasStdoutSupport()) {
|
||||
return fopen('php://output', 'w');
|
||||
}
|
||||
|
||||
return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
|
||||
return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,8 +147,6 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
*/
|
||||
private function openErrorStream()
|
||||
{
|
||||
$errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
|
||||
|
||||
return fopen($errorStream, 'w');
|
||||
return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,8 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Console\Output;
|
||||
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
|
||||
/**
|
||||
* Base class for output classes.
|
||||
|
||||
+30
-2
@@ -33,7 +33,7 @@ interface OutputInterface
|
||||
/**
|
||||
* Writes a message to the output.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines or a single string
|
||||
* @param string|array $messages The message as an array of strings or a single string
|
||||
* @param bool $newline Whether to add a newline
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ interface OutputInterface
|
||||
/**
|
||||
* Writes a message to the output and adds a newline at the end.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines of a single string
|
||||
* @param string|array $messages The message as an array of strings or a single string
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
public function writeln($messages, $options = 0);
|
||||
@@ -61,6 +61,34 @@ interface OutputInterface
|
||||
*/
|
||||
public function getVerbosity();
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is quiet (-q).
|
||||
*
|
||||
* @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise
|
||||
*/
|
||||
public function isQuiet();
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is verbose (-v).
|
||||
*
|
||||
* @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise
|
||||
*/
|
||||
public function isVerbose();
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is very verbose (-vv).
|
||||
*
|
||||
* @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise
|
||||
*/
|
||||
public function isVeryVerbose();
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is debug (-vvv).
|
||||
*
|
||||
* @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise
|
||||
*/
|
||||
public function isDebug();
|
||||
|
||||
/**
|
||||
* Sets the decorated flag.
|
||||
*
|
||||
|
||||
+24
-17
@@ -20,11 +20,11 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* $output = new StreamOutput(fopen('php://stdout', 'w'));
|
||||
* $output = new StreamOutput(fopen('php://stdout', 'w'));
|
||||
*
|
||||
* As `StreamOutput` can use any stream, you can also use a file:
|
||||
*
|
||||
* $output = new StreamOutput(fopen('/path/to/output.log', 'a', false));
|
||||
* $output = new StreamOutput(fopen('/path/to/output.log', 'a', false));
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ class StreamOutput extends Output
|
||||
*/
|
||||
public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {
|
||||
if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
|
||||
throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
|
||||
}
|
||||
|
||||
@@ -83,31 +83,38 @@ class StreamOutput extends Output
|
||||
*
|
||||
* Colorization is disabled if not supported by the stream:
|
||||
*
|
||||
* - the stream is redirected (eg php file.php >log)
|
||||
* - Windows without VT100 support, Ansicon, ConEmu, Mintty
|
||||
* - non tty consoles
|
||||
* This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo
|
||||
* terminals via named pipes, so we can only check the environment.
|
||||
*
|
||||
* Reference: Composer\XdebugHandler\Process::supportsColor
|
||||
* https://github.com/composer/xdebug-handler
|
||||
*
|
||||
* @return bool true if the stream supports colorization, false otherwise
|
||||
*/
|
||||
protected function hasColorSupport()
|
||||
{
|
||||
if (function_exists('stream_isatty') && !@stream_isatty($this->stream)) {
|
||||
return false;
|
||||
if ('Hyper' === getenv('TERM_PROGRAM')) {
|
||||
return true;
|
||||
}
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
if (function_exists('sapi_windows_vt100_support')) {
|
||||
$vt100Enabled = @sapi_windows_vt100_support($this->stream);
|
||||
} else {
|
||||
$vt100Enabled = '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
|
||||
}
|
||||
|
||||
return
|
||||
$vt100Enabled
|
||||
if (\DIRECTORY_SEPARATOR === '\\') {
|
||||
return (\function_exists('sapi_windows_vt100_support')
|
||||
&& @sapi_windows_vt100_support($this->stream))
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM');
|
||||
}
|
||||
|
||||
return function_exists('posix_isatty') && @posix_isatty($this->stream);
|
||||
if (\function_exists('stream_isatty')) {
|
||||
return @stream_isatty($this->stream);
|
||||
}
|
||||
|
||||
if (\function_exists('posix_isatty')) {
|
||||
return @posix_isatty($this->stream);
|
||||
}
|
||||
|
||||
$stat = @fstat($this->stream);
|
||||
// Check if formatted mode is S_IFCHR
|
||||
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user