package and depencies
This commit is contained in:
@@ -21,15 +21,13 @@ namespace Symfony\Component\Console\Helper;
|
||||
class DebugFormatterHelper extends Helper
|
||||
{
|
||||
private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
|
||||
private $started = [];
|
||||
private $count = -1;
|
||||
private array $started = [];
|
||||
private int $count = -1;
|
||||
|
||||
/**
|
||||
* Starts a debug formatting session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function start(string $id, string $message, string $prefix = 'RUN')
|
||||
public function start(string $id, string $message, string $prefix = 'RUN'): string
|
||||
{
|
||||
$this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
|
||||
|
||||
@@ -38,10 +36,8 @@ class DebugFormatterHelper extends Helper
|
||||
|
||||
/**
|
||||
* Adds progress to a formatting session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
|
||||
public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR'): string
|
||||
{
|
||||
$message = '';
|
||||
|
||||
@@ -74,10 +70,8 @@ class DebugFormatterHelper extends Helper
|
||||
|
||||
/**
|
||||
* Stops a formatting session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
|
||||
public function stop(string $id, string $message, bool $successful, string $prefix = 'RES'): string
|
||||
{
|
||||
$trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
|
||||
|
||||
@@ -97,10 +91,7 @@ class DebugFormatterHelper extends Helper
|
||||
return sprintf('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'debug_formatter';
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class DescriptorHelper extends Helper
|
||||
/**
|
||||
* @var DescriptorInterface[]
|
||||
*/
|
||||
private $descriptors = [];
|
||||
private array $descriptors = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -70,17 +70,14 @@ class DescriptorHelper extends Helper
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function register(string $format, DescriptorInterface $descriptor)
|
||||
public function register(string $format, DescriptorInterface $descriptor): static
|
||||
{
|
||||
$this->descriptors[$format] = $descriptor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'descriptor';
|
||||
}
|
||||
|
33
vendor/symfony/console/Helper/Dumper.php
vendored
33
vendor/symfony/console/Helper/Dumper.php
vendored
@@ -21,10 +21,10 @@ use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
*/
|
||||
final class Dumper
|
||||
{
|
||||
private $output;
|
||||
private $dumper;
|
||||
private $cloner;
|
||||
private $handler;
|
||||
private OutputInterface $output;
|
||||
private ?CliDumper $dumper;
|
||||
private ?ClonerInterface $cloner;
|
||||
private \Closure $handler;
|
||||
|
||||
public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null)
|
||||
{
|
||||
@@ -34,30 +34,25 @@ final class Dumper
|
||||
|
||||
if (class_exists(CliDumper::class)) {
|
||||
$this->handler = function ($var): string {
|
||||
$dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
|
||||
$dumper = $this->dumper ??= new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
|
||||
$dumper->setColors($this->output->isDecorated());
|
||||
|
||||
return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true));
|
||||
return rtrim($dumper->dump(($this->cloner ??= new VarCloner())->cloneVar($var)->withRefHandles(false), true));
|
||||
};
|
||||
} else {
|
||||
$this->handler = function ($var): string {
|
||||
switch (true) {
|
||||
case null === $var:
|
||||
return 'null';
|
||||
case true === $var:
|
||||
return 'true';
|
||||
case false === $var:
|
||||
return 'false';
|
||||
case \is_string($var):
|
||||
return '"'.$var.'"';
|
||||
default:
|
||||
return rtrim(print_r($var, true));
|
||||
}
|
||||
return match (true) {
|
||||
null === $var => 'null',
|
||||
true === $var => 'true',
|
||||
false === $var => 'false',
|
||||
\is_string($var) => '"'.$var.'"',
|
||||
default => rtrim(print_r($var, true)),
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public function __invoke($var): string
|
||||
public function __invoke(mixed $var): string
|
||||
{
|
||||
return ($this->handler)($var);
|
||||
}
|
||||
|
@@ -22,22 +22,16 @@ class FormatterHelper extends Helper
|
||||
{
|
||||
/**
|
||||
* Formats a message within a section.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatSection(string $section, string $message, string $style = 'info')
|
||||
public function formatSection(string $section, string $message, string $style = 'info'): string
|
||||
{
|
||||
return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a message as a block of text.
|
||||
*
|
||||
* @param string|array $messages The message to write in the block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatBlock($messages, string $style, bool $large = false)
|
||||
public function formatBlock(string|array $messages, string $style, bool $large = false): string
|
||||
{
|
||||
if (!\is_array($messages)) {
|
||||
$messages = [$messages];
|
||||
@@ -68,10 +62,8 @@ class FormatterHelper extends Helper
|
||||
|
||||
/**
|
||||
* Truncates a message to the given length.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function truncate(string $message, int $length, string $suffix = '...')
|
||||
public function truncate(string $message, int $length, string $suffix = '...'): string
|
||||
{
|
||||
$computedLength = $length - self::width($suffix);
|
||||
|
||||
@@ -82,10 +74,7 @@ class FormatterHelper extends Helper
|
||||
return self::substr($message, 0, $length).$suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'formatter';
|
||||
}
|
||||
|
47
vendor/symfony/console/Helper/Helper.php
vendored
47
vendor/symfony/console/Helper/Helper.php
vendored
@@ -23,43 +23,26 @@ abstract class Helper implements HelperInterface
|
||||
{
|
||||
protected $helperSet = null;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setHelperSet(HelperSet $helperSet = null)
|
||||
{
|
||||
if (1 > \func_num_args()) {
|
||||
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
|
||||
}
|
||||
$this->helperSet = $helperSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHelperSet()
|
||||
public function getHelperSet(): ?HelperSet
|
||||
{
|
||||
return $this->helperSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of a string, using mb_strwidth if it is available.
|
||||
*
|
||||
* @deprecated since Symfony 5.3
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function strlen(?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
|
||||
|
||||
return self::width($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of a string, using mb_strwidth if it is available.
|
||||
* The width is how many characters positions the string will use.
|
||||
*/
|
||||
public static function width(?string $string): int
|
||||
{
|
||||
$string ?? $string = '';
|
||||
$string ??= '';
|
||||
|
||||
if (preg_match('//u', $string)) {
|
||||
return (new UnicodeString($string))->width(false);
|
||||
@@ -78,7 +61,7 @@ abstract class Helper implements HelperInterface
|
||||
*/
|
||||
public static function length(?string $string): int
|
||||
{
|
||||
$string ?? $string = '';
|
||||
$string ??= '';
|
||||
|
||||
if (preg_match('//u', $string)) {
|
||||
return (new UnicodeString($string))->length();
|
||||
@@ -93,12 +76,10 @@ abstract class Helper implements HelperInterface
|
||||
|
||||
/**
|
||||
* Returns the subset of a string, using mb_substr if it is available.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function substr(?string $string, int $from, int $length = null)
|
||||
public static function substr(?string $string, int $from, int $length = null): string
|
||||
{
|
||||
$string ?? $string = '';
|
||||
$string ??= '';
|
||||
|
||||
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
||||
return substr($string, $from, $length);
|
||||
@@ -107,7 +88,7 @@ abstract class Helper implements HelperInterface
|
||||
return mb_substr($string, $from, $length, $encoding);
|
||||
}
|
||||
|
||||
public static function formatTime($secs)
|
||||
public static function formatTime(int|float $secs)
|
||||
{
|
||||
static $timeFormats = [
|
||||
[0, '< 1 sec'],
|
||||
@@ -153,16 +134,6 @@ abstract class Helper implements HelperInterface
|
||||
return sprintf('%d B', $memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 5.3
|
||||
*/
|
||||
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
|
||||
|
||||
return self::width(self::removeDecoration($formatter, $string));
|
||||
}
|
||||
|
||||
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
$isDecorated = $formatter->isDecorated();
|
||||
|
@@ -21,14 +21,12 @@ interface HelperInterface
|
||||
/**
|
||||
* Sets the helper set associated with this helper.
|
||||
*/
|
||||
public function setHelperSet(HelperSet $helperSet = null);
|
||||
public function setHelperSet(?HelperSet $helperSet);
|
||||
|
||||
/**
|
||||
* Gets the helper set associated with this helper.
|
||||
*
|
||||
* @return HelperSet|null
|
||||
*/
|
||||
public function getHelperSet();
|
||||
public function getHelperSet(): ?HelperSet;
|
||||
|
||||
/**
|
||||
* Returns the canonical name of this helper.
|
||||
|
48
vendor/symfony/console/Helper/HelperSet.php
vendored
48
vendor/symfony/console/Helper/HelperSet.php
vendored
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@@ -19,16 +18,15 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @implements \IteratorAggregate<string, Helper>
|
||||
* @implements \IteratorAggregate<string, HelperInterface>
|
||||
*/
|
||||
class HelperSet implements \IteratorAggregate
|
||||
{
|
||||
/** @var array<string, Helper> */
|
||||
private $helpers = [];
|
||||
private $command;
|
||||
/** @var array<string, HelperInterface> */
|
||||
private array $helpers = [];
|
||||
|
||||
/**
|
||||
* @param Helper[] $helpers An array of helper
|
||||
* @param HelperInterface[] $helpers
|
||||
*/
|
||||
public function __construct(array $helpers = [])
|
||||
{
|
||||
@@ -49,10 +47,8 @@ class HelperSet implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Returns true if the helper if defined.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has(string $name): bool
|
||||
{
|
||||
return isset($this->helpers[$name]);
|
||||
}
|
||||
@@ -60,11 +56,9 @@ class HelperSet implements \IteratorAggregate
|
||||
/**
|
||||
* Gets a helper value.
|
||||
*
|
||||
* @return HelperInterface
|
||||
*
|
||||
* @throws InvalidArgumentException if the helper is not defined
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get(string $name): HelperInterface
|
||||
{
|
||||
if (!$this->has($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
|
||||
@@ -73,35 +67,7 @@ class HelperSet implements \IteratorAggregate
|
||||
return $this->helpers[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 5.4
|
||||
*/
|
||||
public function setCommand(Command $command = null)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
|
||||
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command associated with this helper set.
|
||||
*
|
||||
* @return Command
|
||||
*
|
||||
* @deprecated since Symfony 5.4
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
|
||||
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable<string, Helper>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
return new \ArrayIterator($this->helpers);
|
||||
}
|
||||
|
@@ -23,9 +23,6 @@ abstract class InputAwareHelper extends Helper implements InputAwareInterface
|
||||
{
|
||||
protected $input;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setInput(InputInterface $input)
|
||||
{
|
||||
$this->input = $input;
|
||||
|
76
vendor/symfony/console/Helper/OutputWrapper.php
vendored
Normal file
76
vendor/symfony/console/Helper/OutputWrapper.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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\Helper;
|
||||
|
||||
/**
|
||||
* Simple output wrapper for "tagged outputs" instead of wordwrap(). This solution is based on a StackOverflow
|
||||
* answer: https://stackoverflow.com/a/20434776/1476819 from user557597 (alias SLN).
|
||||
*
|
||||
* (?:
|
||||
* # -- Words/Characters
|
||||
* ( # (1 start)
|
||||
* (?> # Atomic Group - Match words with valid breaks
|
||||
* .{1,16} # 1-N characters
|
||||
* # Followed by one of 4 prioritized, non-linebreak whitespace
|
||||
* (?: # break types:
|
||||
* (?<= [^\S\r\n] ) # 1. - Behind a non-linebreak whitespace
|
||||
* [^\S\r\n]? # ( optionally accept an extra non-linebreak whitespace )
|
||||
* | (?= \r? \n ) # 2. - Ahead a linebreak
|
||||
* | $ # 3. - EOS
|
||||
* | [^\S\r\n] # 4. - Accept an extra non-linebreak whitespace
|
||||
* )
|
||||
* ) # End atomic group
|
||||
* |
|
||||
* .{1,16} # No valid word breaks, just break on the N'th character
|
||||
* ) # (1 end)
|
||||
* (?: \r? \n )? # Optional linebreak after Words/Characters
|
||||
* |
|
||||
* # -- Or, Linebreak
|
||||
* (?: \r? \n | $ ) # Stand alone linebreak or at EOS
|
||||
* )
|
||||
*
|
||||
* @author Krisztián Ferenczi <ferenczi.krisztian@gmail.com>
|
||||
*
|
||||
* @see https://stackoverflow.com/a/20434776/1476819
|
||||
*/
|
||||
final class OutputWrapper
|
||||
{
|
||||
private const TAG_OPEN_REGEX_SEGMENT = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';
|
||||
private const TAG_CLOSE_REGEX_SEGMENT = '[a-z][^<>]*+';
|
||||
private const URL_PATTERN = 'https?://\S+';
|
||||
|
||||
public function __construct(
|
||||
private bool $allowCutUrls = false
|
||||
) {
|
||||
}
|
||||
|
||||
public function wrap(string $text, int $width, string $break = "\n"): string
|
||||
{
|
||||
if (!$width) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$tagPattern = sprintf('<(?:(?:%s)|/(?:%s)?)>', self::TAG_OPEN_REGEX_SEGMENT, self::TAG_CLOSE_REGEX_SEGMENT);
|
||||
$limitPattern = "{1,$width}";
|
||||
$patternBlocks = [$tagPattern];
|
||||
if (!$this->allowCutUrls) {
|
||||
$patternBlocks[] = self::URL_PATTERN;
|
||||
}
|
||||
$patternBlocks[] = '.';
|
||||
$blocks = implode('|', $patternBlocks);
|
||||
$rowPattern = "(?:$blocks)$limitPattern";
|
||||
$pattern = sprintf('#(?:((?>(%1$s)((?<=[^\S\r\n])[^\S\r\n]?|(?=\r?\n)|$|[^\S\r\n]))|(%1$s))(?:\r?\n)?|(?:\r?\n|$))#imux', $rowPattern);
|
||||
$output = rtrim(preg_replace($pattern, '\\1'.$break, $text), $break);
|
||||
|
||||
return str_replace(' '.$break, $break, $output);
|
||||
}
|
||||
}
|
11
vendor/symfony/console/Helper/ProcessHelper.php
vendored
11
vendor/symfony/console/Helper/ProcessHelper.php
vendored
@@ -32,7 +32,7 @@ class ProcessHelper extends Helper
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
*/
|
||||
public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
|
||||
public function run(OutputInterface $output, array|Process $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
|
||||
{
|
||||
if (!class_exists(Process::class)) {
|
||||
throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
|
||||
@@ -48,10 +48,6 @@ class ProcessHelper extends Helper
|
||||
$cmd = [$cmd];
|
||||
}
|
||||
|
||||
if (!\is_array($cmd)) {
|
||||
throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd)));
|
||||
}
|
||||
|
||||
if (\is_string($cmd[0] ?? null)) {
|
||||
$process = new Process($cmd);
|
||||
$cmd = [];
|
||||
@@ -98,7 +94,7 @@ class ProcessHelper extends Helper
|
||||
*
|
||||
* @see run()
|
||||
*/
|
||||
public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process
|
||||
public function mustRun(OutputInterface $output, array|Process $cmd, string $error = null, callable $callback = null): Process
|
||||
{
|
||||
$process = $this->run($output, $cmd, $error, $callback);
|
||||
|
||||
@@ -134,9 +130,6 @@ class ProcessHelper extends Helper
|
||||
return str_replace('<', '\\<', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'process';
|
||||
|
100
vendor/symfony/console/Helper/ProgressBar.php
vendored
100
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -36,31 +36,32 @@ final class ProgressBar
|
||||
private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
|
||||
private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
|
||||
|
||||
private $barWidth = 28;
|
||||
private $barChar;
|
||||
private $emptyBarChar = '-';
|
||||
private $progressChar = '>';
|
||||
private $format;
|
||||
private $internalFormat;
|
||||
private $redrawFreq = 1;
|
||||
private $writeCount;
|
||||
private $lastWriteTime;
|
||||
private $minSecondsBetweenRedraws = 0;
|
||||
private $maxSecondsBetweenRedraws = 1;
|
||||
private $output;
|
||||
private $step = 0;
|
||||
private $max;
|
||||
private $startTime;
|
||||
private $stepWidth;
|
||||
private $percent = 0.0;
|
||||
private $messages = [];
|
||||
private $overwrite = true;
|
||||
private $terminal;
|
||||
private $previousMessage;
|
||||
private $cursor;
|
||||
private int $barWidth = 28;
|
||||
private string $barChar;
|
||||
private string $emptyBarChar = '-';
|
||||
private string $progressChar = '>';
|
||||
private ?string $format = null;
|
||||
private ?string $internalFormat = null;
|
||||
private ?int $redrawFreq = 1;
|
||||
private int $writeCount = 0;
|
||||
private float $lastWriteTime = 0;
|
||||
private float $minSecondsBetweenRedraws = 0;
|
||||
private float $maxSecondsBetweenRedraws = 1;
|
||||
private OutputInterface $output;
|
||||
private int $step = 0;
|
||||
private int $startingStep = 0;
|
||||
private ?int $max = null;
|
||||
private int $startTime;
|
||||
private int $stepWidth;
|
||||
private float $percent = 0.0;
|
||||
private array $messages = [];
|
||||
private bool $overwrite = true;
|
||||
private Terminal $terminal;
|
||||
private ?string $previousMessage = null;
|
||||
private Cursor $cursor;
|
||||
|
||||
private static $formatters;
|
||||
private static $formats;
|
||||
private static array $formatters;
|
||||
private static array $formats;
|
||||
|
||||
/**
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
@@ -102,9 +103,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
self::$formatters[$name] = $callable;
|
||||
}
|
||||
@@ -116,9 +115,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function getPlaceholderFormatterDefinition(string $name): ?callable
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
return self::$formatters[$name] ?? null;
|
||||
}
|
||||
@@ -133,9 +130,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function setFormatDefinition(string $name, string $format): void
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
}
|
||||
self::$formats ??= self::initFormats();
|
||||
|
||||
self::$formats[$name] = $format;
|
||||
}
|
||||
@@ -147,9 +142,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function getFormatDefinition(string $name): ?string
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
}
|
||||
self::$formats ??= self::initFormats();
|
||||
|
||||
return self::$formats[$name] ?? null;
|
||||
}
|
||||
@@ -206,11 +199,11 @@ final class ProgressBar
|
||||
|
||||
public function getEstimated(): float
|
||||
{
|
||||
if (!$this->step) {
|
||||
if (0 === $this->step || $this->step === $this->startingStep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return round((time() - $this->startTime) / $this->step * $this->max);
|
||||
return round((time() - $this->startTime) / ($this->step - $this->startingStep) * $this->max);
|
||||
}
|
||||
|
||||
public function getRemaining(): float
|
||||
@@ -219,7 +212,7 @@ final class ProgressBar
|
||||
return 0;
|
||||
}
|
||||
|
||||
return round((time() - $this->startTime) / $this->step * ($this->max - $this->step));
|
||||
return round((time() - $this->startTime) / ($this->step - $this->startingStep) * ($this->max - $this->step));
|
||||
}
|
||||
|
||||
public function setBarWidth(int $size)
|
||||
@@ -309,13 +302,16 @@ final class ProgressBar
|
||||
/**
|
||||
* Starts the progress output.
|
||||
*
|
||||
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
|
||||
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
|
||||
* @param int $startAt The starting point of the bar (useful e.g. when resuming a previously started bar)
|
||||
*/
|
||||
public function start(int $max = null)
|
||||
public function start(int $max = null, int $startAt = 0): void
|
||||
{
|
||||
$this->startTime = time();
|
||||
$this->step = 0;
|
||||
$this->percent = 0.0;
|
||||
$this->step = $startAt;
|
||||
$this->startingStep = $startAt;
|
||||
|
||||
$startAt > 0 ? $this->setProgress($startAt) : $this->percent = 0.0;
|
||||
|
||||
if (null !== $max) {
|
||||
$this->setMaxSteps($max);
|
||||
@@ -495,17 +491,13 @@ final class ProgressBar
|
||||
|
||||
private function determineBestFormat(): string
|
||||
{
|
||||
switch ($this->output->getVerbosity()) {
|
||||
return match ($this->output->getVerbosity()) {
|
||||
// OutputInterface::VERBOSITY_QUIET: display is disabled anyway
|
||||
case OutputInterface::VERBOSITY_VERBOSE:
|
||||
return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX;
|
||||
case OutputInterface::VERBOSITY_VERY_VERBOSE:
|
||||
return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX;
|
||||
case OutputInterface::VERBOSITY_DEBUG:
|
||||
return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX;
|
||||
default:
|
||||
return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX;
|
||||
}
|
||||
OutputInterface::VERBOSITY_VERBOSE => $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX,
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE => $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX,
|
||||
OutputInterface::VERBOSITY_DEBUG => $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX,
|
||||
default => $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX,
|
||||
};
|
||||
}
|
||||
|
||||
private static function initPlaceholderFormatters(): array
|
||||
@@ -572,6 +564,8 @@ final class ProgressBar
|
||||
|
||||
private function buildLine(): string
|
||||
{
|
||||
\assert(null !== $this->format);
|
||||
|
||||
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
|
||||
$callback = function ($matches) {
|
||||
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
|
@@ -31,20 +31,20 @@ class ProgressIndicator
|
||||
'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
|
||||
];
|
||||
|
||||
private $output;
|
||||
private $startTime;
|
||||
private $format;
|
||||
private $message;
|
||||
private $indicatorValues;
|
||||
private $indicatorCurrent;
|
||||
private $indicatorChangeInterval;
|
||||
private $indicatorUpdateTime;
|
||||
private $started = false;
|
||||
private OutputInterface $output;
|
||||
private int $startTime;
|
||||
private ?string $format = null;
|
||||
private ?string $message = null;
|
||||
private array $indicatorValues;
|
||||
private int $indicatorCurrent;
|
||||
private int $indicatorChangeInterval;
|
||||
private float $indicatorUpdateTime;
|
||||
private bool $started = false;
|
||||
|
||||
/**
|
||||
* @var array<string, callable>
|
||||
*/
|
||||
private static $formatters;
|
||||
private static array $formatters;
|
||||
|
||||
/**
|
||||
* @param int $indicatorChangeInterval Change interval in milliseconds
|
||||
@@ -54,14 +54,8 @@ class ProgressIndicator
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
if (null === $format) {
|
||||
$format = $this->determineBestFormat();
|
||||
}
|
||||
|
||||
if (null === $indicatorValues) {
|
||||
$indicatorValues = ['-', '\\', '|', '/'];
|
||||
}
|
||||
|
||||
$format ??= $this->determineBestFormat();
|
||||
$indicatorValues ??= ['-', '\\', '|', '/'];
|
||||
$indicatorValues = array_values($indicatorValues);
|
||||
|
||||
if (2 > \count($indicatorValues)) {
|
||||
@@ -146,10 +140,8 @@ class ProgressIndicator
|
||||
|
||||
/**
|
||||
* Gets the format for a given name.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getFormatDefinition(string $name)
|
||||
public static function getFormatDefinition(string $name): ?string
|
||||
{
|
||||
return self::FORMATS[$name] ?? null;
|
||||
}
|
||||
@@ -161,23 +153,17 @@ class ProgressIndicator
|
||||
*/
|
||||
public static function setPlaceholderFormatterDefinition(string $name, callable $callable)
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
self::$formatters[$name] = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholder formatter for a given name (including the delimiter char like %).
|
||||
*
|
||||
* @return callable|null
|
||||
*/
|
||||
public static function getPlaceholderFormatterDefinition(string $name)
|
||||
public static function getPlaceholderFormatterDefinition(string $name): ?callable
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
return self::$formatters[$name] ?? null;
|
||||
}
|
||||
@@ -199,16 +185,13 @@ class ProgressIndicator
|
||||
|
||||
private function determineBestFormat(): string
|
||||
{
|
||||
switch ($this->output->getVerbosity()) {
|
||||
return match ($this->output->getVerbosity()) {
|
||||
// OutputInterface::VERBOSITY_QUIET: display is disabled anyway
|
||||
case OutputInterface::VERBOSITY_VERBOSE:
|
||||
return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
|
||||
case OutputInterface::VERBOSITY_VERY_VERBOSE:
|
||||
case OutputInterface::VERBOSITY_DEBUG:
|
||||
return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
|
||||
default:
|
||||
return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
|
||||
}
|
||||
OutputInterface::VERBOSITY_VERBOSE => $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi',
|
||||
OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
OutputInterface::VERBOSITY_DEBUG => $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi',
|
||||
default => $this->output->isDecorated() ? 'normal' : 'normal_no_ansi',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,6 +212,9 @@ class ProgressIndicator
|
||||
return round(microtime(true) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, \Closure>
|
||||
*/
|
||||
private static function initPlaceholderFormatters(): array
|
||||
{
|
||||
return [
|
||||
|
51
vendor/symfony/console/Helper/QuestionHelper.php
vendored
51
vendor/symfony/console/Helper/QuestionHelper.php
vendored
@@ -39,8 +39,8 @@ class QuestionHelper extends Helper
|
||||
*/
|
||||
private $inputStream;
|
||||
|
||||
private static $stty = true;
|
||||
private static $stdinIsInteractive;
|
||||
private static bool $stty = true;
|
||||
private static bool $stdinIsInteractive;
|
||||
|
||||
/**
|
||||
* Asks a question to the user.
|
||||
@@ -49,7 +49,7 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @throws RuntimeException If there is no data to read in the input stream
|
||||
*/
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question)
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question): mixed
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
@@ -84,10 +84,7 @@ class QuestionHelper extends Helper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'question';
|
||||
}
|
||||
@@ -103,11 +100,9 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Asks the question to the user.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
|
||||
*/
|
||||
private function doAsk(OutputInterface $output, Question $question)
|
||||
private function doAsk(OutputInterface $output, Question $question): mixed
|
||||
{
|
||||
$this->writePrompt($output, $question);
|
||||
|
||||
@@ -142,6 +137,7 @@ class QuestionHelper extends Helper
|
||||
}
|
||||
|
||||
if ($output instanceof ConsoleSectionOutput) {
|
||||
$output->addContent(''); // add EOL to the question
|
||||
$output->addContent($ret);
|
||||
}
|
||||
|
||||
@@ -154,10 +150,7 @@ class QuestionHelper extends Helper
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function getDefaultAnswer(Question $question)
|
||||
private function getDefaultAnswer(Question $question): mixed
|
||||
{
|
||||
$default = $question->getDefault();
|
||||
|
||||
@@ -205,7 +198,7 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag)
|
||||
protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag): array
|
||||
{
|
||||
$messages = [];
|
||||
|
||||
@@ -411,7 +404,7 @@ class QuestionHelper extends Helper
|
||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||
|
||||
// handle code running from a phar
|
||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||
if (str_starts_with(__FILE__, 'phar:')) {
|
||||
$tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
|
||||
copy($exe, $tmpExe);
|
||||
$exe = $tmpExe;
|
||||
@@ -437,6 +430,11 @@ class QuestionHelper extends Helper
|
||||
|
||||
$value = fgets($inputStream, 4096);
|
||||
|
||||
if (4095 === \strlen($value)) {
|
||||
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
|
||||
$errOutput->warning('The value was possibly truncated by your shell or terminal emulator');
|
||||
}
|
||||
|
||||
if (self::$stty && Terminal::hasSttyAvailable()) {
|
||||
shell_exec('stty '.$sttyMode);
|
||||
}
|
||||
@@ -457,11 +455,9 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @param callable $interviewer A callable that will ask for a question and return the result
|
||||
*
|
||||
* @return mixed The validated response
|
||||
*
|
||||
* @throws \Exception In case the max number of attempts has been reached and no valid response has been given
|
||||
*/
|
||||
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question)
|
||||
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question): mixed
|
||||
{
|
||||
$error = null;
|
||||
$attempts = $question->getMaxAttempts();
|
||||
@@ -488,7 +484,7 @@ class QuestionHelper extends Helper
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== self::$stdinIsInteractive) {
|
||||
if (isset(self::$stdinIsInteractive)) {
|
||||
return self::$stdinIsInteractive;
|
||||
}
|
||||
|
||||
@@ -514,10 +510,8 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @param resource $inputStream The handler resource
|
||||
* @param Question $question The question being asked
|
||||
*
|
||||
* @return string|false The input received, false in case input could not be read
|
||||
*/
|
||||
private function readInput($inputStream, Question $question)
|
||||
private function readInput($inputStream, Question $question): string|false
|
||||
{
|
||||
if (!$question->isMultiline()) {
|
||||
$cp = $this->setIOCodepage();
|
||||
@@ -543,11 +537,6 @@ class QuestionHelper extends Helper
|
||||
return $this->resetIOCodepage($cp, $ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets console I/O to the host code page.
|
||||
*
|
||||
* @return int Previous code page in IBM/EBCDIC format
|
||||
*/
|
||||
private function setIOCodepage(): int
|
||||
{
|
||||
if (\function_exists('sapi_windows_cp_set')) {
|
||||
@@ -562,12 +551,8 @@ class QuestionHelper extends Helper
|
||||
|
||||
/**
|
||||
* Sets console I/O to the specified code page and converts the user input.
|
||||
*
|
||||
* @param string|false $input
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private function resetIOCodepage(int $cp, $input)
|
||||
private function resetIOCodepage(int $cp, string|false $input): string|false
|
||||
{
|
||||
if (0 !== $cp) {
|
||||
sapi_windows_cp_set($cp);
|
||||
|
@@ -25,9 +25,6 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
*/
|
||||
class SymfonyQuestionHelper extends QuestionHelper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function writePrompt(OutputInterface $output, Question $question)
|
||||
{
|
||||
$text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
|
||||
@@ -83,9 +80,6 @@ class SymfonyQuestionHelper extends QuestionHelper
|
||||
$output->write($prompt);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function writeError(OutputInterface $output, \Exception $error)
|
||||
{
|
||||
if ($output instanceof SymfonyStyle) {
|
||||
|
233
vendor/symfony/console/Helper/Table.php
vendored
233
vendor/symfony/console/Helper/Table.php
vendored
@@ -35,70 +35,31 @@ class Table
|
||||
private const SEPARATOR_BOTTOM = 3;
|
||||
private const BORDER_OUTSIDE = 0;
|
||||
private const BORDER_INSIDE = 1;
|
||||
private const DISPLAY_ORIENTATION_DEFAULT = 'default';
|
||||
private const DISPLAY_ORIENTATION_HORIZONTAL = 'horizontal';
|
||||
private const DISPLAY_ORIENTATION_VERTICAL = 'vertical';
|
||||
|
||||
private $headerTitle;
|
||||
private $footerTitle;
|
||||
private ?string $headerTitle = null;
|
||||
private ?string $footerTitle = null;
|
||||
private array $headers = [];
|
||||
private array $rows = [];
|
||||
private array $effectiveColumnWidths = [];
|
||||
private int $numberOfColumns;
|
||||
private OutputInterface $output;
|
||||
private TableStyle $style;
|
||||
private array $columnStyles = [];
|
||||
private array $columnWidths = [];
|
||||
private array $columnMaxWidths = [];
|
||||
private bool $rendered = false;
|
||||
private string $displayOrientation = self::DISPLAY_ORIENTATION_DEFAULT;
|
||||
|
||||
/**
|
||||
* Table headers.
|
||||
*/
|
||||
private $headers = [];
|
||||
|
||||
/**
|
||||
* Table rows.
|
||||
*/
|
||||
private $rows = [];
|
||||
private $horizontal = false;
|
||||
|
||||
/**
|
||||
* Column widths cache.
|
||||
*/
|
||||
private $effectiveColumnWidths = [];
|
||||
|
||||
/**
|
||||
* Number of columns cache.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $numberOfColumns;
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* @var TableStyle
|
||||
*/
|
||||
private $style;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $columnStyles = [];
|
||||
|
||||
/**
|
||||
* User set column widths.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $columnWidths = [];
|
||||
private $columnMaxWidths = [];
|
||||
|
||||
/**
|
||||
* @var array<string, TableStyle>|null
|
||||
*/
|
||||
private static $styles;
|
||||
|
||||
private $rendered = false;
|
||||
private static array $styles;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
if (!self::$styles) {
|
||||
self::$styles = self::initStyles();
|
||||
}
|
||||
self::$styles ??= self::initStyles();
|
||||
|
||||
$this->setStyle('default');
|
||||
}
|
||||
@@ -108,39 +69,27 @@ class Table
|
||||
*/
|
||||
public static function setStyleDefinition(string $name, TableStyle $style)
|
||||
{
|
||||
if (!self::$styles) {
|
||||
self::$styles = self::initStyles();
|
||||
}
|
||||
self::$styles ??= self::initStyles();
|
||||
|
||||
self::$styles[$name] = $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a style definition by name.
|
||||
*
|
||||
* @return TableStyle
|
||||
*/
|
||||
public static function getStyleDefinition(string $name)
|
||||
public static function getStyleDefinition(string $name): TableStyle
|
||||
{
|
||||
if (!self::$styles) {
|
||||
self::$styles = self::initStyles();
|
||||
}
|
||||
self::$styles ??= self::initStyles();
|
||||
|
||||
if (isset(self::$styles[$name])) {
|
||||
return self::$styles[$name];
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
return self::$styles[$name] ?? throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets table style.
|
||||
*
|
||||
* @param TableStyle|string $name The style name or a TableStyle instance
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStyle($name)
|
||||
public function setStyle(TableStyle|string $name): static
|
||||
{
|
||||
$this->style = $this->resolveStyle($name);
|
||||
|
||||
@@ -149,10 +98,8 @@ class Table
|
||||
|
||||
/**
|
||||
* Gets the current table style.
|
||||
*
|
||||
* @return TableStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
public function getStyle(): TableStyle
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
@@ -164,7 +111,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnStyle(int $columnIndex, $name)
|
||||
public function setColumnStyle(int $columnIndex, TableStyle|string $name): static
|
||||
{
|
||||
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
|
||||
|
||||
@@ -175,10 +122,8 @@ class Table
|
||||
* Gets the current style for a column.
|
||||
*
|
||||
* If style was not set, it returns the global table style.
|
||||
*
|
||||
* @return TableStyle
|
||||
*/
|
||||
public function getColumnStyle(int $columnIndex)
|
||||
public function getColumnStyle(int $columnIndex): TableStyle
|
||||
{
|
||||
return $this->columnStyles[$columnIndex] ?? $this->getStyle();
|
||||
}
|
||||
@@ -188,7 +133,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidth(int $columnIndex, int $width)
|
||||
public function setColumnWidth(int $columnIndex, int $width): static
|
||||
{
|
||||
$this->columnWidths[$columnIndex] = $width;
|
||||
|
||||
@@ -200,7 +145,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidths(array $widths)
|
||||
public function setColumnWidths(array $widths): static
|
||||
{
|
||||
$this->columnWidths = [];
|
||||
foreach ($widths as $index => $width) {
|
||||
@@ -218,7 +163,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnMaxWidth(int $columnIndex, int $width): self
|
||||
public function setColumnMaxWidth(int $columnIndex, int $width): static
|
||||
{
|
||||
if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
|
||||
throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, get_debug_type($this->output->getFormatter())));
|
||||
@@ -232,10 +177,10 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaders(array $headers)
|
||||
public function setHeaders(array $headers): static
|
||||
{
|
||||
$headers = array_values($headers);
|
||||
if (!empty($headers) && !\is_array($headers[0])) {
|
||||
if ($headers && !\is_array($headers[0])) {
|
||||
$headers = [$headers];
|
||||
}
|
||||
|
||||
@@ -244,6 +189,9 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setRows(array $rows)
|
||||
{
|
||||
$this->rows = [];
|
||||
@@ -254,7 +202,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addRows(array $rows)
|
||||
public function addRows(array $rows): static
|
||||
{
|
||||
foreach ($rows as $row) {
|
||||
$this->addRow($row);
|
||||
@@ -266,7 +214,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addRow($row)
|
||||
public function addRow(TableSeparator|array $row): static
|
||||
{
|
||||
if ($row instanceof TableSeparator) {
|
||||
$this->rows[] = $row;
|
||||
@@ -274,10 +222,6 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!\is_array($row)) {
|
||||
throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
|
||||
}
|
||||
|
||||
$this->rows[] = array_values($row);
|
||||
|
||||
return $this;
|
||||
@@ -288,7 +232,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function appendRow($row): self
|
||||
public function appendRow(TableSeparator|array $row): static
|
||||
{
|
||||
if (!$this->output instanceof ConsoleSectionOutput) {
|
||||
throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
|
||||
@@ -307,7 +251,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setRow($column, array $row)
|
||||
public function setRow(int|string $column, array $row): static
|
||||
{
|
||||
$this->rows[$column] = $row;
|
||||
|
||||
@@ -317,7 +261,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaderTitle(?string $title): self
|
||||
public function setHeaderTitle(?string $title): static
|
||||
{
|
||||
$this->headerTitle = $title;
|
||||
|
||||
@@ -327,7 +271,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFooterTitle(?string $title): self
|
||||
public function setFooterTitle(?string $title): static
|
||||
{
|
||||
$this->footerTitle = $title;
|
||||
|
||||
@@ -337,9 +281,19 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHorizontal(bool $horizontal = true): self
|
||||
public function setHorizontal(bool $horizontal = true): static
|
||||
{
|
||||
$this->horizontal = $horizontal;
|
||||
$this->displayOrientation = $horizontal ? self::DISPLAY_ORIENTATION_HORIZONTAL : self::DISPLAY_ORIENTATION_DEFAULT;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setVertical(bool $vertical = true): static
|
||||
{
|
||||
$this->displayOrientation = $vertical ? self::DISPLAY_ORIENTATION_VERTICAL : self::DISPLAY_ORIENTATION_DEFAULT;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -360,8 +314,13 @@ class Table
|
||||
public function render()
|
||||
{
|
||||
$divider = new TableSeparator();
|
||||
if ($this->horizontal) {
|
||||
$rows = [];
|
||||
$isCellWithColspan = static fn ($cell) => $cell instanceof TableCell && $cell->getColspan() >= 2;
|
||||
|
||||
$horizontal = self::DISPLAY_ORIENTATION_HORIZONTAL === $this->displayOrientation;
|
||||
$vertical = self::DISPLAY_ORIENTATION_VERTICAL === $this->displayOrientation;
|
||||
|
||||
$rows = [];
|
||||
if ($horizontal) {
|
||||
foreach ($this->headers[0] ?? [] as $i => $header) {
|
||||
$rows[$i] = [$header];
|
||||
foreach ($this->rows as $row) {
|
||||
@@ -370,13 +329,48 @@ class Table
|
||||
}
|
||||
if (isset($row[$i])) {
|
||||
$rows[$i][] = $row[$i];
|
||||
} elseif ($rows[$i][0] instanceof TableCell && $rows[$i][0]->getColspan() >= 2) {
|
||||
} elseif ($isCellWithColspan($rows[$i][0])) {
|
||||
// Noop, there is a "title"
|
||||
} else {
|
||||
$rows[$i][] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($vertical) {
|
||||
$formatter = $this->output->getFormatter();
|
||||
$maxHeaderLength = array_reduce($this->headers[0] ?? [], static fn ($max, $header) => max($max, Helper::width(Helper::removeDecoration($formatter, $header))), 0);
|
||||
|
||||
foreach ($this->rows as $row) {
|
||||
if ($row instanceof TableSeparator) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($rows) {
|
||||
$rows[] = [$divider];
|
||||
}
|
||||
|
||||
$containsColspan = false;
|
||||
foreach ($row as $cell) {
|
||||
if ($containsColspan = $isCellWithColspan($cell)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$headers = $this->headers[0] ?? [];
|
||||
$maxRows = max(\count($headers), \count($row));
|
||||
for ($i = 0; $i < $maxRows; ++$i) {
|
||||
$cell = (string) ($row[$i] ?? '');
|
||||
if ($headers && !$containsColspan) {
|
||||
$rows[] = [sprintf(
|
||||
'<comment>%s</>: %s',
|
||||
str_pad($headers[$i] ?? '', $maxHeaderLength, ' ', \STR_PAD_LEFT),
|
||||
$cell
|
||||
)];
|
||||
} elseif ('' !== $cell) {
|
||||
$rows[] = [$cell];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rows = array_merge($this->headers, [$divider], $this->rows);
|
||||
}
|
||||
@@ -386,8 +380,8 @@ class Table
|
||||
$rowGroups = $this->buildTableRows($rows);
|
||||
$this->calculateColumnsWidth($rowGroups);
|
||||
|
||||
$isHeader = !$this->horizontal;
|
||||
$isFirstRow = $this->horizontal;
|
||||
$isHeader = !$horizontal;
|
||||
$isFirstRow = $horizontal;
|
||||
$hasTitle = (bool) $this->headerTitle;
|
||||
|
||||
foreach ($rowGroups as $rowGroup) {
|
||||
@@ -431,7 +425,12 @@ class Table
|
||||
$hasTitle = false;
|
||||
}
|
||||
|
||||
if ($this->horizontal) {
|
||||
if ($vertical) {
|
||||
$isHeader = false;
|
||||
$isFirstRow = false;
|
||||
}
|
||||
|
||||
if ($horizontal) {
|
||||
$this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());
|
||||
} else {
|
||||
$this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
|
||||
@@ -453,7 +452,7 @@ class Table
|
||||
*/
|
||||
private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $title = null, string $titleFormat = null)
|
||||
{
|
||||
if (0 === $count = $this->numberOfColumns) {
|
||||
if (!$count = $this->numberOfColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -570,11 +569,11 @@ class Table
|
||||
$cellFormat = '<'.$tag.'>%s</>';
|
||||
}
|
||||
|
||||
if (strstr($content, '</>')) {
|
||||
if (str_contains($content, '</>')) {
|
||||
$content = str_replace('</>', '', $content);
|
||||
$width -= 3;
|
||||
}
|
||||
if (strstr($content, '<fg=default;bg=default>')) {
|
||||
if (str_contains($content, '<fg=default;bg=default>')) {
|
||||
$content = str_replace('<fg=default;bg=default>', '', $content);
|
||||
$width -= \strlen('<fg=default;bg=default>');
|
||||
}
|
||||
@@ -618,10 +617,10 @@ class Table
|
||||
if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
|
||||
$cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
|
||||
}
|
||||
if (!strstr($cell ?? '', "\n")) {
|
||||
if (!str_contains($cell ?? '', "\n")) {
|
||||
continue;
|
||||
}
|
||||
$escaped = implode("\n", array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode("\n", $cell)));
|
||||
$escaped = implode("\n", array_map(OutputFormatter::escapeTrailingBackslash(...), explode("\n", $cell)));
|
||||
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
|
||||
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $cell));
|
||||
foreach ($lines as $lineKey => $line) {
|
||||
@@ -662,7 +661,7 @@ class Table
|
||||
++$numberOfRows; // Add row for header separator
|
||||
}
|
||||
|
||||
if (\count($this->rows) > 0) {
|
||||
if ($this->rows) {
|
||||
++$numberOfRows; // Add row for footer separator
|
||||
}
|
||||
|
||||
@@ -678,13 +677,13 @@ class Table
|
||||
{
|
||||
$unmergedRows = [];
|
||||
foreach ($rows[$line] as $column => $cell) {
|
||||
if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) {
|
||||
if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) {
|
||||
throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
|
||||
}
|
||||
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
|
||||
$nbLines = $cell->getRowspan() - 1;
|
||||
$lines = [$cell];
|
||||
if (strstr($cell, "\n")) {
|
||||
if (str_contains($cell, "\n")) {
|
||||
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
|
||||
$nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
|
||||
|
||||
@@ -847,7 +846,7 @@ class Table
|
||||
private function cleanup()
|
||||
{
|
||||
$this->effectiveColumnWidths = [];
|
||||
$this->numberOfColumns = null;
|
||||
unset($this->numberOfColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -900,16 +899,12 @@ class Table
|
||||
];
|
||||
}
|
||||
|
||||
private function resolveStyle($name): TableStyle
|
||||
private function resolveStyle(TableStyle|string $name): TableStyle
|
||||
{
|
||||
if ($name instanceof TableStyle) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (isset(self::$styles[$name])) {
|
||||
return self::$styles[$name];
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
return self::$styles[$name] ?? throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
}
|
||||
}
|
||||
|
16
vendor/symfony/console/Helper/TableCell.php
vendored
16
vendor/symfony/console/Helper/TableCell.php
vendored
@@ -18,8 +18,8 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class TableCell
|
||||
{
|
||||
private $value;
|
||||
private $options = [
|
||||
private string $value;
|
||||
private array $options = [
|
||||
'rowspan' => 1,
|
||||
'colspan' => 1,
|
||||
'style' => null,
|
||||
@@ -43,30 +43,24 @@ class TableCell
|
||||
|
||||
/**
|
||||
* Returns the cell value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of colspan.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColspan()
|
||||
public function getColspan(): int
|
||||
{
|
||||
return (int) $this->options['colspan'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of rowspan.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRowspan()
|
||||
public function getRowspan(): int
|
||||
{
|
||||
return (int) $this->options['rowspan'];
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ class TableCellStyle
|
||||
'right' => \STR_PAD_LEFT,
|
||||
];
|
||||
|
||||
private $options = [
|
||||
private array $options = [
|
||||
'fg' => 'default',
|
||||
'bg' => 'default',
|
||||
'options' => null,
|
||||
@@ -63,7 +63,7 @@ class TableCellStyle
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getTagOptions()
|
||||
public function getTagOptions(): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->getOptions(),
|
||||
@@ -74,10 +74,7 @@ class TableCellStyle
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPadByAlign()
|
||||
public function getPadByAlign(): int
|
||||
{
|
||||
return self::ALIGN_MAP[$this->getOptions()['align']];
|
||||
}
|
||||
|
2
vendor/symfony/console/Helper/TableRows.php
vendored
2
vendor/symfony/console/Helper/TableRows.php
vendored
@@ -16,7 +16,7 @@ namespace Symfony\Component\Console\Helper;
|
||||
*/
|
||||
class TableRows implements \IteratorAggregate
|
||||
{
|
||||
private $generator;
|
||||
private \Closure $generator;
|
||||
|
||||
public function __construct(\Closure $generator)
|
||||
{
|
||||
|
98
vendor/symfony/console/Helper/TableStyle.php
vendored
98
vendor/symfony/console/Helper/TableStyle.php
vendored
@@ -23,37 +23,37 @@ use Symfony\Component\Console\Exception\LogicException;
|
||||
*/
|
||||
class TableStyle
|
||||
{
|
||||
private $paddingChar = ' ';
|
||||
private $horizontalOutsideBorderChar = '-';
|
||||
private $horizontalInsideBorderChar = '-';
|
||||
private $verticalOutsideBorderChar = '|';
|
||||
private $verticalInsideBorderChar = '|';
|
||||
private $crossingChar = '+';
|
||||
private $crossingTopRightChar = '+';
|
||||
private $crossingTopMidChar = '+';
|
||||
private $crossingTopLeftChar = '+';
|
||||
private $crossingMidRightChar = '+';
|
||||
private $crossingBottomRightChar = '+';
|
||||
private $crossingBottomMidChar = '+';
|
||||
private $crossingBottomLeftChar = '+';
|
||||
private $crossingMidLeftChar = '+';
|
||||
private $crossingTopLeftBottomChar = '+';
|
||||
private $crossingTopMidBottomChar = '+';
|
||||
private $crossingTopRightBottomChar = '+';
|
||||
private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private $cellHeaderFormat = '<info>%s</info>';
|
||||
private $cellRowFormat = '%s';
|
||||
private $cellRowContentFormat = ' %s ';
|
||||
private $borderFormat = '%s';
|
||||
private $padType = \STR_PAD_RIGHT;
|
||||
private string $paddingChar = ' ';
|
||||
private string $horizontalOutsideBorderChar = '-';
|
||||
private string $horizontalInsideBorderChar = '-';
|
||||
private string $verticalOutsideBorderChar = '|';
|
||||
private string $verticalInsideBorderChar = '|';
|
||||
private string $crossingChar = '+';
|
||||
private string $crossingTopRightChar = '+';
|
||||
private string $crossingTopMidChar = '+';
|
||||
private string $crossingTopLeftChar = '+';
|
||||
private string $crossingMidRightChar = '+';
|
||||
private string $crossingBottomRightChar = '+';
|
||||
private string $crossingBottomMidChar = '+';
|
||||
private string $crossingBottomLeftChar = '+';
|
||||
private string $crossingMidLeftChar = '+';
|
||||
private string $crossingTopLeftBottomChar = '+';
|
||||
private string $crossingTopMidBottomChar = '+';
|
||||
private string $crossingTopRightBottomChar = '+';
|
||||
private string $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private string $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private string $cellHeaderFormat = '<info>%s</info>';
|
||||
private string $cellRowFormat = '%s';
|
||||
private string $cellRowContentFormat = ' %s ';
|
||||
private string $borderFormat = '%s';
|
||||
private int $padType = \STR_PAD_RIGHT;
|
||||
|
||||
/**
|
||||
* Sets padding character, used for cell padding.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPaddingChar(string $paddingChar)
|
||||
public function setPaddingChar(string $paddingChar): static
|
||||
{
|
||||
if (!$paddingChar) {
|
||||
throw new LogicException('The padding char must not be empty.');
|
||||
@@ -66,10 +66,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets padding character, used for cell padding.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPaddingChar()
|
||||
public function getPaddingChar(): string
|
||||
{
|
||||
return $this->paddingChar;
|
||||
}
|
||||
@@ -90,7 +88,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHorizontalBorderChars(string $outside, string $inside = null): self
|
||||
public function setHorizontalBorderChars(string $outside, string $inside = null): static
|
||||
{
|
||||
$this->horizontalOutsideBorderChar = $outside;
|
||||
$this->horizontalInsideBorderChar = $inside ?? $outside;
|
||||
@@ -115,7 +113,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVerticalBorderChars(string $outside, string $inside = null): self
|
||||
public function setVerticalBorderChars(string $outside, string $inside = null): static
|
||||
{
|
||||
$this->verticalOutsideBorderChar = $outside;
|
||||
$this->verticalInsideBorderChar = $inside ?? $outside;
|
||||
@@ -169,7 +167,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): self
|
||||
public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): static
|
||||
{
|
||||
$this->crossingChar = $cross;
|
||||
$this->crossingTopLeftChar = $topLeft;
|
||||
@@ -199,10 +197,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets crossing character.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCrossingChar()
|
||||
public function getCrossingChar(): string
|
||||
{
|
||||
return $this->crossingChar;
|
||||
}
|
||||
@@ -235,7 +231,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellHeaderFormat(string $cellHeaderFormat)
|
||||
public function setCellHeaderFormat(string $cellHeaderFormat): static
|
||||
{
|
||||
$this->cellHeaderFormat = $cellHeaderFormat;
|
||||
|
||||
@@ -244,10 +240,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets header cell format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCellHeaderFormat()
|
||||
public function getCellHeaderFormat(): string
|
||||
{
|
||||
return $this->cellHeaderFormat;
|
||||
}
|
||||
@@ -257,7 +251,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellRowFormat(string $cellRowFormat)
|
||||
public function setCellRowFormat(string $cellRowFormat): static
|
||||
{
|
||||
$this->cellRowFormat = $cellRowFormat;
|
||||
|
||||
@@ -266,10 +260,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets row cell format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCellRowFormat()
|
||||
public function getCellRowFormat(): string
|
||||
{
|
||||
return $this->cellRowFormat;
|
||||
}
|
||||
@@ -279,7 +271,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellRowContentFormat(string $cellRowContentFormat)
|
||||
public function setCellRowContentFormat(string $cellRowContentFormat): static
|
||||
{
|
||||
$this->cellRowContentFormat = $cellRowContentFormat;
|
||||
|
||||
@@ -288,10 +280,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets row cell content format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCellRowContentFormat()
|
||||
public function getCellRowContentFormat(): string
|
||||
{
|
||||
return $this->cellRowContentFormat;
|
||||
}
|
||||
@@ -301,7 +291,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBorderFormat(string $borderFormat)
|
||||
public function setBorderFormat(string $borderFormat): static
|
||||
{
|
||||
$this->borderFormat = $borderFormat;
|
||||
|
||||
@@ -310,10 +300,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets table border format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderFormat()
|
||||
public function getBorderFormat(): string
|
||||
{
|
||||
return $this->borderFormat;
|
||||
}
|
||||
@@ -323,7 +311,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPadType(int $padType)
|
||||
public function setPadType(int $padType): static
|
||||
{
|
||||
if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
|
||||
throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
|
||||
@@ -336,10 +324,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets cell padding type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPadType()
|
||||
public function getPadType(): int
|
||||
{
|
||||
return $this->padType;
|
||||
}
|
||||
@@ -352,7 +338,7 @@ class TableStyle
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaderTitleFormat(string $format): self
|
||||
public function setHeaderTitleFormat(string $format): static
|
||||
{
|
||||
$this->headerTitleFormat = $format;
|
||||
|
||||
@@ -367,7 +353,7 @@ class TableStyle
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFooterTitleFormat(string $format): self
|
||||
public function setFooterTitleFormat(string $format): static
|
||||
{
|
||||
$this->footerTitleFormat = $format;
|
||||
|
||||
|
Reference in New Issue
Block a user