Skip to content

Commit

Permalink
Merge pull request #573 from nextcloud/fix/symfony/console
Browse files Browse the repository at this point in the history
Add TrimmedBufferOutput.php
  • Loading branch information
ChristophWurst authored Dec 30, 2020
2 parents 2f1899e + ebd914d commit 1461de7
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
4 changes: 2 additions & 2 deletions composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e',
'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09',
'name' => 'nextcloud/3rdparty',
),
'versions' =>
Expand Down Expand Up @@ -284,7 +284,7 @@ class InstalledVersions
'aliases' =>
array (
),
'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e',
'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09',
),
'nextcloud/lognormalizer' =>
array (
Expand Down
1 change: 1 addition & 0 deletions composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -5574,6 +5574,6 @@
"install-path": "../web-auth/webauthn-lib"
}
],
"dev": false,
"dev": true,
"dev-package-names": []
}
4 changes: 2 additions & 2 deletions composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'aliases' =>
array (
),
'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e',
'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09',
'name' => 'nextcloud/3rdparty',
),
'versions' =>
Expand Down Expand Up @@ -261,7 +261,7 @@
'aliases' =>
array (
),
'reference' => '80cbffbe19083ba1c5a707f8353c1736a14a9c2e',
'reference' => '2f1899e16a86170d69581b4b79bc2c0106552a09',
),
'nextcloud/lognormalizer' =>
array (
Expand Down
67 changes: 67 additions & 0 deletions symfony/console/Output/TrimmedBufferOutput.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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é <[email protected]>
*/
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);
}
}

0 comments on commit 1461de7

Please sign in to comment.