From ebd914daf43d32ba74c45ce675526478dd18de85 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 30 Dec 2020 11:40:49 +0100 Subject: [PATCH] Add TrimmedBufferOutput.php Signed-off-by: Roeland Jago Douma --- composer/InstalledVersions.php | 4 +- composer/autoload_classmap.php | 1 + composer/autoload_static.php | 1 + composer/installed.json | 2 +- composer/installed.php | 4 +- .../console/Output/TrimmedBufferOutput.php | 67 +++++++++++++++++++ 6 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 symfony/console/Output/TrimmedBufferOutput.php diff --git a/composer/InstalledVersions.php b/composer/InstalledVersions.php index a888736ce..c7e7c7fe5 100644 --- a/composer/InstalledVersions.php +++ b/composer/InstalledVersions.php @@ -29,7 +29,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e', + 'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09', 'name' => 'nextcloud/3rdparty', ), 'versions' => @@ -284,7 +284,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e', + 'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09', ), 'nextcloud/lognormalizer' => array ( diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 5d7216d35..504be639c 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -2579,6 +2579,7 @@ 'Symfony\\Component\\Console\\Output\\Output' => $vendorDir . '/symfony/console/Output/Output.php', 'Symfony\\Component\\Console\\Output\\OutputInterface' => $vendorDir . '/symfony/console/Output/OutputInterface.php', 'Symfony\\Component\\Console\\Output\\StreamOutput' => $vendorDir . '/symfony/console/Output/StreamOutput.php', + 'Symfony\\Component\\Console\\Output\\TrimmedBufferOutput' => $vendorDir . '/symfony/console/Output/TrimmedBufferOutput.php', 'Symfony\\Component\\Console\\Question\\ChoiceQuestion' => $vendorDir . '/symfony/console/Question/ChoiceQuestion.php', 'Symfony\\Component\\Console\\Question\\ConfirmationQuestion' => $vendorDir . '/symfony/console/Question/ConfirmationQuestion.php', 'Symfony\\Component\\Console\\Question\\Question' => $vendorDir . '/symfony/console/Question/Question.php', diff --git a/composer/autoload_static.php b/composer/autoload_static.php index cf2ef37a0..374044b42 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -3081,6 +3081,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Symfony\\Component\\Console\\Output\\Output' => __DIR__ . '/..' . '/symfony/console/Output/Output.php', 'Symfony\\Component\\Console\\Output\\OutputInterface' => __DIR__ . '/..' . '/symfony/console/Output/OutputInterface.php', 'Symfony\\Component\\Console\\Output\\StreamOutput' => __DIR__ . '/..' . '/symfony/console/Output/StreamOutput.php', + 'Symfony\\Component\\Console\\Output\\TrimmedBufferOutput' => __DIR__ . '/..' . '/symfony/console/Output/TrimmedBufferOutput.php', 'Symfony\\Component\\Console\\Question\\ChoiceQuestion' => __DIR__ . '/..' . '/symfony/console/Question/ChoiceQuestion.php', 'Symfony\\Component\\Console\\Question\\ConfirmationQuestion' => __DIR__ . '/..' . '/symfony/console/Question/ConfirmationQuestion.php', 'Symfony\\Component\\Console\\Question\\Question' => __DIR__ . '/..' . '/symfony/console/Question/Question.php', diff --git a/composer/installed.json b/composer/installed.json index 13630e06e..697aac3f0 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -5574,6 +5574,6 @@ "install-path": "../web-auth/webauthn-lib" } ], - "dev": false, + "dev": true, "dev-package-names": [] } diff --git a/composer/installed.php b/composer/installed.php index 550985a09..53573ede9 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -6,7 +6,7 @@ 'aliases' => array ( ), - 'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e', + 'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09', 'name' => 'nextcloud/3rdparty', ), 'versions' => @@ -261,7 +261,7 @@ 'aliases' => array ( ), - 'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e', + 'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09', ), 'nextcloud/lognormalizer' => array ( diff --git a/symfony/console/Output/TrimmedBufferOutput.php b/symfony/console/Output/TrimmedBufferOutput.php new file mode 100644 index 000000000..a03aa835f --- /dev/null +++ b/symfony/console/Output/TrimmedBufferOutput.php @@ -0,0 +1,67 @@ + + * + * 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\Exception\InvalidArgumentException; +use Symfony\Component\Console\Formatter\OutputFormatterInterface; + +/** + * A BufferedOutput that keeps only the last N chars. + * + * @author Jérémy Derussé + */ +class TrimmedBufferOutput extends Output +{ + private $maxLength; + private $buffer = ''; + + public function __construct( + int $maxLength, + ?int $verbosity = self::VERBOSITY_NORMAL, + bool $decorated = false, + OutputFormatterInterface $formatter = null + ) { + if ($maxLength <= 0) { + throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength)); + } + + parent::__construct($verbosity, $decorated, $formatter); + $this->maxLength = $maxLength; + } + + /** + * 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 .= \PHP_EOL; + } + + $this->buffer = substr($this->buffer, 0 - $this->maxLength); + } +}