Aggiornato Composer
This commit is contained in:
2
vendor/psy/psysh/src/Output/OutputPager.php
vendored
2
vendor/psy/psysh/src/Output/OutputPager.php
vendored
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -32,9 +32,9 @@ class ProcOutputPager extends StreamOutput implements OutputPager
|
||||
* Constructor.
|
||||
*
|
||||
* @param StreamOutput $output
|
||||
* @param string $cmd Pager process command (default: 'less -R -S -F -X')
|
||||
* @param string $cmd Pager process command (default: 'less -R -F -X')
|
||||
*/
|
||||
public function __construct(StreamOutput $output, string $cmd = 'less -R -S -F -X')
|
||||
public function __construct(StreamOutput $output, string $cmd = 'less -R -F -X')
|
||||
{
|
||||
$this->stream = $output->getStream();
|
||||
$this->cmd = $cmd;
|
||||
@@ -48,12 +48,13 @@ class ProcOutputPager extends StreamOutput implements OutputPager
|
||||
*
|
||||
* @throws \RuntimeException When unable to write output (should never happen)
|
||||
*/
|
||||
public function doWrite($message, $newline)
|
||||
public function doWrite($message, $newline): void
|
||||
{
|
||||
$pipe = $this->getPipe();
|
||||
if (false === @\fwrite($pipe, $message.($newline ? \PHP_EOL : ''))) {
|
||||
// @codeCoverageIgnoreStart
|
||||
// should never happen
|
||||
$this->close();
|
||||
throw new \RuntimeException('Unable to write output');
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
70
vendor/psy/psysh/src/Output/ShellOutput.php
vendored
70
vendor/psy/psysh/src/Output/ShellOutput.php
vendored
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -13,7 +13,6 @@ namespace Psy\Output;
|
||||
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
/**
|
||||
@@ -24,8 +23,13 @@ class ShellOutput extends ConsoleOutput
|
||||
const NUMBER_LINES = 128;
|
||||
|
||||
private $paging = 0;
|
||||
|
||||
/** @var OutputPager */
|
||||
private $pager;
|
||||
|
||||
/** @var Theme */
|
||||
private $theme;
|
||||
|
||||
/**
|
||||
* Construct a ShellOutput instance.
|
||||
*
|
||||
@@ -34,10 +38,11 @@ class ShellOutput extends ConsoleOutput
|
||||
* @param OutputFormatterInterface|null $formatter (default: null)
|
||||
* @param string|OutputPager|null $pager (default: null)
|
||||
*/
|
||||
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null, $pager = null)
|
||||
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, ?OutputFormatterInterface $formatter = null, $pager = null, $theme = null)
|
||||
{
|
||||
parent::__construct($verbosity, $decorated, $formatter);
|
||||
|
||||
$this->theme = $theme ?? new Theme('modern');
|
||||
$this->initFormatters();
|
||||
|
||||
if ($pager === null) {
|
||||
@@ -114,7 +119,7 @@ class ShellOutput extends ConsoleOutput
|
||||
* @param bool $newline Whether to add a newline or not
|
||||
* @param int $type The type of output
|
||||
*/
|
||||
public function write($messages, $newline = false, $type = 0)
|
||||
public function write($messages, $newline = false, $type = 0): void
|
||||
{
|
||||
if ($this->getVerbosity() === self::VERBOSITY_QUIET) {
|
||||
return;
|
||||
@@ -149,7 +154,7 @@ class ShellOutput extends ConsoleOutput
|
||||
* @param string $message A message to write to the output
|
||||
* @param bool $newline Whether to add a newline or not
|
||||
*/
|
||||
public function doWrite($message, $newline)
|
||||
public function doWrite($message, $newline): void
|
||||
{
|
||||
if ($this->paging > 0) {
|
||||
$this->pager->doWrite($message, $newline);
|
||||
@@ -158,6 +163,15 @@ class ShellOutput extends ConsoleOutput
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the output Theme.
|
||||
*/
|
||||
public function setTheme(Theme $theme)
|
||||
{
|
||||
$this->theme = $theme;
|
||||
$this->initFormatters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush and close the output pager.
|
||||
*/
|
||||
@@ -173,38 +187,22 @@ class ShellOutput extends ConsoleOutput
|
||||
*/
|
||||
private function initFormatters()
|
||||
{
|
||||
$formatter = $this->getFormatter();
|
||||
$useGrayFallback = !$this->grayExists();
|
||||
$this->theme->applyStyles($this->getFormatter(), $useGrayFallback);
|
||||
$this->theme->applyErrorStyles($this->getErrorOutput()->getFormatter(), $useGrayFallback);
|
||||
}
|
||||
|
||||
$formatter->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
|
||||
$formatter->setStyle('error', new OutputFormatterStyle('white', 'red', ['bold']));
|
||||
$formatter->setStyle('aside', new OutputFormatterStyle('blue'));
|
||||
$formatter->setStyle('strong', new OutputFormatterStyle(null, null, ['bold']));
|
||||
$formatter->setStyle('return', new OutputFormatterStyle('cyan'));
|
||||
$formatter->setStyle('urgent', new OutputFormatterStyle('red'));
|
||||
$formatter->setStyle('hidden', new OutputFormatterStyle('black'));
|
||||
/**
|
||||
* Checks if the "gray" color exists on the output.
|
||||
*/
|
||||
private function grayExists(): bool
|
||||
{
|
||||
try {
|
||||
$this->write('<fg=gray></>');
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Visibility
|
||||
$formatter->setStyle('public', new OutputFormatterStyle(null, null, ['bold']));
|
||||
$formatter->setStyle('protected', new OutputFormatterStyle('yellow'));
|
||||
$formatter->setStyle('private', new OutputFormatterStyle('red'));
|
||||
$formatter->setStyle('global', new OutputFormatterStyle('cyan', null, ['bold']));
|
||||
$formatter->setStyle('const', new OutputFormatterStyle('cyan'));
|
||||
$formatter->setStyle('class', new OutputFormatterStyle('blue', null, ['underscore']));
|
||||
$formatter->setStyle('function', new OutputFormatterStyle(null));
|
||||
$formatter->setStyle('default', new OutputFormatterStyle(null));
|
||||
|
||||
// Types
|
||||
$formatter->setStyle('number', new OutputFormatterStyle('magenta'));
|
||||
$formatter->setStyle('integer', new OutputFormatterStyle('magenta'));
|
||||
$formatter->setStyle('float', new OutputFormatterStyle('yellow'));
|
||||
$formatter->setStyle('string', new OutputFormatterStyle('green'));
|
||||
$formatter->setStyle('bool', new OutputFormatterStyle('cyan'));
|
||||
$formatter->setStyle('keyword', new OutputFormatterStyle('yellow'));
|
||||
$formatter->setStyle('comment', new OutputFormatterStyle('blue'));
|
||||
$formatter->setStyle('object', new OutputFormatterStyle('blue'));
|
||||
$formatter->setStyle('resource', new OutputFormatterStyle('yellow'));
|
||||
|
||||
// Code-specific formatting
|
||||
$formatter->setStyle('inline_html', new OutputFormatterStyle('cyan'));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user