summaryrefslogtreecommitdiffstats
path: root/vendor/symfony/console/Symfony/Component/Console/Output
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-05-05 19:34:39 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-05-05 19:34:39 +0200
commit705c4cb50eea66585cc95c7314001fce9dd197cd (patch)
tree4a448f4e30b117e12306b643121f49da15e6376b /vendor/symfony/console/Symfony/Component/Console/Output
downloadCatalog-705c4cb50eea66585cc95c7314001fce9dd197cd.tar.gz
Catalog-705c4cb50eea66585cc95c7314001fce9dd197cd.zip
Initial commit
Diffstat (limited to 'vendor/symfony/console/Symfony/Component/Console/Output')
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php48
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php113
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php35
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php113
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/Output.php165
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php113
-rw-r--r--vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php103
7 files changed, 690 insertions, 0 deletions
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php
new file mode 100644
index 0000000..5682fc2
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php
@@ -0,0 +1,48 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+/**
+ * @author Jean-François Simon <contact@jfsimon.fr>
+ */
+class BufferedOutput extends Output
+{
+ /**
+ * @var string
+ */
+ private $buffer = '';
+
+ /**
+ * Empties buffer and returns its content.
+ *
+ * @return string
+ */
+ public function fetch()
+ {
+ $content = $this->buffer;
+ $this->buffer = '';
+
+ return $content;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doWrite($message, $newline)
+ {
+ $this->buffer .= $message;
+
+ if ($newline) {
+ $this->buffer .= "\n";
+ }
+ }
+}
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php
new file mode 100644
index 0000000..3560f1c
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php
@@ -0,0 +1,113 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+
+/**
+ * ConsoleOutput is the default class for all CLI output. It uses STDOUT.
+ *
+ * This class is a convenient wrapper around `StreamOutput`.
+ *
+ * $output = new ConsoleOutput();
+ *
+ * This is equivalent to:
+ *
+ * $output = new StreamOutput(fopen('php://stdout', 'w'));
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
+{
+ private $stderr;
+
+ /**
+ * Constructor.
+ *
+ * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
+ * @param bool|null $decorated Whether to decorate messages (null for auto-guessing)
+ * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
+ *
+ * @api
+ */
+ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
+ {
+ $outputStream = 'php://stdout';
+ if (!$this->hasStdoutSupport()) {
+ $outputStream = 'php://output';
+ }
+
+ parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
+
+ $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $this->getFormatter());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setDecorated($decorated)
+ {
+ parent::setDecorated($decorated);
+ $this->stderr->setDecorated($decorated);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(OutputFormatterInterface $formatter)
+ {
+ parent::setFormatter($formatter);
+ $this->stderr->setFormatter($formatter);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setVerbosity($level)
+ {
+ parent::setVerbosity($level);
+ $this->stderr->setVerbosity($level);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getErrorOutput()
+ {
+ return $this->stderr;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setErrorOutput(OutputInterface $error)
+ {
+ $this->stderr = $error;
+ }
+
+ /**
+ * Returns true if current environment supports writing console output to
+ * STDOUT.
+ *
+ * IBM iSeries (OS400) exhibits character-encoding issues when writing to
+ * STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage
+ * output.
+ *
+ * @return bool
+ */
+ protected function hasStdoutSupport()
+ {
+ return ('OS400' != php_uname('s'));
+ }
+}
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php
new file mode 100644
index 0000000..5eb4fc7
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php
@@ -0,0 +1,35 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+/**
+ * ConsoleOutputInterface is the interface implemented by ConsoleOutput class.
+ * This adds information about stderr output stream.
+ *
+ * @author Dariusz Górecki <darek.krk@gmail.com>
+ */
+interface ConsoleOutputInterface extends OutputInterface
+{
+ /**
+ * Gets the OutputInterface for errors.
+ *
+ * @return OutputInterface
+ */
+ public function getErrorOutput();
+
+ /**
+ * Sets the OutputInterface used for errors.
+ *
+ * @param OutputInterface $error
+ */
+ public function setErrorOutput(OutputInterface $error);
+}
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php
new file mode 100644
index 0000000..557f8af
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php
@@ -0,0 +1,113 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+use Symfony\Component\Console\Formatter\OutputFormatter;
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+
+/**
+ * NullOutput suppresses all output.
+ *
+ * $output = new NullOutput();
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Tobias Schultze <http://tobion.de>
+ *
+ * @api
+ */
+class NullOutput implements OutputInterface
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(OutputFormatterInterface $formatter)
+ {
+ // do nothing
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormatter()
+ {
+ // to comply with the interface we must return a OutputFormatterInterface
+ return new OutputFormatter();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setDecorated($decorated)
+ {
+ // do nothing
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isDecorated()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setVerbosity($level)
+ {
+ // do nothing
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getVerbosity()
+ {
+ return self::VERBOSITY_QUIET;
+ }
+
+ public function isQuiet()
+ {
+ return true;
+ }
+
+ public function isVerbose()
+ {
+ return false;
+ }
+
+ public function isVeryVerbose()
+ {
+ return false;
+ }
+
+ public function isDebug()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function writeln($messages, $type = self::OUTPUT_NORMAL)
+ {
+ // do nothing
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
+ {
+ // do nothing
+ }
+}
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/Output.php b/vendor/symfony/console/Symfony/Component/Console/Output/Output.php
new file mode 100644
index 0000000..cb0e40d
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/Output.php
@@ -0,0 +1,165 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+use Symfony\Component\Console\Formatter\OutputFormatter;
+
+/**
+ * Base class for output classes.
+ *
+ * There are five levels of verbosity:
+ *
+ * * normal: no option passed (normal output)
+ * * verbose: -v (more output)
+ * * very verbose: -vv (highly extended output)
+ * * debug: -vvv (all debug output)
+ * * quiet: -q (no output)
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+abstract class Output implements OutputInterface
+{
+ private $verbosity;
+ private $formatter;
+
+ /**
+ * Constructor.
+ *
+ * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
+ * @param bool $decorated Whether to decorate messages
+ * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
+ *
+ * @api
+ */
+ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
+ {
+ $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
+ $this->formatter = $formatter ?: new OutputFormatter();
+ $this->formatter->setDecorated($decorated);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setFormatter(OutputFormatterInterface $formatter)
+ {
+ $this->formatter = $formatter;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFormatter()
+ {
+ return $this->formatter;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setDecorated($decorated)
+ {
+ $this->formatter->setDecorated($decorated);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isDecorated()
+ {
+ return $this->formatter->isDecorated();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setVerbosity($level)
+ {
+ $this->verbosity = (int) $level;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getVerbosity()
+ {
+ return $this->verbosity;
+ }
+
+ public function isQuiet()
+ {
+ return self::VERBOSITY_QUIET === $this->verbosity;
+ }
+
+ public function isVerbose()
+ {
+ return self::VERBOSITY_VERBOSE <= $this->verbosity;
+ }
+
+ public function isVeryVerbose()
+ {
+ return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
+ }
+
+ public function isDebug()
+ {
+ return self::VERBOSITY_DEBUG <= $this->verbosity;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function writeln($messages, $type = self::OUTPUT_NORMAL)
+ {
+ $this->write($messages, true, $type);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
+ {
+ if (self::VERBOSITY_QUIET === $this->verbosity) {
+ return;
+ }
+
+ $messages = (array) $messages;
+
+ foreach ($messages as $message) {
+ switch ($type) {
+ case OutputInterface::OUTPUT_NORMAL:
+ $message = $this->formatter->format($message);
+ break;
+ case OutputInterface::OUTPUT_RAW:
+ break;
+ case OutputInterface::OUTPUT_PLAIN:
+ $message = strip_tags($this->formatter->format($message));
+ break;
+ default:
+ throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type));
+ }
+
+ $this->doWrite($message, $newline);
+ }
+ }
+
+ /**
+ * Writes a message to the output.
+ *
+ * @param string $message A message to write to the output
+ * @param bool $newline Whether to add a newline or not
+ */
+ abstract protected function doWrite($message, $newline);
+}
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php
new file mode 100644
index 0000000..f7f3063
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php
@@ -0,0 +1,113 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+
+/**
+ * OutputInterface is the interface implemented by all Output classes.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+interface OutputInterface
+{
+ const VERBOSITY_QUIET = 0;
+ const VERBOSITY_NORMAL = 1;
+ const VERBOSITY_VERBOSE = 2;
+ const VERBOSITY_VERY_VERBOSE = 3;
+ const VERBOSITY_DEBUG = 4;
+
+ const OUTPUT_NORMAL = 0;
+ const OUTPUT_RAW = 1;
+ const OUTPUT_PLAIN = 2;
+
+ /**
+ * Writes a message to the output.
+ *
+ * @param string|array $messages The message as an array of lines or a single string
+ * @param bool $newline Whether to add a newline
+ * @param int $type The type of output (one of the OUTPUT constants)
+ *
+ * @throws \InvalidArgumentException When unknown output type is given
+ *
+ * @api
+ */
+ public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL);
+
+ /**
+ * 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 int $type The type of output (one of the OUTPUT constants)
+ *
+ * @throws \InvalidArgumentException When unknown output type is given
+ *
+ * @api
+ */
+ public function writeln($messages, $type = self::OUTPUT_NORMAL);
+
+ /**
+ * Sets the verbosity of the output.
+ *
+ * @param int $level The level of verbosity (one of the VERBOSITY constants)
+ *
+ * @api
+ */
+ public function setVerbosity($level);
+
+ /**
+ * Gets the current verbosity of the output.
+ *
+ * @return int The current level of verbosity (one of the VERBOSITY constants)
+ *
+ * @api
+ */
+ public function getVerbosity();
+
+ /**
+ * Sets the decorated flag.
+ *
+ * @param bool $decorated Whether to decorate the messages
+ *
+ * @api
+ */
+ public function setDecorated($decorated);
+
+ /**
+ * Gets the decorated flag.
+ *
+ * @return bool true if the output will decorate messages, false otherwise
+ *
+ * @api
+ */
+ public function isDecorated();
+
+ /**
+ * Sets output formatter.
+ *
+ * @param OutputFormatterInterface $formatter
+ *
+ * @api
+ */
+ public function setFormatter(OutputFormatterInterface $formatter);
+
+ /**
+ * Returns current output formatter instance.
+ *
+ * @return OutputFormatterInterface
+ *
+ * @api
+ */
+ public function getFormatter();
+}
diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php
new file mode 100644
index 0000000..8de10b4
--- /dev/null
+++ b/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php
@@ -0,0 +1,103 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+
+/**
+ * StreamOutput writes the output to a given stream.
+ *
+ * Usage:
+ *
+ * $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));
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @api
+ */
+class StreamOutput extends Output
+{
+ private $stream;
+
+ /**
+ * Constructor.
+ *
+ * @param mixed $stream A stream resource
+ * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
+ * @param bool|null $decorated Whether to decorate messages (null for auto-guessing)
+ * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
+ *
+ * @throws \InvalidArgumentException When first argument is not a real stream
+ *
+ * @api
+ */
+ public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
+ {
+ if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {
+ throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
+ }
+
+ $this->stream = $stream;
+
+ if (null === $decorated) {
+ $decorated = $this->hasColorSupport();
+ }
+
+ parent::__construct($verbosity, $decorated, $formatter);
+ }
+
+ /**
+ * Gets the stream attached to this StreamOutput instance.
+ *
+ * @return resource A stream resource
+ */
+ public function getStream()
+ {
+ return $this->stream;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doWrite($message, $newline)
+ {
+ if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) {
+ // should never happen
+ throw new \RuntimeException('Unable to write output.');
+ }
+
+ fflush($this->stream);
+ }
+
+ /**
+ * Returns true if the stream supports colorization.
+ *
+ * Colorization is disabled if not supported by the stream:
+ *
+ * - Windows without Ansicon and ConEmu
+ * - non tty consoles
+ *
+ * @return bool true if the stream supports colorization, false otherwise
+ */
+ protected function hasColorSupport()
+ {
+ if (DIRECTORY_SEPARATOR == '\\') {
+ return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
+ }
+
+ return function_exists('posix_isatty') && @posix_isatty($this->stream);
+ }
+}