upgraded dependencies
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-2018 Justin Hileman | ||||
|  * (c) 2012-2022 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-2018 Justin Hileman | ||||
|  * (c) 2012-2022 Justin Hileman | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|   | ||||
							
								
								
									
										14
									
								
								vendor/psy/psysh/src/Output/ProcOutputPager.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								vendor/psy/psysh/src/Output/ProcOutputPager.php
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
| /* | ||||
|  * This file is part of Psy Shell. | ||||
|  * | ||||
|  * (c) 2012-2018 Justin Hileman | ||||
|  * (c) 2012-2022 Justin Hileman | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
| @@ -32,12 +32,12 @@ 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, $cmd = 'less -R -S -F -X') | ||||
|     public function __construct(StreamOutput $output, string $cmd = 'less -R -F -X') | ||||
|     { | ||||
|         $this->stream = $output->getStream(); | ||||
|         $this->cmd    = $cmd; | ||||
|         $this->cmd = $cmd; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -51,9 +51,10 @@ class ProcOutputPager extends StreamOutput implements OutputPager | ||||
|     public function doWrite($message, $newline) | ||||
|     { | ||||
|         $pipe = $this->getPipe(); | ||||
|         if (false === @\fwrite($pipe, $message . ($newline ? PHP_EOL : ''))) { | ||||
|         if (false === @\fwrite($pipe, $message.($newline ? \PHP_EOL : ''))) { | ||||
|             // @codeCoverageIgnoreStart | ||||
|             // should never happen | ||||
|             $this->close(); | ||||
|             throw new \RuntimeException('Unable to write output'); | ||||
|             // @codeCoverageIgnoreEnd | ||||
|         } | ||||
| @@ -77,7 +78,8 @@ class ProcOutputPager extends StreamOutput implements OutputPager | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         unset($this->pipe, $this->proc); | ||||
|         $this->pipe = null; | ||||
|         $this->proc = null; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
							
								
								
									
										78
									
								
								vendor/psy/psysh/src/Output/ShellOutput.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										78
									
								
								vendor/psy/psysh/src/Output/ShellOutput.php
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
| /* | ||||
|  * This file is part of Psy Shell. | ||||
|  * | ||||
|  * (c) 2012-2018 Justin Hileman | ||||
|  * (c) 2012-2022 Justin Hileman | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
| @@ -11,8 +11,8 @@ | ||||
|  | ||||
| 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; | ||||
|  | ||||
| /** | ||||
| @@ -23,20 +23,26 @@ class ShellOutput extends ConsoleOutput | ||||
|     const NUMBER_LINES = 128; | ||||
|  | ||||
|     private $paging = 0; | ||||
|  | ||||
|     /** @var OutputPager */ | ||||
|     private $pager; | ||||
|  | ||||
|     /** @var Theme */ | ||||
|     private $theme; | ||||
|  | ||||
|     /** | ||||
|      * Construct a ShellOutput instance. | ||||
|      * | ||||
|      * @param mixed                    $verbosity (default: self::VERBOSITY_NORMAL) | ||||
|      * @param bool                     $decorated (default: null) | ||||
|      * @param OutputFormatterInterface $formatter (default: null) | ||||
|      * @param null|string|OutputPager  $pager     (default: null) | ||||
|      * @param mixed                         $verbosity (default: self::VERBOSITY_NORMAL) | ||||
|      * @param bool|null                     $decorated (default: null) | ||||
|      * @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) { | ||||
| @@ -46,7 +52,7 @@ class ShellOutput extends ConsoleOutput | ||||
|         } elseif ($pager instanceof OutputPager) { | ||||
|             $this->pager = $pager; | ||||
|         } else { | ||||
|             throw new \InvalidArgumentException('Unexpected pager parameter: ' . $pager); | ||||
|             throw new \InvalidArgumentException('Unexpected pager parameter: '.$pager); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -63,7 +69,7 @@ class ShellOutput extends ConsoleOutput | ||||
|      * @param string|array|\Closure $messages A string, array of strings or a callback | ||||
|      * @param int                   $type     (default: 0) | ||||
|      */ | ||||
|     public function page($messages, $type = 0) | ||||
|     public function page($messages, int $type = 0) | ||||
|     { | ||||
|         if (\is_string($messages)) { | ||||
|             $messages = (array) $messages; | ||||
| @@ -126,7 +132,7 @@ class ShellOutput extends ConsoleOutput | ||||
|             $template = $this->isDecorated() ? "<aside>%{$pad}s</aside>: %s" : "%{$pad}s: %s"; | ||||
|  | ||||
|             if ($type & self::OUTPUT_RAW) { | ||||
|                 $messages = \array_map(['Symfony\Component\Console\Formatter\OutputFormatter', 'escape'], $messages); | ||||
|                 $messages = \array_map([OutputFormatter::class, 'escape'], $messages); | ||||
|             } | ||||
|  | ||||
|             foreach ($messages as $i => $line) { | ||||
| @@ -157,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. | ||||
|      */ | ||||
| @@ -172,33 +187,24 @@ 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('black', '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. | ||||
|      * | ||||
|      * @return bool | ||||
|      */ | ||||
|     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('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')); | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|   | ||||
							
								
								
									
										285
									
								
								vendor/psy/psysh/src/Output/Theme.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										285
									
								
								vendor/psy/psysh/src/Output/Theme.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,285 @@ | ||||
| <?php | ||||
|  | ||||
| /* | ||||
|  * This file is part of Psy Shell. | ||||
|  * | ||||
|  * (c) 2012-2022 Justin Hileman | ||||
|  * | ||||
|  * For the full copyright and license information, please view the LICENSE | ||||
|  * file that was distributed with this source code. | ||||
|  */ | ||||
|  | ||||
| namespace Psy\Output; | ||||
|  | ||||
| use Symfony\Component\Console\Formatter\OutputFormatterInterface; | ||||
| use Symfony\Component\Console\Formatter\OutputFormatterStyle; | ||||
|  | ||||
| /** | ||||
|  * An output Theme, which controls prompt strings, formatter styles, and compact output. | ||||
|  */ | ||||
| class Theme | ||||
| { | ||||
|     const MODERN_THEME = []; // Defaults :) | ||||
|  | ||||
|     const COMPACT_THEME = [ | ||||
|         'compact' => true, | ||||
|     ]; | ||||
|  | ||||
|     const CLASSIC_THEME = [ | ||||
|         'compact' => true, | ||||
|  | ||||
|         'prompt'       => '>>> ', | ||||
|         'bufferPrompt' => '... ', | ||||
|         'replayPrompt' => '--> ', | ||||
|         'returnValue'  => '=>  ', | ||||
|     ]; | ||||
|  | ||||
|     const DEFAULT_STYLES = [ | ||||
|         'info'    => ['white', 'blue', ['bold']], | ||||
|         'warning' => ['black', 'yellow'], | ||||
|         'error'   => ['white', 'red', ['bold']], | ||||
|         'whisper' => ['gray'], | ||||
|  | ||||
|         'aside'  => ['blue'], | ||||
|         'strong' => [null, null, ['bold']], | ||||
|         'return' => ['cyan'], | ||||
|         'urgent' => ['red'], | ||||
|         'hidden' => ['black'], | ||||
|  | ||||
|         // Visibility | ||||
|         'public'    => [null, null, ['bold']], | ||||
|         'protected' => ['yellow'], | ||||
|         'private'   => ['red'], | ||||
|         'global'    => ['cyan', null, ['bold']], | ||||
|         'const'     => ['cyan'], | ||||
|         'class'     => ['blue', null, ['underscore']], | ||||
|         'function'  => [null], | ||||
|         'default'   => [null], | ||||
|  | ||||
|         // Types | ||||
|         'number'   => ['magenta'], | ||||
|         'integer'  => ['magenta'], | ||||
|         'float'    => ['yellow'], | ||||
|         'string'   => ['green'], | ||||
|         'bool'     => ['cyan'], | ||||
|         'keyword'  => ['yellow'], | ||||
|         'comment'  => ['blue'], | ||||
|         'object'   => ['blue'], | ||||
|         'resource' => ['yellow'], | ||||
|  | ||||
|         // Code-specific formatting | ||||
|         'inline_html' => ['cyan'], | ||||
|     ]; | ||||
|  | ||||
|     const ERROR_STYLES = ['info', 'warning', 'error', 'whisper']; | ||||
|  | ||||
|     private $compact = false; | ||||
|  | ||||
|     private $prompt = '> '; | ||||
|     private $bufferPrompt = '. '; | ||||
|     private $replayPrompt = '- '; | ||||
|     private $returnValue = '= '; | ||||
|  | ||||
|     private $grayFallback = 'blue'; | ||||
|  | ||||
|     private $styles = []; | ||||
|  | ||||
|     /** | ||||
|      * @param string|array $config theme name or config options | ||||
|      */ | ||||
|     public function __construct($config = 'modern') | ||||
|     { | ||||
|         if (\is_string($config)) { | ||||
|             switch ($config) { | ||||
|                 case 'modern': | ||||
|                     $config = static::MODERN_THEME; | ||||
|                     break; | ||||
|  | ||||
|                     case 'compact': | ||||
|                     $config = static::COMPACT_THEME; | ||||
|                     break; | ||||
|  | ||||
|                 case 'classic': | ||||
|                     $config = static::CLASSIC_THEME; | ||||
|                     break; | ||||
|  | ||||
|                 default: | ||||
|                     \trigger_error(\sprintf('Unknown theme: %s', $config), \E_USER_NOTICE); | ||||
|                     $config = static::MODERN_THEME; | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!\is_array($config)) { | ||||
|             throw new \InvalidArgumentException('Invalid theme config'); | ||||
|         } | ||||
|  | ||||
|         foreach ($config as $name => $value) { | ||||
|             switch ($name) { | ||||
|                 case 'compact': | ||||
|                     $this->setCompact($value); | ||||
|                     break; | ||||
|  | ||||
|                 case 'prompt': | ||||
|                     $this->setPrompt($value); | ||||
|                     break; | ||||
|  | ||||
|                 case 'bufferPrompt': | ||||
|                     $this->setBufferPrompt($value); | ||||
|                     break; | ||||
|  | ||||
|                 case 'replayPrompt': | ||||
|                     $this->setReplayPrompt($value); | ||||
|                     break; | ||||
|  | ||||
|                 case 'returnValue': | ||||
|                     $this->setReturnValue($value); | ||||
|                     break; | ||||
|  | ||||
|                 case 'grayFallback': | ||||
|                     $this->setGrayFallback($value); | ||||
|                     break; | ||||
|  | ||||
|                 case 'compact': | ||||
|                     $this->setCompact($value); | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $this->setStyles($config['styles'] ?? []); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Enable or disable compact output. | ||||
|      */ | ||||
|     public function setCompact(bool $compact) | ||||
|     { | ||||
|         $this->compact = $compact; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get whether to use compact output. | ||||
|      */ | ||||
|     public function compact(): bool | ||||
|     { | ||||
|         return $this->compact; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set the prompt string. | ||||
|      */ | ||||
|     public function setPrompt(string $prompt) | ||||
|     { | ||||
|         $this->prompt = $prompt; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the prompt string. | ||||
|      */ | ||||
|     public function prompt(): string | ||||
|     { | ||||
|         return $this->prompt; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set the buffer prompt string (used for multi-line input continuation). | ||||
|      */ | ||||
|     public function setBufferPrompt(string $bufferPrompt) | ||||
|     { | ||||
|         $this->bufferPrompt = $bufferPrompt; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the buffer prompt string (used for multi-line input continuation). | ||||
|      */ | ||||
|     public function bufferPrompt(): string | ||||
|     { | ||||
|         return $this->bufferPrompt; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set the prompt string used when replaying history. | ||||
|      */ | ||||
|     public function setReplayPrompt(string $replayPrompt) | ||||
|     { | ||||
|         $this->replayPrompt = $replayPrompt; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the prompt string used when replaying history. | ||||
|      */ | ||||
|     public function replayPrompt(): string | ||||
|     { | ||||
|         return $this->replayPrompt; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set the return value marker. | ||||
|      */ | ||||
|     public function setReturnValue(string $returnValue) | ||||
|     { | ||||
|         $this->returnValue = $returnValue; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the return value marker. | ||||
|      */ | ||||
|     public function returnValue(): string | ||||
|     { | ||||
|         return $this->returnValue; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set the fallback color when "gray" is unavailable. | ||||
|      */ | ||||
|     public function setGrayFallback(string $grayFallback) | ||||
|     { | ||||
|         $this->grayFallback = $grayFallback; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set the shell output formatter styles. | ||||
|      * | ||||
|      * Accepts a map from style name to [fg, bg, options], for example: | ||||
|      * | ||||
|      *     [ | ||||
|      *         'error' => ['white', 'red', ['bold']], | ||||
|      *         'warning' => ['black', 'yellow'], | ||||
|      *     ] | ||||
|      * | ||||
|      * Foreground, background or options can be null, or even omitted entirely. | ||||
|      */ | ||||
|     public function setStyles(array $styles) | ||||
|     { | ||||
|         foreach (\array_keys(static::DEFAULT_STYLES) as $name) { | ||||
|             $this->styles[$name] = $styles[$name] ?? static::DEFAULT_STYLES[$name]; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Apply the current output formatter styles. | ||||
|      */ | ||||
|     public function applyStyles(OutputFormatterInterface $formatter, bool $useGrayFallback) | ||||
|     { | ||||
|         foreach (\array_keys(static::DEFAULT_STYLES) as $name) { | ||||
|             $formatter->setStyle($name, new OutputFormatterStyle(...$this->getStyle($name, $useGrayFallback))); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Apply the current output formatter error styles. | ||||
|      */ | ||||
|     public function applyErrorStyles(OutputFormatterInterface $errorFormatter, bool $useGrayFallback) | ||||
|     { | ||||
|         foreach (static::ERROR_STYLES as $name) { | ||||
|             $errorFormatter->setStyle($name, new OutputFormatterStyle(...$this->getStyle($name, $useGrayFallback))); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function getStyle(string $name, bool $useGrayFallback): array | ||||
|     { | ||||
|         return \array_map(function ($style) use ($useGrayFallback) { | ||||
|             return ($useGrayFallback && $style === 'gray') ? $this->grayFallback : $style; | ||||
|         }, $this->styles[$name]); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 RafficMohammed
					RafficMohammed