Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
140
vendor/symfony/console/Application.php
vendored
140
vendor/symfony/console/Application.php
vendored
@@ -17,11 +17,11 @@ use Symfony\Component\Console\Command\ListCommand;
|
||||
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\Console\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Exception\NamespaceNotFoundException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Helper\DebugFormatterHelper;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
@@ -40,6 +40,7 @@ use Symfony\Component\Console\Input\StreamableInputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
@@ -81,7 +82,7 @@ class Application
|
||||
* @param string $name The name of the application
|
||||
* @param string $version The version of the application
|
||||
*/
|
||||
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
|
||||
public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->version = $version;
|
||||
@@ -138,10 +139,6 @@ class Application
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $this->dispatcher && $this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) {
|
||||
@trigger_error(sprintf('The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead.'), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->configureIO($input, $output);
|
||||
|
||||
try {
|
||||
@@ -224,24 +221,41 @@ class Application
|
||||
}
|
||||
|
||||
try {
|
||||
$e = $this->runningCommand = null;
|
||||
$this->runningCommand = null;
|
||||
// the command name MUST be the first element of the input
|
||||
$command = $this->find($name);
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
if (null !== $e) {
|
||||
if (null !== $this->dispatcher) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
$e = $event->getError();
|
||||
if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
|
||||
if (null !== $this->dispatcher) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
|
||||
if (0 === $event->getExitCode()) {
|
||||
return 0;
|
||||
if (0 === $event->getExitCode()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$e = $event->getError();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
$alternative = $alternatives[0];
|
||||
|
||||
$style = new SymfonyStyle($input, $output);
|
||||
$style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
|
||||
if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
|
||||
if (null !== $this->dispatcher) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
|
||||
return $event->getExitCode();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$command = $this->find($alternative);
|
||||
}
|
||||
|
||||
$this->runningCommand = $command;
|
||||
@@ -540,7 +554,7 @@ class Application
|
||||
*
|
||||
* @return string A registered namespace
|
||||
*
|
||||
* @throws CommandNotFoundException When namespace is incorrect or ambiguous
|
||||
* @throws NamespaceNotFoundException When namespace is incorrect or ambiguous
|
||||
*/
|
||||
public function findNamespace($namespace)
|
||||
{
|
||||
@@ -561,12 +575,12 @@ class Application
|
||||
$message .= implode("\n ", $alternatives);
|
||||
}
|
||||
|
||||
throw new CommandNotFoundException($message, $alternatives);
|
||||
throw new NamespaceNotFoundException($message, $alternatives);
|
||||
}
|
||||
|
||||
$exact = \in_array($namespace, $namespaces, true);
|
||||
if (\count($namespaces) > 1 && !$exact) {
|
||||
throw new CommandNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
|
||||
throw new NamespaceNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
|
||||
}
|
||||
|
||||
return $exact ? $namespace : reset($namespaces);
|
||||
@@ -746,10 +760,6 @@ class Application
|
||||
}
|
||||
|
||||
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX;
|
||||
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
|
||||
if (\defined('HHVM_VERSION') && $width > 1 << 31) {
|
||||
$width = 1 << 31;
|
||||
}
|
||||
$lines = array();
|
||||
foreach ('' !== $message ? preg_split('/\r?\n/', $message) : array() as $line) {
|
||||
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
|
||||
@@ -798,70 +808,6 @@ class Application
|
||||
} while ($e = $e->getPrevious());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to figure out the terminal width in which this application runs.
|
||||
*
|
||||
* @return int|null
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
|
||||
*/
|
||||
protected function getTerminalWidth()
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->terminal->getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to figure out the terminal height in which this application runs.
|
||||
*
|
||||
* @return int|null
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
|
||||
*/
|
||||
protected function getTerminalHeight()
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->terminal->getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to figure out the terminal dimensions based on the current environment.
|
||||
*
|
||||
* @return array Array containing width and height
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
|
||||
*/
|
||||
public function getTerminalDimensions()
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return array($this->terminal->getWidth(), $this->terminal->getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets terminal dimensions.
|
||||
*
|
||||
* Can be useful to force terminal dimensions for functional tests.
|
||||
*
|
||||
* @param int $width The width
|
||||
* @param int $height The height
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead.
|
||||
*/
|
||||
public function setTerminalDimensions($width, $height)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
putenv('COLUMNS='.$width);
|
||||
putenv('LINES='.$height);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the input and output instances based on the user arguments and options.
|
||||
*/
|
||||
@@ -882,12 +828,6 @@ class Application
|
||||
$inputStream = $input->getStream();
|
||||
}
|
||||
|
||||
// This check ensures that calling QuestionHelper::setInputStream() works
|
||||
// To be removed in 4.0 (in the same time as QuestionHelper::setInputStream)
|
||||
if (!$inputStream && $this->getHelperSet()->has('question')) {
|
||||
$inputStream = $this->getHelperSet()->get('question')->getInputStream(false);
|
||||
}
|
||||
|
||||
if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
|
||||
$input->setInteractive(false);
|
||||
}
|
||||
@@ -965,19 +905,7 @@ class Application
|
||||
} else {
|
||||
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
if (null !== $e) {
|
||||
if ($this->dispatcher->hasListeners(ConsoleEvents::EXCEPTION)) {
|
||||
$x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
|
||||
$event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
|
||||
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
|
||||
|
||||
if ($x !== $event->getException()) {
|
||||
$e = $event->getException();
|
||||
}
|
||||
}
|
||||
$event = new ConsoleErrorEvent($input, $output, $e, $command);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
$e = $event->getError();
|
||||
|
17
vendor/symfony/console/CHANGELOG.md
vendored
17
vendor/symfony/console/CHANGELOG.md
vendored
@@ -1,6 +1,23 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.1.0
|
||||
-----
|
||||
|
||||
* added option to run suggested command if command is not found and only 1 alternative is available
|
||||
* added option to modify console output and print multiple modifiable sections
|
||||
* added support for iterable messages in output `write` and `writeln` methods
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* `OutputFormatter` throws an exception when unknown options are used
|
||||
* removed `QuestionHelper::setInputStream()/getInputStream()`
|
||||
* removed `Application::getTerminalWidth()/getTerminalHeight()` and
|
||||
`Application::setTerminalDimensions()/getTerminalDimensions()`
|
||||
* removed `ConsoleExceptionEvent`
|
||||
* removed `ConsoleEvents::EXCEPTION`
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
|
16
vendor/symfony/console/Command/Command.php
vendored
16
vendor/symfony/console/Command/Command.php
vendored
@@ -66,7 +66,7 @@ class Command
|
||||
*
|
||||
* @throws LogicException When the command name is empty
|
||||
*/
|
||||
public function __construct($name = null)
|
||||
public function __construct(string $name = null)
|
||||
{
|
||||
$this->definition = new InputDefinition();
|
||||
|
||||
@@ -273,15 +273,7 @@ class Command
|
||||
if ($code instanceof \Closure) {
|
||||
$r = new \ReflectionFunction($code);
|
||||
if (null === $r->getClosureThis()) {
|
||||
if (\PHP_VERSION_ID < 70000) {
|
||||
// Bug in PHP5: https://bugs.php.net/bug.php?id=64761
|
||||
// This means that we cannot bind static closures and therefore we must
|
||||
// ignore any errors here. There is no way to test if the closure is
|
||||
// bindable.
|
||||
$code = @\Closure::bind($code, $this);
|
||||
} else {
|
||||
$code = \Closure::bind($code, $this);
|
||||
}
|
||||
$code = \Closure::bind($code, $this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,11 +635,9 @@ class Command
|
||||
*
|
||||
* It must be non-empty and parts can optionally be separated by ":".
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws InvalidArgumentException When the name is invalid
|
||||
*/
|
||||
private function validateName($name)
|
||||
private function validateName(string $name)
|
||||
{
|
||||
if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
|
||||
throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
|
||||
|
@@ -43,7 +43,7 @@ trait LockableTrait
|
||||
throw new LogicException('A lock is already in place.');
|
||||
}
|
||||
|
||||
if (SemaphoreStore::isSupported($blocking)) {
|
||||
if (SemaphoreStore::isSupported()) {
|
||||
$store = new SemaphoreStore();
|
||||
} else {
|
||||
$store = new FlockStore();
|
||||
|
13
vendor/symfony/console/ConsoleEvents.php
vendored
13
vendor/symfony/console/ConsoleEvents.php
vendored
@@ -35,19 +35,6 @@ final class ConsoleEvents
|
||||
*/
|
||||
const TERMINATE = 'console.terminate';
|
||||
|
||||
/**
|
||||
* The EXCEPTION event occurs when an uncaught exception appears
|
||||
* while executing Command#run().
|
||||
*
|
||||
* This event allows you to deal with the exception or
|
||||
* to modify the thrown exception.
|
||||
*
|
||||
* @Event("Symfony\Component\Console\Event\ConsoleExceptionEvent")
|
||||
*
|
||||
* @deprecated The console.exception event is deprecated since version 3.3 and will be removed in 4.0. Use the console.error event instead.
|
||||
*/
|
||||
const EXCEPTION = 'console.exception';
|
||||
|
||||
/**
|
||||
* The ERROR event occurs when an uncaught exception or error appears.
|
||||
*
|
||||
|
@@ -29,7 +29,7 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
private $commandLoaderServiceId;
|
||||
private $commandTag;
|
||||
|
||||
public function __construct($commandLoaderServiceId = 'console.command_loader', $commandTag = 'console.command')
|
||||
public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command')
|
||||
{
|
||||
$this->commandLoaderServiceId = $commandLoaderServiceId;
|
||||
$this->commandTag = $commandTag;
|
||||
@@ -41,14 +41,11 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
$lazyCommandMap = array();
|
||||
$lazyCommandRefs = array();
|
||||
$serviceIds = array();
|
||||
$lazyServiceIds = array();
|
||||
|
||||
foreach ($commandServices as $id => $tags) {
|
||||
$definition = $container->getDefinition($id);
|
||||
$class = $container->getParameterBag()->resolveValue($definition->getClass());
|
||||
|
||||
$commandId = 'console.command.'.strtolower(str_replace('\\', '_', $class));
|
||||
|
||||
if (isset($tags[0]['command'])) {
|
||||
$commandName = $tags[0]['command'];
|
||||
} else {
|
||||
@@ -62,20 +59,16 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
if (null === $commandName) {
|
||||
if (isset($serviceIds[$commandId]) || $container->hasAlias($commandId)) {
|
||||
$commandId = $commandId.'_'.$id;
|
||||
}
|
||||
if (!$definition->isPublic() || $definition->isPrivate()) {
|
||||
$commandId = 'console.command.public_alias.'.$id;
|
||||
$container->setAlias($commandId, $id)->setPublic(true);
|
||||
$id = $commandId;
|
||||
}
|
||||
$serviceIds[$commandId] = $id;
|
||||
$serviceIds[] = $id;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$serviceIds[$commandId] = $id;
|
||||
$lazyServiceIds[$id] = true;
|
||||
unset($tags[0]);
|
||||
$lazyCommandMap[$commandName] = $id;
|
||||
$lazyCommandRefs[$id] = new TypedReference($id, $class);
|
||||
@@ -101,6 +94,5 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
->setArguments(array(ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap));
|
||||
|
||||
$container->setParameter('console.command.ids', $serviceIds);
|
||||
$container->setParameter('console.lazy_command.ids', $lazyServiceIds);
|
||||
}
|
||||
}
|
||||
|
@@ -43,12 +43,7 @@ class ApplicationDescription
|
||||
*/
|
||||
private $aliases;
|
||||
|
||||
/**
|
||||
* @param Application $application
|
||||
* @param string|null $namespace
|
||||
* @param bool $showHidden
|
||||
*/
|
||||
public function __construct(Application $application, $namespace = null, $showHidden = false)
|
||||
public function __construct(Application $application, string $namespace = null, bool $showHidden = false)
|
||||
{
|
||||
$this->application = $application;
|
||||
$this->namespace = $namespace;
|
||||
@@ -123,10 +118,7 @@ class ApplicationDescription
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function sortCommands(array $commands)
|
||||
private function sortCommands(array $commands): array
|
||||
{
|
||||
$namespacedCommands = array();
|
||||
$globalCommands = array();
|
||||
|
@@ -140,6 +140,13 @@ class TextDescriptor extends Descriptor
|
||||
$command->getSynopsis(false);
|
||||
$command->mergeApplicationDefinition(false);
|
||||
|
||||
if ($description = $command->getDescription()) {
|
||||
$this->writeText('<comment>Description:</comment>', $options);
|
||||
$this->writeText("\n");
|
||||
$this->writeText(' '.$description);
|
||||
$this->writeText("\n\n");
|
||||
}
|
||||
|
||||
$this->writeText('<comment>Usage:</comment>', $options);
|
||||
foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
|
||||
$this->writeText("\n");
|
||||
@@ -154,7 +161,8 @@ class TextDescriptor extends Descriptor
|
||||
$this->writeText("\n");
|
||||
}
|
||||
|
||||
if ($help = $command->getProcessedHelp()) {
|
||||
$help = $command->getProcessedHelp();
|
||||
if ($help && $help !== $description) {
|
||||
$this->writeText("\n");
|
||||
$this->writeText('<comment>Help:</comment>', $options);
|
||||
$this->writeText("\n");
|
||||
@@ -202,9 +210,9 @@ class TextDescriptor extends Descriptor
|
||||
}
|
||||
|
||||
// calculate max. width based on available commands per namespace
|
||||
$width = $this->getColumnWidth(\call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) {
|
||||
$width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
|
||||
return array_intersect($namespace['commands'], array_keys($commands));
|
||||
}, $namespaces)));
|
||||
}, $namespaces))));
|
||||
|
||||
if ($describedNamespace) {
|
||||
$this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
|
||||
@@ -252,10 +260,8 @@ class TextDescriptor extends Descriptor
|
||||
|
||||
/**
|
||||
* Formats command aliases to show them in the command description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCommandAliasesText(Command $command)
|
||||
private function getCommandAliasesText(Command $command): string
|
||||
{
|
||||
$text = '';
|
||||
$aliases = $command->getAliases();
|
||||
@@ -271,10 +277,8 @@ class TextDescriptor extends Descriptor
|
||||
* Formats input option/argument default value.
|
||||
*
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function formatDefaultValue($default)
|
||||
private function formatDefaultValue($default): string
|
||||
{
|
||||
if (INF === $default) {
|
||||
return 'INF';
|
||||
@@ -295,10 +299,8 @@ class TextDescriptor extends Descriptor
|
||||
|
||||
/**
|
||||
* @param (Command|string)[] $commands
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getColumnWidth(array $commands)
|
||||
private function getColumnWidth(array $commands): int
|
||||
{
|
||||
$widths = array();
|
||||
|
||||
@@ -318,10 +320,8 @@ class TextDescriptor extends Descriptor
|
||||
|
||||
/**
|
||||
* @param InputOption[] $options
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function calculateTotalWidthForOptions(array $options)
|
||||
private function calculateTotalWidthForOptions(array $options): int
|
||||
{
|
||||
$totalWidth = 0;
|
||||
foreach ($options as $option) {
|
||||
|
@@ -188,10 +188,7 @@ class XmlDescriptor extends Descriptor
|
||||
$this->write($dom->saveXML());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
private function getInputArgumentDocument(InputArgument $argument)
|
||||
private function getInputArgumentDocument(InputArgument $argument): \DOMDocument
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
@@ -212,10 +209,7 @@ class XmlDescriptor extends Descriptor
|
||||
return $dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
private function getInputOptionDocument(InputOption $option)
|
||||
private function getInputOptionDocument(InputOption $option): \DOMDocument
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
|
@@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Console\Event;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
@@ -26,57 +25,33 @@ final class ConsoleErrorEvent extends ConsoleEvent
|
||||
private $error;
|
||||
private $exitCode;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output, $error, Command $command = null)
|
||||
public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, Command $command = null)
|
||||
{
|
||||
parent::__construct($command, $input, $output);
|
||||
|
||||
$this->setError($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the thrown error/exception.
|
||||
*
|
||||
* @return \Throwable
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the thrown error/exception.
|
||||
*
|
||||
* @param \Throwable $error
|
||||
*/
|
||||
public function setError($error)
|
||||
{
|
||||
if (!$error instanceof \Throwable && !$error instanceof \Exception) {
|
||||
throw new InvalidArgumentException(sprintf('The error passed to ConsoleErrorEvent must be an instance of \Throwable or \Exception, "%s" was passed instead.', \is_object($error) ? \get_class($error) : \gettype($error)));
|
||||
}
|
||||
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exit code.
|
||||
*
|
||||
* @param int $exitCode The command exit code
|
||||
*/
|
||||
public function setExitCode($exitCode)
|
||||
public function getError(): \Throwable
|
||||
{
|
||||
$this->exitCode = (int) $exitCode;
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function setError(\Throwable $error): void
|
||||
{
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
public function setExitCode(int $exitCode): void
|
||||
{
|
||||
$this->exitCode = $exitCode;
|
||||
|
||||
$r = new \ReflectionProperty($this->error, 'code');
|
||||
$r->setAccessible(true);
|
||||
$r->setValue($this->error, $this->exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exit code.
|
||||
*
|
||||
* @return int The command exit code
|
||||
*/
|
||||
public function getExitCode()
|
||||
public function getExitCode(): int
|
||||
{
|
||||
return null !== $this->exitCode ? $this->exitCode : (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
|
||||
}
|
||||
|
@@ -1,71 +0,0 @@
|
||||
<?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\Event;
|
||||
|
||||
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Allows to handle exception thrown in a command.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated since version 3.3, to be removed in 4.0. Use ConsoleErrorEvent instead.
|
||||
*/
|
||||
class ConsoleExceptionEvent extends ConsoleEvent
|
||||
{
|
||||
private $exception;
|
||||
private $exitCode;
|
||||
|
||||
public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
|
||||
{
|
||||
parent::__construct($command, $input, $output);
|
||||
|
||||
$this->setException($exception);
|
||||
$this->exitCode = (int) $exitCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the thrown exception.
|
||||
*
|
||||
* @return \Exception The thrown exception
|
||||
*/
|
||||
public function getException()
|
||||
{
|
||||
return $this->exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the thrown exception.
|
||||
*
|
||||
* This exception will be thrown if no response is set in the event.
|
||||
*
|
||||
* @param \Exception $exception The thrown exception
|
||||
*/
|
||||
public function setException(\Exception $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exit code.
|
||||
*
|
||||
* @return int The command exit code
|
||||
*/
|
||||
public function getExitCode()
|
||||
{
|
||||
return $this->exitCode;
|
||||
}
|
||||
}
|
@@ -22,14 +22,9 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
class ConsoleTerminateEvent extends ConsoleEvent
|
||||
{
|
||||
/**
|
||||
* The exit code of the command.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $exitCode;
|
||||
|
||||
public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
|
||||
public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode)
|
||||
{
|
||||
parent::__construct($command, $input, $output);
|
||||
|
||||
|
@@ -26,7 +26,7 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce
|
||||
* @param int $code Exception code
|
||||
* @param \Exception $previous Previous exception used for the exception chaining
|
||||
*/
|
||||
public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
|
||||
public function __construct(string $message, array $alternatives = array(), int $code = 0, \Exception $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
|
21
vendor/symfony/console/Exception/NamespaceNotFoundException.php
vendored
Normal file
21
vendor/symfony/console/Exception/NamespaceNotFoundException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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\Exception;
|
||||
|
||||
/**
|
||||
* Represents an incorrect namespace typed in the console.
|
||||
*
|
||||
* @author Pierre du Plessis <pdples@gmail.com>
|
||||
*/
|
||||
class NamespaceNotFoundException extends CommandNotFoundException
|
||||
{
|
||||
}
|
@@ -65,9 +65,9 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
* @param bool $decorated Whether this formatter should actually decorate strings
|
||||
* @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances
|
||||
*/
|
||||
public function __construct($decorated = false, array $styles = array())
|
||||
public function __construct(bool $decorated = false, array $styles = array())
|
||||
{
|
||||
$this->decorated = (bool) $decorated;
|
||||
$this->decorated = $decorated;
|
||||
|
||||
$this->setStyle('error', new OutputFormatterStyle('white', 'red'));
|
||||
$this->setStyle('info', new OutputFormatterStyle('green'));
|
||||
@@ -186,11 +186,9 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
/**
|
||||
* Tries to create new style instance from string.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return OutputFormatterStyle|false false if string is not format string
|
||||
* @return OutputFormatterStyle|false False if string is not format string
|
||||
*/
|
||||
private function createStyleFromString($string)
|
||||
private function createStyleFromString(string $string)
|
||||
{
|
||||
if (isset($this->styles[$string])) {
|
||||
return $this->styles[$string];
|
||||
@@ -212,13 +210,7 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
preg_match_all('([^,;]+)', $match[1], $options);
|
||||
$options = array_shift($options);
|
||||
foreach ($options as $option) {
|
||||
try {
|
||||
$style->setOption($option);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
@trigger_error(sprintf('Unknown style options are deprecated since Symfony 3.2 and will be removed in 4.0. Exception "%s".', $e->getMessage()), E_USER_DEPRECATED);
|
||||
|
||||
return false;
|
||||
}
|
||||
$style->setOption($option);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
@@ -230,12 +222,8 @@ class OutputFormatter implements OutputFormatterInterface
|
||||
|
||||
/**
|
||||
* Applies current style from stack to text, if must be applied.
|
||||
*
|
||||
* @param string $text Input text
|
||||
*
|
||||
* @return string Styled text
|
||||
*/
|
||||
private function applyCurrentStyle($text)
|
||||
private function applyCurrentStyle(string $text): string
|
||||
{
|
||||
return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
* @param string|null $background The style background color name
|
||||
* @param array $options The style options
|
||||
*/
|
||||
public function __construct($foreground = null, $background = null, array $options = array())
|
||||
public function __construct(string $foreground = null, string $background = null, array $options = array())
|
||||
{
|
||||
if (null !== $foreground) {
|
||||
$this->setForeground($foreground);
|
||||
|
203
vendor/symfony/console/Helper/ProgressBar.php
vendored
203
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -13,6 +13,7 @@ namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
@@ -50,7 +51,7 @@ final class ProgressBar
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
*/
|
||||
public function __construct(OutputInterface $output, $max = 0)
|
||||
public function __construct(OutputInterface $output, int $max = 0)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
@@ -79,7 +80,7 @@ final class ProgressBar
|
||||
* @param string $name The placeholder name (including the delimiter char like %)
|
||||
* @param callable $callable A PHP callable
|
||||
*/
|
||||
public static function setPlaceholderFormatterDefinition($name, callable $callable)
|
||||
public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
@@ -95,7 +96,7 @@ final class ProgressBar
|
||||
*
|
||||
* @return callable|null A PHP callable
|
||||
*/
|
||||
public static function getPlaceholderFormatterDefinition($name)
|
||||
public static function getPlaceholderFormatterDefinition(string $name): ?callable
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
@@ -112,7 +113,7 @@ final class ProgressBar
|
||||
* @param string $name The format name
|
||||
* @param string $format A format string
|
||||
*/
|
||||
public static function setFormatDefinition($name, $format)
|
||||
public static function setFormatDefinition(string $name, string $format): void
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
@@ -128,7 +129,7 @@ final class ProgressBar
|
||||
*
|
||||
* @return string|null A format string
|
||||
*/
|
||||
public static function getFormatDefinition($name)
|
||||
public static function getFormatDefinition(string $name): ?string
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
@@ -147,102 +148,57 @@ final class ProgressBar
|
||||
* @param string $message The text to associate with the placeholder
|
||||
* @param string $name The name of the placeholder
|
||||
*/
|
||||
public function setMessage($message, $name = 'message')
|
||||
public function setMessage(string $message, string $name = 'message')
|
||||
{
|
||||
$this->messages[$name] = $message;
|
||||
}
|
||||
|
||||
public function getMessage($name = 'message')
|
||||
public function getMessage(string $name = 'message')
|
||||
{
|
||||
return $this->messages[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress bar start time.
|
||||
*
|
||||
* @return int The progress bar start time
|
||||
*/
|
||||
public function getStartTime()
|
||||
public function getStartTime(): int
|
||||
{
|
||||
return $this->startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress bar maximal steps.
|
||||
*
|
||||
* @return int The progress bar max steps
|
||||
*/
|
||||
public function getMaxSteps()
|
||||
public function getMaxSteps(): int
|
||||
{
|
||||
return $this->max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current step position.
|
||||
*
|
||||
* @return int The progress bar step
|
||||
*/
|
||||
public function getProgress()
|
||||
public function getProgress(): int
|
||||
{
|
||||
return $this->step;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress bar step width.
|
||||
*
|
||||
* @return int The progress bar step width
|
||||
*/
|
||||
private function getStepWidth()
|
||||
private function getStepWidth(): int
|
||||
{
|
||||
return $this->stepWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current progress bar percent.
|
||||
*
|
||||
* @return float The current progress bar percent
|
||||
*/
|
||||
public function getProgressPercent()
|
||||
public function getProgressPercent(): float
|
||||
{
|
||||
return $this->percent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar width.
|
||||
*
|
||||
* @param int $size The progress bar size
|
||||
*/
|
||||
public function setBarWidth($size)
|
||||
public function setBarWidth(int $size)
|
||||
{
|
||||
$this->barWidth = max(1, (int) $size);
|
||||
$this->barWidth = max(1, $size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress bar width.
|
||||
*
|
||||
* @return int The progress bar size
|
||||
*/
|
||||
public function getBarWidth()
|
||||
public function getBarWidth(): int
|
||||
{
|
||||
return $this->barWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bar character.
|
||||
*
|
||||
* @param string $char A character
|
||||
*/
|
||||
public function setBarCharacter($char)
|
||||
public function setBarCharacter(string $char)
|
||||
{
|
||||
$this->barChar = $char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bar character.
|
||||
*
|
||||
* @return string A character
|
||||
*/
|
||||
public function getBarCharacter()
|
||||
public function getBarCharacter(): string
|
||||
{
|
||||
if (null === $this->barChar) {
|
||||
return $this->max ? '=' : $this->emptyBarChar;
|
||||
@@ -251,52 +207,27 @@ final class ProgressBar
|
||||
return $this->barChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the empty bar character.
|
||||
*
|
||||
* @param string $char A character
|
||||
*/
|
||||
public function setEmptyBarCharacter($char)
|
||||
public function setEmptyBarCharacter(string $char)
|
||||
{
|
||||
$this->emptyBarChar = $char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the empty bar character.
|
||||
*
|
||||
* @return string A character
|
||||
*/
|
||||
public function getEmptyBarCharacter()
|
||||
public function getEmptyBarCharacter(): string
|
||||
{
|
||||
return $this->emptyBarChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar character.
|
||||
*
|
||||
* @param string $char A character
|
||||
*/
|
||||
public function setProgressCharacter($char)
|
||||
public function setProgressCharacter(string $char)
|
||||
{
|
||||
$this->progressChar = $char;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress bar character.
|
||||
*
|
||||
* @return string A character
|
||||
*/
|
||||
public function getProgressCharacter()
|
||||
public function getProgressCharacter(): string
|
||||
{
|
||||
return $this->progressChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar format.
|
||||
*
|
||||
* @param string $format The format
|
||||
*/
|
||||
public function setFormat($format)
|
||||
public function setFormat(string $format)
|
||||
{
|
||||
$this->format = null;
|
||||
$this->internalFormat = $format;
|
||||
@@ -307,9 +238,9 @@ final class ProgressBar
|
||||
*
|
||||
* @param int|float $freq The frequency in steps
|
||||
*/
|
||||
public function setRedrawFrequency($freq)
|
||||
public function setRedrawFrequency(int $freq)
|
||||
{
|
||||
$this->redrawFreq = max((int) $freq, 1);
|
||||
$this->redrawFreq = max($freq, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +248,7 @@ final class ProgressBar
|
||||
*
|
||||
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
|
||||
*/
|
||||
public function start($max = null)
|
||||
public function start(int $max = null)
|
||||
{
|
||||
$this->startTime = time();
|
||||
$this->step = 0;
|
||||
@@ -335,30 +266,21 @@ final class ProgressBar
|
||||
*
|
||||
* @param int $step Number of steps to advance
|
||||
*/
|
||||
public function advance($step = 1)
|
||||
public function advance(int $step = 1)
|
||||
{
|
||||
$this->setProgress($this->step + $step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to overwrite the progressbar, false for new line.
|
||||
*
|
||||
* @param bool $overwrite
|
||||
*/
|
||||
public function setOverwrite($overwrite)
|
||||
public function setOverwrite(bool $overwrite)
|
||||
{
|
||||
$this->overwrite = (bool) $overwrite;
|
||||
$this->overwrite = $overwrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current progress.
|
||||
*
|
||||
* @param int $step The current progress
|
||||
*/
|
||||
public function setProgress($step)
|
||||
public function setProgress(int $step)
|
||||
{
|
||||
$step = (int) $step;
|
||||
|
||||
if ($this->max && $step > $this->max) {
|
||||
$this->max = $step;
|
||||
} elseif ($step < 0) {
|
||||
@@ -374,10 +296,17 @@ final class ProgressBar
|
||||
}
|
||||
}
|
||||
|
||||
public function setMaxSteps(int $max)
|
||||
{
|
||||
$this->format = null;
|
||||
$this->max = max(0, $max);
|
||||
$this->stepWidth = $this->max ? Helper::strlen((string) $this->max) : 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes the progress output.
|
||||
*/
|
||||
public function finish()
|
||||
public function finish(): void
|
||||
{
|
||||
if (!$this->max) {
|
||||
$this->max = $this->step;
|
||||
@@ -394,7 +323,7 @@ final class ProgressBar
|
||||
/**
|
||||
* Outputs the current progress string.
|
||||
*/
|
||||
public function display()
|
||||
public function display(): void
|
||||
{
|
||||
if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
|
||||
return;
|
||||
@@ -414,7 +343,7 @@ final class ProgressBar
|
||||
* while a progress bar is running.
|
||||
* Call display() to show the progress bar again.
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): void
|
||||
{
|
||||
if (!$this->overwrite) {
|
||||
return;
|
||||
@@ -427,12 +356,7 @@ final class ProgressBar
|
||||
$this->overwrite('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar format.
|
||||
*
|
||||
* @param string $format The format
|
||||
*/
|
||||
private function setRealFormat($format)
|
||||
private function setRealFormat(string $format)
|
||||
{
|
||||
// try to use the _nomax variant if available
|
||||
if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
|
||||
@@ -446,35 +370,27 @@ final class ProgressBar
|
||||
$this->formatLineCount = substr_count($this->format, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the progress bar maximal steps.
|
||||
*
|
||||
* @param int $max The progress bar max steps
|
||||
*/
|
||||
private function setMaxSteps($max)
|
||||
{
|
||||
$this->max = max(0, (int) $max);
|
||||
$this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output.
|
||||
*
|
||||
* @param string $message The message
|
||||
*/
|
||||
private function overwrite($message)
|
||||
private function overwrite(string $message): void
|
||||
{
|
||||
if ($this->overwrite) {
|
||||
if (!$this->firstRun) {
|
||||
// Move the cursor to the beginning of the line
|
||||
$this->output->write("\x0D");
|
||||
if ($this->output instanceof ConsoleSectionOutput) {
|
||||
$lines = floor(Helper::strlen($message) / $this->terminal->getWidth()) + $this->formatLineCount + 1;
|
||||
$this->output->clear($lines);
|
||||
} else {
|
||||
// Move the cursor to the beginning of the line
|
||||
$this->output->write("\x0D");
|
||||
|
||||
// Erase the line
|
||||
$this->output->write("\x1B[2K");
|
||||
// Erase the line
|
||||
$this->output->write("\x1B[2K");
|
||||
|
||||
// Erase previous lines
|
||||
if ($this->formatLineCount > 0) {
|
||||
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
|
||||
// Erase previous lines
|
||||
if ($this->formatLineCount > 0) {
|
||||
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($this->step > 0) {
|
||||
@@ -486,7 +402,7 @@ final class ProgressBar
|
||||
$this->output->write($message);
|
||||
}
|
||||
|
||||
private function determineBestFormat()
|
||||
private function determineBestFormat(): string
|
||||
{
|
||||
switch ($this->output->getVerbosity()) {
|
||||
// OutputInterface::VERBOSITY_QUIET: display is disabled anyway
|
||||
@@ -501,7 +417,7 @@ final class ProgressBar
|
||||
}
|
||||
}
|
||||
|
||||
private static function initPlaceholderFormatters()
|
||||
private static function initPlaceholderFormatters(): array
|
||||
{
|
||||
return array(
|
||||
'bar' => function (ProgressBar $bar, OutputInterface $output) {
|
||||
@@ -558,7 +474,7 @@ final class ProgressBar
|
||||
);
|
||||
}
|
||||
|
||||
private static function initFormats()
|
||||
private static function initFormats(): array
|
||||
{
|
||||
return array(
|
||||
'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
|
||||
@@ -575,10 +491,7 @@ final class ProgressBar
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function buildLine()
|
||||
private function buildLine(): string
|
||||
{
|
||||
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
|
||||
$callback = function ($matches) {
|
||||
|
@@ -39,7 +39,7 @@ class ProgressIndicator
|
||||
* @param int $indicatorChangeInterval Change interval in milliseconds
|
||||
* @param array|null $indicatorValues Animated indicator characters
|
||||
*/
|
||||
public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
|
||||
public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null)
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
@@ -219,10 +219,8 @@ class ProgressIndicator
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output.
|
||||
*
|
||||
* @param string $message The message
|
||||
*/
|
||||
private function overwrite($message)
|
||||
private function overwrite(string $message)
|
||||
{
|
||||
if ($this->output->isDecorated()) {
|
||||
$this->output->write("\x0D\x1B[2K");
|
||||
|
54
vendor/symfony/console/Helper/QuestionHelper.php
vendored
54
vendor/symfony/console/Helper/QuestionHelper.php
vendored
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
@@ -71,46 +70,6 @@ class QuestionHelper extends Helper
|
||||
return $this->validateAttempts($interviewer, $output, $question);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input stream to read from when interacting with the user.
|
||||
*
|
||||
* This is mainly useful for testing purpose.
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Use
|
||||
* StreamableInputInterface::setStream() instead.
|
||||
*
|
||||
* @param resource $stream The input stream
|
||||
*
|
||||
* @throws InvalidArgumentException In case the stream is not a resource
|
||||
*/
|
||||
public function setInputStream($stream)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED);
|
||||
|
||||
if (!\is_resource($stream)) {
|
||||
throw new InvalidArgumentException('Input stream must be a valid resource.');
|
||||
}
|
||||
|
||||
$this->inputStream = $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the helper's input stream.
|
||||
*
|
||||
* @deprecated since version 3.2, to be removed in 4.0. Use
|
||||
* StreamableInputInterface::getStream() instead.
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getInputStream()
|
||||
{
|
||||
if (0 === \func_num_args() || func_get_arg(0)) {
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $this->inputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -217,11 +176,8 @@ class QuestionHelper extends Helper
|
||||
* @param OutputInterface $output
|
||||
* @param Question $question
|
||||
* @param resource $inputStream
|
||||
* @param array $autocomplete
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
|
||||
private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete): string
|
||||
{
|
||||
$ret = '';
|
||||
|
||||
@@ -336,11 +292,9 @@ class QuestionHelper extends Helper
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param resource $inputStream The handler resource
|
||||
*
|
||||
* @return string The answer
|
||||
*
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
|
||||
*/
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream)
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream): string
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||
@@ -451,10 +405,8 @@ class QuestionHelper extends Helper
|
||||
|
||||
/**
|
||||
* Returns whether Stty is available or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function hasSttyAvailable()
|
||||
private function hasSttyAvailable(): bool
|
||||
{
|
||||
if (null !== self::$stty) {
|
||||
return self::$stty;
|
||||
|
@@ -11,9 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
@@ -27,32 +25,6 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
*/
|
||||
class SymfonyQuestionHelper extends QuestionHelper
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* To be removed in 4.0
|
||||
*/
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question)
|
||||
{
|
||||
$validator = $question->getValidator();
|
||||
$question->setValidator(function ($value) use ($validator) {
|
||||
if (null !== $validator) {
|
||||
$value = $validator($value);
|
||||
} else {
|
||||
// make required
|
||||
if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
|
||||
@trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED);
|
||||
|
||||
throw new LogicException('A value is required.');
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
});
|
||||
|
||||
return parent::ask($input, $output, $question);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
240
vendor/symfony/console/Helper/Table.php
vendored
240
vendor/symfony/console/Helper/Table.php
vendored
@@ -12,6 +12,8 @@
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
@@ -21,9 +23,17 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
* @author Саша Стаменковић <umpirsky@gmail.com>
|
||||
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
|
||||
* @author Max Grigorian <maxakawizard@gmail.com>
|
||||
* @author Dany Maillard <danymaillard93b@gmail.com>
|
||||
*/
|
||||
class Table
|
||||
{
|
||||
private const SEPARATOR_TOP = 0;
|
||||
private const SEPARATOR_TOP_BOTTOM = 1;
|
||||
private const SEPARATOR_MID = 2;
|
||||
private const SEPARATOR_BOTTOM = 3;
|
||||
private const BORDER_OUTSIDE = 0;
|
||||
private const BORDER_INSIDE = 1;
|
||||
|
||||
/**
|
||||
* Table headers.
|
||||
*/
|
||||
@@ -70,6 +80,8 @@ class Table
|
||||
|
||||
private static $styles;
|
||||
|
||||
private $rendered = false;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
@@ -252,6 +264,25 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a row to the table, and re-renders the table.
|
||||
*/
|
||||
public function appendRow($row): self
|
||||
{
|
||||
if (!$this->output instanceof ConsoleSectionOutput) {
|
||||
throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
|
||||
}
|
||||
|
||||
if ($this->rendered) {
|
||||
$this->output->clear($this->calculateRowCount());
|
||||
}
|
||||
|
||||
$this->addRow($row);
|
||||
$this->render();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRow($column, array $row)
|
||||
{
|
||||
$this->rows[$column] = $row;
|
||||
@@ -275,31 +306,43 @@ class Table
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->calculateNumberOfColumns();
|
||||
$rows = $this->buildTableRows($this->rows);
|
||||
$headers = $this->buildTableRows($this->headers);
|
||||
$rows = array_merge($this->headers, array($divider = new TableSeparator()), $this->rows);
|
||||
$this->calculateNumberOfColumns($rows);
|
||||
|
||||
$this->calculateColumnsWidth(array_merge($headers, $rows));
|
||||
$rows = $this->buildTableRows($rows);
|
||||
$this->calculateColumnsWidth($rows);
|
||||
|
||||
$this->renderRowSeparator();
|
||||
if (!empty($headers)) {
|
||||
foreach ($headers as $header) {
|
||||
$this->renderRow($header, $this->style->getCellHeaderFormat());
|
||||
$this->renderRowSeparator();
|
||||
}
|
||||
}
|
||||
$isHeader = true;
|
||||
$isFirstRow = false;
|
||||
foreach ($rows as $row) {
|
||||
if ($divider === $row) {
|
||||
$isHeader = false;
|
||||
$isFirstRow = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($row instanceof TableSeparator) {
|
||||
$this->renderRowSeparator();
|
||||
} else {
|
||||
$this->renderRow($row, $this->style->getCellRowFormat());
|
||||
|
||||
continue;
|
||||
}
|
||||
if (!$row) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($isHeader || $isFirstRow) {
|
||||
$this->renderRowSeparator($isFirstRow ? self::SEPARATOR_TOP_BOTTOM : self::SEPARATOR_TOP);
|
||||
if ($isFirstRow) {
|
||||
$isFirstRow = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
|
||||
}
|
||||
if (!empty($rows)) {
|
||||
$this->renderRowSeparator();
|
||||
}
|
||||
$this->renderRowSeparator(self::SEPARATOR_BOTTOM);
|
||||
|
||||
$this->cleanup();
|
||||
$this->rendered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,19 +350,32 @@ class Table
|
||||
*
|
||||
* Example: <code>+-----+-----------+-------+</code>
|
||||
*/
|
||||
private function renderRowSeparator()
|
||||
private function renderRowSeparator(int $type = self::SEPARATOR_MID)
|
||||
{
|
||||
if (0 === $count = $this->numberOfColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
|
||||
$borders = $this->style->getBorderChars();
|
||||
if (!$borders[0] && !$borders[2] && !$this->style->getCrossingChar()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$markup = $this->style->getCrossingChar();
|
||||
$crossings = $this->style->getCrossingChars();
|
||||
if (self::SEPARATOR_MID === $type) {
|
||||
list($horizontal, $leftChar, $midChar, $rightChar) = array($borders[2], $crossings[8], $crossings[0], $crossings[4]);
|
||||
} elseif (self::SEPARATOR_TOP === $type) {
|
||||
list($horizontal, $leftChar, $midChar, $rightChar) = array($borders[0], $crossings[1], $crossings[2], $crossings[3]);
|
||||
} elseif (self::SEPARATOR_TOP_BOTTOM === $type) {
|
||||
list($horizontal, $leftChar, $midChar, $rightChar) = array($borders[0], $crossings[9], $crossings[10], $crossings[11]);
|
||||
} else {
|
||||
list($horizontal, $leftChar, $midChar, $rightChar) = array($borders[0], $crossings[7], $crossings[6], $crossings[5]);
|
||||
}
|
||||
|
||||
$markup = $leftChar;
|
||||
for ($column = 0; $column < $count; ++$column) {
|
||||
$markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->effectiveColumnWidths[$column]).$this->style->getCrossingChar();
|
||||
$markup .= str_repeat($horizontal, $this->effectiveColumnWidths[$column]);
|
||||
$markup .= $column === $count - 1 ? $rightChar : $midChar;
|
||||
}
|
||||
|
||||
$this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
|
||||
@@ -328,41 +384,34 @@ class Table
|
||||
/**
|
||||
* Renders vertical column separator.
|
||||
*/
|
||||
private function renderColumnSeparator()
|
||||
private function renderColumnSeparator($type = self::BORDER_OUTSIDE)
|
||||
{
|
||||
return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
|
||||
$borders = $this->style->getBorderChars();
|
||||
|
||||
return sprintf($this->style->getBorderFormat(), self::BORDER_OUTSIDE === $type ? $borders[1] : $borders[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders table row.
|
||||
*
|
||||
* Example: <code>| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |</code>
|
||||
*
|
||||
* @param array $row
|
||||
* @param string $cellFormat
|
||||
*/
|
||||
private function renderRow(array $row, $cellFormat)
|
||||
private function renderRow(array $row, string $cellFormat)
|
||||
{
|
||||
if (empty($row)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rowContent = $this->renderColumnSeparator();
|
||||
foreach ($this->getRowColumns($row) as $column) {
|
||||
$rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE);
|
||||
$columns = $this->getRowColumns($row);
|
||||
$last = \count($columns) - 1;
|
||||
foreach ($columns as $i => $column) {
|
||||
$rowContent .= $this->renderCell($row, $column, $cellFormat);
|
||||
$rowContent .= $this->renderColumnSeparator();
|
||||
$rowContent .= $this->renderColumnSeparator($last === $i ? self::BORDER_OUTSIDE : self::BORDER_INSIDE);
|
||||
}
|
||||
$this->output->writeln($rowContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders table cell with padding.
|
||||
*
|
||||
* @param array $row
|
||||
* @param int $column
|
||||
* @param string $cellFormat
|
||||
*/
|
||||
private function renderCell(array $row, $column, $cellFormat)
|
||||
private function renderCell(array $row, int $column, string $cellFormat)
|
||||
{
|
||||
$cell = isset($row[$column]) ? $row[$column] : '';
|
||||
$width = $this->effectiveColumnWidths[$column];
|
||||
@@ -381,7 +430,7 @@ class Table
|
||||
$style = $this->getColumnStyle($column);
|
||||
|
||||
if ($cell instanceof TableSeparator) {
|
||||
return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
|
||||
return sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
|
||||
}
|
||||
|
||||
$width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
|
||||
@@ -393,14 +442,10 @@ class Table
|
||||
/**
|
||||
* Calculate number of columns for this table.
|
||||
*/
|
||||
private function calculateNumberOfColumns()
|
||||
private function calculateNumberOfColumns($rows)
|
||||
{
|
||||
if (null !== $this->numberOfColumns) {
|
||||
return;
|
||||
}
|
||||
|
||||
$columns = array(0);
|
||||
foreach (array_merge($this->headers, $this->rows) as $row) {
|
||||
foreach ($rows as $row) {
|
||||
if ($row instanceof TableSeparator) {
|
||||
continue;
|
||||
}
|
||||
@@ -436,28 +481,38 @@ class Table
|
||||
}
|
||||
}
|
||||
|
||||
$tableRows = array();
|
||||
foreach ($rows as $rowKey => $row) {
|
||||
$tableRows[] = $this->fillCells($row);
|
||||
if (isset($unmergedRows[$rowKey])) {
|
||||
$tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
|
||||
return new TableRows(function () use ($rows, $unmergedRows) {
|
||||
foreach ($rows as $rowKey => $row) {
|
||||
yield $this->fillCells($row);
|
||||
|
||||
if (isset($unmergedRows[$rowKey])) {
|
||||
foreach ($unmergedRows[$rowKey] as $row) {
|
||||
yield $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function calculateRowCount(): int
|
||||
{
|
||||
$numberOfRows = \count(iterator_to_array($this->buildTableRows(array_merge($this->headers, array(new TableSeparator()), $this->rows))));
|
||||
|
||||
if ($this->headers) {
|
||||
++$numberOfRows; // Add row for header separator
|
||||
}
|
||||
|
||||
return $tableRows;
|
||||
++$numberOfRows; // Add row for footer separator
|
||||
|
||||
return $numberOfRows;
|
||||
}
|
||||
|
||||
/**
|
||||
* fill rows that contains rowspan > 1.
|
||||
*
|
||||
* @param array $rows
|
||||
* @param int $line
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function fillNextRows(array $rows, $line)
|
||||
private function fillNextRows(array $rows, int $line): array
|
||||
{
|
||||
$unmergedRows = array();
|
||||
foreach ($rows[$line] as $column => $cell) {
|
||||
@@ -510,8 +565,6 @@ class Table
|
||||
|
||||
/**
|
||||
* fill cells for a row that contains colspan > 1.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function fillCells($row)
|
||||
{
|
||||
@@ -529,13 +582,7 @@ class Table
|
||||
return $newRow ?: $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rows
|
||||
* @param int $line
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function copyRow(array $rows, $line)
|
||||
private function copyRow(array $rows, int $line): array
|
||||
{
|
||||
$row = $rows[$line];
|
||||
foreach ($row as $cellKey => $cellValue) {
|
||||
@@ -550,10 +597,8 @@ class Table
|
||||
|
||||
/**
|
||||
* Gets number of columns by row.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getNumberOfColumns(array $row)
|
||||
private function getNumberOfColumns(array $row): int
|
||||
{
|
||||
$columns = \count($row);
|
||||
foreach ($row as $column) {
|
||||
@@ -565,10 +610,8 @@ class Table
|
||||
|
||||
/**
|
||||
* Gets list of columns for the given row.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getRowColumns(array $row)
|
||||
private function getRowColumns(array $row): array
|
||||
{
|
||||
$columns = range(0, $this->numberOfColumns - 1);
|
||||
foreach ($row as $cellKey => $cell) {
|
||||
@@ -584,7 +627,7 @@ class Table
|
||||
/**
|
||||
* Calculates columns widths.
|
||||
*/
|
||||
private function calculateColumnsWidth(array $rows)
|
||||
private function calculateColumnsWidth(iterable $rows)
|
||||
{
|
||||
for ($column = 0; $column < $this->numberOfColumns; ++$column) {
|
||||
$lengths = array();
|
||||
@@ -613,25 +656,12 @@ class Table
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets column width.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getColumnSeparatorWidth()
|
||||
private function getColumnSeparatorWidth(): int
|
||||
{
|
||||
return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
|
||||
return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets cell width.
|
||||
*
|
||||
* @param array $row
|
||||
* @param int $column
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getCellWidth(array $row, $column)
|
||||
private function getCellWidth(array $row, int $column): int
|
||||
{
|
||||
$cellWidth = 0;
|
||||
|
||||
@@ -658,32 +688,46 @@ class Table
|
||||
{
|
||||
$borderless = new TableStyle();
|
||||
$borderless
|
||||
->setHorizontalBorderChar('=')
|
||||
->setVerticalBorderChar(' ')
|
||||
->setCrossingChar(' ')
|
||||
->setHorizontalBorderChars('=')
|
||||
->setVerticalBorderChars(' ')
|
||||
->setDefaultCrossingChar(' ')
|
||||
;
|
||||
|
||||
$compact = new TableStyle();
|
||||
$compact
|
||||
->setHorizontalBorderChar('')
|
||||
->setVerticalBorderChar(' ')
|
||||
->setCrossingChar('')
|
||||
->setHorizontalBorderChars('')
|
||||
->setVerticalBorderChars(' ')
|
||||
->setDefaultCrossingChar('')
|
||||
->setCellRowContentFormat('%s')
|
||||
;
|
||||
|
||||
$styleGuide = new TableStyle();
|
||||
$styleGuide
|
||||
->setHorizontalBorderChar('-')
|
||||
->setVerticalBorderChar(' ')
|
||||
->setCrossingChar(' ')
|
||||
->setHorizontalBorderChars('-')
|
||||
->setVerticalBorderChars(' ')
|
||||
->setDefaultCrossingChar(' ')
|
||||
->setCellHeaderFormat('%s')
|
||||
;
|
||||
|
||||
$box = (new TableStyle())
|
||||
->setHorizontalBorderChars('─')
|
||||
->setVerticalBorderChars('│')
|
||||
->setCrossingChars('┼', '┌', '┬', '┐', '┤', '┘', '┴', '└', '├')
|
||||
;
|
||||
|
||||
$boxDouble = (new TableStyle())
|
||||
->setHorizontalBorderChars('═', '─')
|
||||
->setVerticalBorderChars('║', '│')
|
||||
->setCrossingChars('┼', '╔', '╤', '╗', '╢', '╝', '╧', '╚', '╟', '╠', '╪', '╣')
|
||||
;
|
||||
|
||||
return array(
|
||||
'default' => new TableStyle(),
|
||||
'borderless' => $borderless,
|
||||
'compact' => $compact,
|
||||
'symfony-style-guide' => $styleGuide,
|
||||
'box' => $box,
|
||||
'box-double' => $boxDouble,
|
||||
);
|
||||
}
|
||||
|
||||
|
10
vendor/symfony/console/Helper/TableCell.php
vendored
10
vendor/symfony/console/Helper/TableCell.php
vendored
@@ -24,16 +24,8 @@ class TableCell
|
||||
'colspan' => 1,
|
||||
);
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct($value = '', array $options = array())
|
||||
public function __construct(string $value = '', array $options = array())
|
||||
{
|
||||
if (is_numeric($value) && !\is_string($value)) {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
|
||||
// check option names
|
||||
|
32
vendor/symfony/console/Helper/TableRows.php
vendored
Normal file
32
vendor/symfony/console/Helper/TableRows.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class TableRows implements \IteratorAggregate
|
||||
{
|
||||
private $generator;
|
||||
|
||||
public function __construct(callable $generator)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
$g = $this->generator;
|
||||
|
||||
return $g();
|
||||
}
|
||||
}
|
194
vendor/symfony/console/Helper/TableStyle.php
vendored
194
vendor/symfony/console/Helper/TableStyle.php
vendored
@@ -19,13 +19,27 @@ use Symfony\Component\Console\Exception\LogicException;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Саша Стаменковић <umpirsky@gmail.com>
|
||||
* @author Dany Maillard <danymaillard93b@gmail.com>
|
||||
*/
|
||||
class TableStyle
|
||||
{
|
||||
private $paddingChar = ' ';
|
||||
private $horizontalBorderChar = '-';
|
||||
private $verticalBorderChar = '|';
|
||||
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 $cellHeaderFormat = '<info>%s</info>';
|
||||
private $cellRowFormat = '%s';
|
||||
private $cellRowContentFormat = ' %s ';
|
||||
@@ -60,28 +74,85 @@ class TableStyle
|
||||
return $this->paddingChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets horizontal border characters.
|
||||
*
|
||||
* <code>
|
||||
* ╔═══════════════╤══════════════════════════╤══════════════════╗
|
||||
* 1 ISBN 2 Title │ Author ║
|
||||
* ╠═══════════════╪══════════════════════════╪══════════════════╣
|
||||
* ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
|
||||
* ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
|
||||
* ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
|
||||
* ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
|
||||
* ╚═══════════════╧══════════════════════════╧══════════════════╝
|
||||
* </code>
|
||||
*
|
||||
* @param string $outside Outside border char (see #1 of example)
|
||||
* @param string|null $inside Inside border char (see #2 of example), equals $outside if null
|
||||
*/
|
||||
public function setHorizontalBorderChars(string $outside, string $inside = null): self
|
||||
{
|
||||
$this->horizontalOutsideBorderChar = $outside;
|
||||
$this->horizontalInsideBorderChar = $inside ?? $outside;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets horizontal border character.
|
||||
*
|
||||
* @param string $horizontalBorderChar
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated since Symfony 4.1, use {@link setHorizontalBorderChars()} instead.
|
||||
*/
|
||||
public function setHorizontalBorderChar($horizontalBorderChar)
|
||||
{
|
||||
$this->horizontalBorderChar = $horizontalBorderChar;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this;
|
||||
return $this->setHorizontalBorderChars($horizontalBorderChar, $horizontalBorderChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets horizontal border character.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated since Symfony 4.1, use {@link getBorderChars()} instead.
|
||||
*/
|
||||
public function getHorizontalBorderChar()
|
||||
{
|
||||
return $this->horizontalBorderChar;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->horizontalOutsideBorderChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets vertical border characters.
|
||||
*
|
||||
* <code>
|
||||
* ╔═══════════════╤══════════════════════════╤══════════════════╗
|
||||
* ║ ISBN │ Title │ Author ║
|
||||
* ╠═══════1═══════╪══════════════════════════╪══════════════════╣
|
||||
* ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
|
||||
* ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
|
||||
* ╟───────2───────┼──────────────────────────┼──────────────────╢
|
||||
* ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
|
||||
* ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
|
||||
* ╚═══════════════╧══════════════════════════╧══════════════════╝
|
||||
* </code>
|
||||
*
|
||||
* @param string $outside Outside border char (see #1 of example)
|
||||
* @param string|null $inside Inside border char (see #2 of example), equals $outside if null
|
||||
*/
|
||||
public function setVerticalBorderChars(string $outside, string $inside = null): self
|
||||
{
|
||||
$this->verticalOutsideBorderChar = $outside;
|
||||
$this->verticalInsideBorderChar = $inside ?? $outside;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,22 +161,100 @@ class TableStyle
|
||||
* @param string $verticalBorderChar
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated since Symfony 4.1, use {@link setVerticalBorderChars()} instead.
|
||||
*/
|
||||
public function setVerticalBorderChar($verticalBorderChar)
|
||||
{
|
||||
$this->verticalBorderChar = $verticalBorderChar;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setVerticalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this;
|
||||
return $this->setVerticalBorderChars($verticalBorderChar, $verticalBorderChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets vertical border character.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated since Symfony 4.1, use {@link getBorderChars()} instead.
|
||||
*/
|
||||
public function getVerticalBorderChar()
|
||||
{
|
||||
return $this->verticalBorderChar;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->verticalOutsideBorderChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets border characters.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getBorderChars()
|
||||
{
|
||||
return array(
|
||||
$this->horizontalOutsideBorderChar,
|
||||
$this->verticalOutsideBorderChar,
|
||||
$this->horizontalInsideBorderChar,
|
||||
$this->verticalInsideBorderChar,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets crossing characters.
|
||||
*
|
||||
* Example:
|
||||
* <code>
|
||||
* 1═══════════════2══════════════════════════2══════════════════3
|
||||
* ║ ISBN │ Title │ Author ║
|
||||
* 8'══════════════0'═════════════════════════0'═════════════════4'
|
||||
* ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
|
||||
* ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
|
||||
* 8───────────────0──────────────────────────0──────────────────4
|
||||
* ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
|
||||
* ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
|
||||
* 7═══════════════6══════════════════════════6══════════════════5
|
||||
* </code>
|
||||
*
|
||||
* @param string $cross Crossing char (see #0 of example)
|
||||
* @param string $topLeft Top left char (see #1 of example)
|
||||
* @param string $topMid Top mid char (see #2 of example)
|
||||
* @param string $topRight Top right char (see #3 of example)
|
||||
* @param string $midRight Mid right char (see #4 of example)
|
||||
* @param string $bottomRight Bottom right char (see #5 of example)
|
||||
* @param string $bottomMid Bottom mid char (see #6 of example)
|
||||
* @param string $bottomLeft Bottom left char (see #7 of example)
|
||||
* @param string $midLeft Mid left char (see #8 of example)
|
||||
* @param string|null $topLeftBottom Top left bottom char (see #8' of example), equals to $midLeft if null
|
||||
* @param string|null $topMidBottom Top mid bottom char (see #0' of example), equals to $cross if null
|
||||
* @param string|null $topRightBottom Top right bottom char (see #4' of example), equals to $midRight if null
|
||||
*/
|
||||
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
|
||||
{
|
||||
$this->crossingChar = $cross;
|
||||
$this->crossingTopLeftChar = $topLeft;
|
||||
$this->crossingTopMidChar = $topMid;
|
||||
$this->crossingTopRightChar = $topRight;
|
||||
$this->crossingMidRightChar = $midRight;
|
||||
$this->crossingBottomRightChar = $bottomRight;
|
||||
$this->crossingBottomMidChar = $bottomMid;
|
||||
$this->crossingBottomLeftChar = $bottomLeft;
|
||||
$this->crossingMidLeftChar = $midLeft;
|
||||
$this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft;
|
||||
$this->crossingTopMidBottomChar = $topMidBottom ?? $cross;
|
||||
$this->crossingTopRightBottomChar = $topRightBottom ?? $midRight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default crossing character used for each cross.
|
||||
*
|
||||
* @see {@link setCrossingChars()} for setting each crossing individually.
|
||||
*/
|
||||
public function setDefaultCrossingChar(string $char): self
|
||||
{
|
||||
return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,12 +263,14 @@ class TableStyle
|
||||
* @param string $crossingChar
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @deprecated since Symfony 4.1. Use {@link setDefaultCrossingChar()} instead.
|
||||
*/
|
||||
public function setCrossingChar($crossingChar)
|
||||
{
|
||||
$this->crossingChar = $crossingChar;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this;
|
||||
return $this->setDefaultCrossingChar($crossingChar);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +283,29 @@ class TableStyle
|
||||
return $this->crossingChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets crossing characters.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getCrossingChars(): array
|
||||
{
|
||||
return array(
|
||||
$this->crossingChar,
|
||||
$this->crossingTopLeftChar,
|
||||
$this->crossingTopMidChar,
|
||||
$this->crossingTopRightChar,
|
||||
$this->crossingMidRightChar,
|
||||
$this->crossingBottomRightChar,
|
||||
$this->crossingBottomMidChar,
|
||||
$this->crossingBottomLeftChar,
|
||||
$this->crossingMidLeftChar,
|
||||
$this->crossingTopLeftBottomChar,
|
||||
$this->crossingTopMidBottomChar,
|
||||
$this->crossingTopRightBottomChar,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets header cell format.
|
||||
*
|
||||
|
5
vendor/symfony/console/Input/ArgvInput.php
vendored
5
vendor/symfony/console/Input/ArgvInput.php
vendored
@@ -146,11 +146,6 @@ class ArgvInput extends Input
|
||||
|
||||
if (false !== $pos = strpos($name, '=')) {
|
||||
if (0 === \strlen($value = substr($name, $pos + 1))) {
|
||||
// if no value after "=" then substr() returns "" since php7 only, false before
|
||||
// see http://php.net/manual/fr/migration70.incompatible.php#119151
|
||||
if (\PHP_VERSION_ID < 70000 && false === $value) {
|
||||
$value = '';
|
||||
}
|
||||
array_unshift($this->parsed, $value);
|
||||
}
|
||||
$this->addLongOption(substr($name, 0, $pos), $value);
|
||||
|
@@ -38,11 +38,11 @@ class InputArgument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument mode is not valid
|
||||
*/
|
||||
public function __construct($name, $mode = null, $description = '', $default = null)
|
||||
public function __construct(string $name, int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
if (null === $mode) {
|
||||
$mode = self::OPTIONAL;
|
||||
} elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
|
||||
} elseif ($mode > 7 || $mode < 1) {
|
||||
throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
|
||||
}
|
||||
|
||||
|
14
vendor/symfony/console/Input/InputDefinition.php
vendored
14
vendor/symfony/console/Input/InputDefinition.php
vendored
@@ -382,21 +382,21 @@ class InputDefinition
|
||||
$elements[] = '[--]';
|
||||
}
|
||||
|
||||
$tail = '';
|
||||
foreach ($this->getArguments() as $argument) {
|
||||
$element = '<'.$argument->getName().'>';
|
||||
if (!$argument->isRequired()) {
|
||||
$element = '['.$element.']';
|
||||
} elseif ($argument->isArray()) {
|
||||
$element = $element.' ('.$element.')';
|
||||
}
|
||||
|
||||
if ($argument->isArray()) {
|
||||
$element .= '...';
|
||||
}
|
||||
|
||||
if (!$argument->isRequired()) {
|
||||
$element = '['.$element;
|
||||
$tail .= ']';
|
||||
}
|
||||
|
||||
$elements[] = $element;
|
||||
}
|
||||
|
||||
return implode(' ', $elements);
|
||||
return implode(' ', $elements).$tail;
|
||||
}
|
||||
}
|
||||
|
4
vendor/symfony/console/Input/InputOption.php
vendored
4
vendor/symfony/console/Input/InputOption.php
vendored
@@ -41,7 +41,7 @@ class InputOption
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
|
||||
public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
if (0 === strpos($name, '--')) {
|
||||
$name = substr($name, 2);
|
||||
@@ -70,7 +70,7 @@ class InputOption
|
||||
|
||||
if (null === $mode) {
|
||||
$mode = self::VALUE_NONE;
|
||||
} elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
|
||||
} elseif ($mode > 15 || $mode < 1) {
|
||||
throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
|
||||
}
|
||||
|
||||
|
2
vendor/symfony/console/Input/StringInput.php
vendored
2
vendor/symfony/console/Input/StringInput.php
vendored
@@ -30,7 +30,7 @@ class StringInput extends ArgvInput
|
||||
/**
|
||||
* @param string $input A string representing the parameters from the CLI
|
||||
*/
|
||||
public function __construct($input)
|
||||
public function __construct(string $input)
|
||||
{
|
||||
parent::__construct(array());
|
||||
|
||||
|
@@ -99,13 +99,8 @@ class ConsoleLogger extends AbstractLogger
|
||||
* Interpolates context values into the message placeholders.
|
||||
*
|
||||
* @author PHP Framework Interoperability Group
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function interpolate($message, array $context)
|
||||
private function interpolate(string $message, array $context): string
|
||||
{
|
||||
if (false === strpos($message, '{')) {
|
||||
return $message;
|
||||
|
11
vendor/symfony/console/Output/ConsoleOutput.php
vendored
11
vendor/symfony/console/Output/ConsoleOutput.php
vendored
@@ -30,13 +30,14 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
{
|
||||
private $stderr;
|
||||
private $consoleSectionOutputs = array();
|
||||
|
||||
/**
|
||||
* @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
|
||||
* @param bool|null $decorated Whether to decorate messages (null for auto-guessing)
|
||||
* @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
|
||||
*/
|
||||
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
|
||||
|
||||
@@ -48,6 +49,14 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new output section.
|
||||
*/
|
||||
public function section(): ConsoleSectionOutput
|
||||
{
|
||||
return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@@ -13,9 +13,11 @@ namespace Symfony\Component\Console\Output;
|
||||
|
||||
/**
|
||||
* ConsoleOutputInterface is the interface implemented by ConsoleOutput class.
|
||||
* This adds information about stderr output stream.
|
||||
* This adds information about stderr and section output stream.
|
||||
*
|
||||
* @author Dariusz Górecki <darek.krk@gmail.com>
|
||||
*
|
||||
* @method ConsoleSectionOutput section() Creates a new output section
|
||||
*/
|
||||
interface ConsoleOutputInterface extends OutputInterface
|
||||
{
|
||||
|
133
vendor/symfony/console/Output/ConsoleSectionOutput.php
vendored
Normal file
133
vendor/symfony/console/Output/ConsoleSectionOutput.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?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\Output;
|
||||
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
use Symfony\Component\Console\Helper\Helper;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
/**
|
||||
* @author Pierre du Plessis <pdples@gmail.com>
|
||||
* @author Gabriel Ostrolucký <gabriel.ostrolucky@gmail.com>
|
||||
*/
|
||||
class ConsoleSectionOutput extends StreamOutput
|
||||
{
|
||||
private $content = array();
|
||||
private $lines = 0;
|
||||
private $sections;
|
||||
private $terminal;
|
||||
|
||||
/**
|
||||
* @param resource $stream
|
||||
* @param ConsoleSectionOutput[] $sections
|
||||
*/
|
||||
public function __construct($stream, array &$sections, int $verbosity, bool $decorated, OutputFormatterInterface $formatter)
|
||||
{
|
||||
parent::__construct($stream, $verbosity, $decorated, $formatter);
|
||||
array_unshift($sections, $this);
|
||||
$this->sections = &$sections;
|
||||
$this->terminal = new Terminal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears previous output for this section.
|
||||
*
|
||||
* @param int $lines Number of lines to clear. If null, then the entire output of this section is cleared
|
||||
*/
|
||||
public function clear(int $lines = null)
|
||||
{
|
||||
if (empty($this->content) || !$this->isDecorated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($lines) {
|
||||
\array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content
|
||||
} else {
|
||||
$lines = $this->lines;
|
||||
$this->content = array();
|
||||
}
|
||||
|
||||
$this->lines -= $lines;
|
||||
|
||||
parent::doWrite($this->popStreamContentUntilCurrentSection($lines), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites the previous output with a new message.
|
||||
*
|
||||
* @param array|string $message
|
||||
*/
|
||||
public function overwrite($message)
|
||||
{
|
||||
$this->clear();
|
||||
$this->writeln($message);
|
||||
}
|
||||
|
||||
public function getContent(): string
|
||||
{
|
||||
return implode('', $this->content);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWrite($message, $newline)
|
||||
{
|
||||
if (!$this->isDecorated()) {
|
||||
return parent::doWrite($message, $newline);
|
||||
}
|
||||
|
||||
$erasedContent = $this->popStreamContentUntilCurrentSection();
|
||||
|
||||
foreach (explode(PHP_EOL, $message) as $lineContent) {
|
||||
$this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1;
|
||||
$this->content[] = $lineContent;
|
||||
$this->content[] = PHP_EOL;
|
||||
}
|
||||
|
||||
parent::doWrite($message, true);
|
||||
parent::doWrite($erasedContent, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* At initial stage, cursor is at the end of stream output. This method makes cursor crawl upwards until it hits
|
||||
* current section. Then it erases content it crawled through. Optionally, it erases part of current section too.
|
||||
*/
|
||||
private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0): string
|
||||
{
|
||||
$numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
|
||||
$erasedContent = array();
|
||||
|
||||
foreach ($this->sections as $section) {
|
||||
if ($section === $this) {
|
||||
break;
|
||||
}
|
||||
|
||||
$numberOfLinesToClear += $section->lines;
|
||||
$erasedContent[] = $section->getContent();
|
||||
}
|
||||
|
||||
if ($numberOfLinesToClear > 0) {
|
||||
// move cursor up n lines
|
||||
parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
|
||||
// erase to end of screen
|
||||
parent::doWrite("\x1b[0J", false);
|
||||
}
|
||||
|
||||
return implode('', array_reverse($erasedContent));
|
||||
}
|
||||
|
||||
private function getDisplayLength(string $text): string
|
||||
{
|
||||
return Helper::strlenWithoutDecoration($this->getFormatter(), str_replace("\t", ' ', $text));
|
||||
}
|
||||
}
|
6
vendor/symfony/console/Output/Output.php
vendored
6
vendor/symfony/console/Output/Output.php
vendored
@@ -37,7 +37,7 @@ abstract class Output implements OutputInterface
|
||||
* @param bool $decorated Whether to decorate messages
|
||||
* @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
|
||||
*/
|
||||
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
|
||||
public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
$this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
|
||||
$this->formatter = $formatter ?: new OutputFormatter();
|
||||
@@ -137,7 +137,9 @@ abstract class Output implements OutputInterface
|
||||
*/
|
||||
public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
|
||||
{
|
||||
$messages = (array) $messages;
|
||||
if (!is_iterable($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
|
||||
$types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
|
||||
$type = $types & $options ?: self::OUTPUT_NORMAL;
|
||||
|
@@ -33,17 +33,17 @@ interface OutputInterface
|
||||
/**
|
||||
* Writes a message to the output.
|
||||
*
|
||||
* @param string|array $messages The message as an array of strings or a single string
|
||||
* @param bool $newline Whether to add a newline
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
* @param string|iterable $messages The message as an iterable of strings or a single string
|
||||
* @param bool $newline Whether to add a newline
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
public function write($messages, $newline = false, $options = 0);
|
||||
|
||||
/**
|
||||
* Writes a message to the output and adds a newline at the end.
|
||||
*
|
||||
* @param string|array $messages The message as an array of strings or a single string
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
* @param string|iterable $messages The message as an iterable of strings or a single string
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
public function writeln($messages, $options = 0);
|
||||
|
||||
|
@@ -40,7 +40,7 @@ class StreamOutput extends Output
|
||||
*
|
||||
* @throws InvalidArgumentException When first argument is not a real stream
|
||||
*/
|
||||
public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
|
||||
throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
|
||||
|
@@ -30,7 +30,7 @@ class ChoiceQuestion extends Question
|
||||
* @param array $choices The list of available choices
|
||||
* @param mixed $default The default answer to return
|
||||
*/
|
||||
public function __construct($question, array $choices, $default = null)
|
||||
public function __construct(string $question, array $choices, $default = null)
|
||||
{
|
||||
if (!$choices) {
|
||||
throw new \LogicException('Choice question must have at least 1 choice available.');
|
||||
@@ -121,12 +121,7 @@ class ChoiceQuestion extends Question
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default answer validator.
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
private function getDefaultValidator()
|
||||
private function getDefaultValidator(): callable
|
||||
{
|
||||
$choices = $this->choices;
|
||||
$errorMessage = $this->errorMessage;
|
||||
|
@@ -25,9 +25,9 @@ class ConfirmationQuestion extends Question
|
||||
* @param bool $default The default answer to return, true or false
|
||||
* @param string $trueAnswerRegex A regex to match the "yes" answer
|
||||
*/
|
||||
public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
|
||||
public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i')
|
||||
{
|
||||
parent::__construct($question, (bool) $default);
|
||||
parent::__construct($question, $default);
|
||||
|
||||
$this->trueAnswerRegex = $trueAnswerRegex;
|
||||
$this->setNormalizer($this->getDefaultNormalizer());
|
||||
|
2
vendor/symfony/console/Question/Question.php
vendored
2
vendor/symfony/console/Question/Question.php
vendored
@@ -34,7 +34,7 @@ class Question
|
||||
* @param string $question The question to ask to the user
|
||||
* @param mixed $default The default answer to return if the user enters nothing
|
||||
*/
|
||||
public function __construct($question, $default = null)
|
||||
public function __construct(string $question, $default = null)
|
||||
{
|
||||
$this->question = $question;
|
||||
$this->default = $default;
|
||||
|
41
vendor/symfony/console/Style/SymfonyStyle.php
vendored
41
vendor/symfony/console/Style/SymfonyStyle.php
vendored
@@ -306,8 +306,14 @@ class SymfonyStyle extends OutputStyle
|
||||
*/
|
||||
public function writeln($messages, $type = self::OUTPUT_NORMAL)
|
||||
{
|
||||
parent::writeln($messages, $type);
|
||||
$this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
|
||||
if (!is_iterable($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
|
||||
foreach ($messages as $message) {
|
||||
parent::writeln($message, $type);
|
||||
$this->writeBuffer($message, true, $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,8 +321,14 @@ class SymfonyStyle extends OutputStyle
|
||||
*/
|
||||
public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
|
||||
{
|
||||
parent::write($messages, $newline, $type);
|
||||
$this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
|
||||
if (!is_iterable($messages)) {
|
||||
$messages = array($messages);
|
||||
}
|
||||
|
||||
foreach ($messages as $message) {
|
||||
parent::write($message, $newline, $type);
|
||||
$this->writeBuffer($message, $newline, $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,10 +350,7 @@ class SymfonyStyle extends OutputStyle
|
||||
return new self($this->input, $this->getErrorOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProgressBar
|
||||
*/
|
||||
private function getProgressBar()
|
||||
private function getProgressBar(): ProgressBar
|
||||
{
|
||||
if (!$this->progressBar) {
|
||||
throw new RuntimeException('The ProgressBar is not started.');
|
||||
@@ -350,18 +359,20 @@ class SymfonyStyle extends OutputStyle
|
||||
return $this->progressBar;
|
||||
}
|
||||
|
||||
private function autoPrependBlock()
|
||||
private function autoPrependBlock(): void
|
||||
{
|
||||
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
|
||||
|
||||
if (!isset($chars[0])) {
|
||||
return $this->newLine(); //empty history, so we should start with a new line.
|
||||
$this->newLine(); //empty history, so we should start with a new line.
|
||||
|
||||
return;
|
||||
}
|
||||
//Prepend new line for each non LF chars (This means no blank line was output before)
|
||||
$this->newLine(2 - substr_count($chars, "\n"));
|
||||
}
|
||||
|
||||
private function autoPrependText()
|
||||
private function autoPrependText(): void
|
||||
{
|
||||
$fetched = $this->bufferedOutput->fetch();
|
||||
//Prepend new line if last char isn't EOL:
|
||||
@@ -370,16 +381,14 @@ class SymfonyStyle extends OutputStyle
|
||||
}
|
||||
}
|
||||
|
||||
private function reduceBuffer($messages)
|
||||
private function writeBuffer(string $message, bool $newLine, int $type): void
|
||||
{
|
||||
// We need to know if the two last chars are PHP_EOL
|
||||
// Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer
|
||||
return array_map(function ($value) {
|
||||
return substr($value, -4);
|
||||
}, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
|
||||
$this->bufferedOutput->write(substr($message, -4), $newLine, $type);
|
||||
}
|
||||
|
||||
private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
|
||||
private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false)
|
||||
{
|
||||
$indentLength = 0;
|
||||
$prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
|
||||
|
@@ -13,9 +13,7 @@ namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
@@ -30,13 +28,11 @@ use Symfony\Component\Console\Output\StreamOutput;
|
||||
*/
|
||||
class ApplicationTester
|
||||
{
|
||||
use TesterTrait;
|
||||
|
||||
private $application;
|
||||
private $input;
|
||||
private $statusCode;
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private $output;
|
||||
private $captureStreamsIndependently = false;
|
||||
|
||||
public function __construct(Application $application)
|
||||
@@ -66,6 +62,13 @@ class ApplicationTester
|
||||
$this->input->setInteractive($options['interactive']);
|
||||
}
|
||||
|
||||
$shellInteractive = getenv('SHELL_INTERACTIVE');
|
||||
|
||||
if ($this->inputs) {
|
||||
$this->input->setStream(self::createStream($this->inputs));
|
||||
putenv('SHELL_INTERACTIVE=1');
|
||||
}
|
||||
|
||||
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
@@ -97,27 +100,11 @@ class ApplicationTester
|
||||
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
|
||||
}
|
||||
|
||||
return $this->statusCode = $this->application->run($this->input, $this->output);
|
||||
}
|
||||
$this->statusCode = $this->application->run($this->input, $this->output);
|
||||
|
||||
/**
|
||||
* Gets the display returned by the last execution of the application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string The display
|
||||
*/
|
||||
public function getDisplay($normalize = false)
|
||||
{
|
||||
rewind($this->output->getStream());
|
||||
putenv($shellInteractive ? "SHELL_INTERACTIVE=$shellInteractive" : 'SHELL_INTERACTIVE');
|
||||
|
||||
$display = stream_get_contents($this->output->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,34 +130,4 @@ class ApplicationTester
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input instance used by the last execution of the application.
|
||||
*
|
||||
* @return InputInterface The current input instance
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output instance used by the last execution of the application.
|
||||
*
|
||||
* @return OutputInterface The current output instance
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code returned by the last execution of the application.
|
||||
*
|
||||
* @return int The status code
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
}
|
||||
|
81
vendor/symfony/console/Tester/CommandTester.php
vendored
81
vendor/symfony/console/Tester/CommandTester.php
vendored
@@ -13,8 +13,6 @@ namespace Symfony\Component\Console\Tester;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
@@ -25,10 +23,10 @@ use Symfony\Component\Console\Output\StreamOutput;
|
||||
*/
|
||||
class CommandTester
|
||||
{
|
||||
use TesterTrait;
|
||||
|
||||
private $command;
|
||||
private $input;
|
||||
private $output;
|
||||
private $inputs = array();
|
||||
private $statusCode;
|
||||
|
||||
public function __construct(Command $command)
|
||||
@@ -78,79 +76,4 @@ class CommandTester
|
||||
|
||||
return $this->statusCode = $this->command->run($this->input, $this->output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display returned by the last execution of the command.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string The display
|
||||
*/
|
||||
public function getDisplay($normalize = false)
|
||||
{
|
||||
rewind($this->output->getStream());
|
||||
|
||||
$display = stream_get_contents($this->output->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input instance used by the last execution of the command.
|
||||
*
|
||||
* @return InputInterface The current input instance
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output instance used by the last execution of the command.
|
||||
*
|
||||
* @return OutputInterface The current output instance
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code returned by the last execution of the application.
|
||||
*
|
||||
* @return int The status code
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user inputs.
|
||||
*
|
||||
* @param array $inputs An array of strings representing each input
|
||||
* passed to the command input stream
|
||||
*
|
||||
* @return CommandTester
|
||||
*/
|
||||
public function setInputs(array $inputs)
|
||||
{
|
||||
$this->inputs = $inputs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private static function createStream(array $inputs)
|
||||
{
|
||||
$stream = fopen('php://memory', 'r+', false);
|
||||
|
||||
fwrite($stream, implode(PHP_EOL, $inputs));
|
||||
rewind($stream);
|
||||
|
||||
return $stream;
|
||||
}
|
||||
}
|
||||
|
103
vendor/symfony/console/Tester/TesterTrait.php
vendored
Normal file
103
vendor/symfony/console/Tester/TesterTrait.php
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
<?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\Tester;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait TesterTrait
|
||||
{
|
||||
/** @var StreamOutput */
|
||||
private $output;
|
||||
private $inputs = array();
|
||||
|
||||
/**
|
||||
* Gets the display returned by the last execution of the command or application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string The display
|
||||
*/
|
||||
public function getDisplay($normalize = false)
|
||||
{
|
||||
rewind($this->output->getStream());
|
||||
|
||||
$display = stream_get_contents($this->output->getStream());
|
||||
|
||||
if ($normalize) {
|
||||
$display = str_replace(PHP_EOL, "\n", $display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input instance used by the last execution of the command or application.
|
||||
*
|
||||
* @return InputInterface The current input instance
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output instance used by the last execution of the command or application.
|
||||
*
|
||||
* @return OutputInterface The current output instance
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code returned by the last execution of the command or application.
|
||||
*
|
||||
* @return int The status code
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user inputs.
|
||||
*
|
||||
* @param $inputs array An array of strings representing each input
|
||||
* passed to the command input stream
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setInputs(array $inputs)
|
||||
{
|
||||
$this->inputs = $inputs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private static function createStream(array $inputs)
|
||||
{
|
||||
$stream = fopen('php://memory', 'r+', false);
|
||||
|
||||
fwrite($stream, implode(PHP_EOL, $inputs));
|
||||
rewind($stream);
|
||||
|
||||
return $stream;
|
||||
}
|
||||
}
|
147
vendor/symfony/console/Tests/ApplicationTest.php
vendored
147
vendor/symfony/console/Tests/ApplicationTest.php
vendored
@@ -18,9 +18,9 @@ use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
|
||||
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
||||
use Symfony\Component\Console\Event\ConsoleCommandEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Symfony\Component\Console\Exception\NamespaceNotFoundException;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
@@ -57,6 +57,7 @@ class ApplicationTest extends TestCase
|
||||
require_once self::$fixturesPath.'/BarBucCommand.php';
|
||||
require_once self::$fixturesPath.'/FooSubnamespaced1Command.php';
|
||||
require_once self::$fixturesPath.'/FooSubnamespaced2Command.php';
|
||||
require_once self::$fixturesPath.'/FooWithoutAliasCommand.php';
|
||||
require_once self::$fixturesPath.'/TestTiti.php';
|
||||
require_once self::$fixturesPath.'/TestToto.php';
|
||||
}
|
||||
@@ -276,10 +277,10 @@ class ApplicationTest extends TestCase
|
||||
$expectedMsg = "The namespace \"f\" is ambiguous.\nDid you mean one of these?\n foo\n foo1";
|
||||
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException(CommandNotFoundException::class);
|
||||
$this->expectException(NamespaceNotFoundException::class);
|
||||
$this->expectExceptionMessage($expectedMsg);
|
||||
} else {
|
||||
$this->setExpectedException(CommandNotFoundException::class, $expectedMsg);
|
||||
$this->setExpectedException(NamespaceNotFoundException::class, $expectedMsg);
|
||||
}
|
||||
|
||||
$application->findNamespace('f');
|
||||
@@ -294,7 +295,7 @@ class ApplicationTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException
|
||||
* @expectedException \Symfony\Component\Console\Exception\NamespaceNotFoundException
|
||||
* @expectedExceptionMessage There are no commands defined in the "bar" namespace.
|
||||
*/
|
||||
public function testFindInvalidNamespace()
|
||||
@@ -458,6 +459,52 @@ class ApplicationTest extends TestCase
|
||||
$application->find($name);
|
||||
}
|
||||
|
||||
public function testDontRunAlternativeNamespaceName()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \Foo1Command());
|
||||
$application->setAutoExit(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foos:bar1'), array('decorated' => false));
|
||||
$this->assertSame('
|
||||
|
||||
There are no commands defined in the "foos" namespace.
|
||||
|
||||
Did you mean this?
|
||||
foo
|
||||
|
||||
|
||||
', $tester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testCanRunAlternativeCommandName()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \FooWithoutAliasCommand());
|
||||
$application->setAutoExit(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->setInputs(array('y'));
|
||||
$tester->run(array('command' => 'foos'), array('decorated' => false));
|
||||
$display = trim($tester->getDisplay(true));
|
||||
$this->assertContains('Command "foos" is not defined', $display);
|
||||
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
|
||||
$this->assertContains('called', $display);
|
||||
}
|
||||
|
||||
public function testDontRunAlternativeCommandName()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->add(new \FooWithoutAliasCommand());
|
||||
$application->setAutoExit(false);
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->setInputs(array('n'));
|
||||
$exitCode = $tester->run(array('command' => 'foos'), array('decorated' => false));
|
||||
$this->assertSame(1, $exitCode);
|
||||
$display = trim($tester->getDisplay(true));
|
||||
$this->assertContains('Command "foos" is not defined', $display);
|
||||
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
|
||||
}
|
||||
|
||||
public function provideInvalidCommandNamesSingle()
|
||||
{
|
||||
return array(
|
||||
@@ -575,7 +622,8 @@ class ApplicationTest extends TestCase
|
||||
$application->find('foo2:command');
|
||||
$this->fail('->find() throws a CommandNotFoundException if namespace does not exist');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if namespace does not exist');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\NamespaceNotFoundException', $e, '->find() throws a NamespaceNotFoundException if namespace does not exist');
|
||||
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, 'NamespaceNotFoundException extends from CommandNotFoundException');
|
||||
$this->assertCount(3, $e->getAlternatives());
|
||||
$this->assertContains('foo', $e->getAlternatives());
|
||||
$this->assertContains('foo1', $e->getAlternatives());
|
||||
@@ -1164,9 +1212,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('before.error.after.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testRunWithError()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1235,36 +1280,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertEquals(1, $tester->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "ConsoleEvents::EXCEPTION" event is deprecated since Symfony 3.3 and will be removed in 4.0. Listen to the "ConsoleEvents::ERROR" event instead.
|
||||
*/
|
||||
public function testLegacyExceptionListenersAreStillTriggered()
|
||||
{
|
||||
$dispatcher = $this->getDispatcher();
|
||||
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
|
||||
$event->getOutput()->write('caught.');
|
||||
|
||||
$event->setException(new \RuntimeException('replaced in caught.'));
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
throw new \RuntimeException('foo');
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo'));
|
||||
$this->assertContains('before.caught.error.after.', $tester->getDisplay());
|
||||
$this->assertContains('replaced in caught.', $tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1287,7 +1302,6 @@ class ApplicationTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage error
|
||||
*/
|
||||
@@ -1309,9 +1323,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testRunDispatchesAllEventsWithError()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1329,9 +1340,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertContains('before.dym.error.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testRunWithErrorFailingStatusCode()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1422,24 +1430,6 @@ class ApplicationTest extends TestCase
|
||||
$this->assertEquals('some test value', $extraValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testTerminalDimensions()
|
||||
{
|
||||
$application = new Application();
|
||||
$originalDimensions = $application->getTerminalDimensions();
|
||||
$this->assertCount(2, $originalDimensions);
|
||||
|
||||
$width = 80;
|
||||
if ($originalDimensions[0] == $width) {
|
||||
$width = 100;
|
||||
}
|
||||
|
||||
$application->setTerminalDimensions($width, 80);
|
||||
$this->assertSame(array($width, 80), $application->getTerminalDimensions());
|
||||
}
|
||||
|
||||
public function testSetRunCustomDefaultCommand()
|
||||
{
|
||||
$command = new \FooCommand();
|
||||
@@ -1592,9 +1582,6 @@ class ApplicationTest extends TestCase
|
||||
return $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEnabled()
|
||||
{
|
||||
$application = new Application();
|
||||
@@ -1615,6 +1602,34 @@ class ApplicationTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage foo
|
||||
*/
|
||||
public function testThrowingErrorListener()
|
||||
{
|
||||
$dispatcher = $this->getDispatcher();
|
||||
$dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) {
|
||||
throw new \RuntimeException('foo');
|
||||
});
|
||||
|
||||
$dispatcher->addListener('console.command', function () {
|
||||
throw new \RuntimeException('bar');
|
||||
});
|
||||
|
||||
$application = new Application();
|
||||
$application->setDispatcher($dispatcher);
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
|
||||
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
$output->write('foo.');
|
||||
});
|
||||
|
||||
$tester = new ApplicationTester($application);
|
||||
$tester->run(array('command' => 'foo'));
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
putenv('SHELL_VERBOSITY');
|
||||
|
@@ -392,13 +392,7 @@ class CommandTest extends TestCase
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array());
|
||||
|
||||
if (\PHP_VERSION_ID < 70000) {
|
||||
// Cannot bind static closures in PHP 5
|
||||
$this->assertEquals('interact called'.PHP_EOL.'not bound'.PHP_EOL, $tester->getDisplay());
|
||||
} else {
|
||||
// Can bind static closures in PHP 7
|
||||
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
private static function createClosure()
|
||||
|
@@ -41,7 +41,7 @@ class LockableTraitTest extends TestCase
|
||||
{
|
||||
$command = new \FooLockCommand();
|
||||
|
||||
if (SemaphoreStore::isSupported(false)) {
|
||||
if (SemaphoreStore::isSupported()) {
|
||||
$store = new SemaphoreStore();
|
||||
} else {
|
||||
$store = new FlockStore();
|
||||
|
@@ -33,28 +33,27 @@ class AddConsoleCommandPassTest extends TestCase
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$container->setParameter('my-command.class', 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand');
|
||||
|
||||
$id = 'my-command';
|
||||
$definition = new Definition('%my-command.class%');
|
||||
$definition->setPublic($public);
|
||||
$definition->addTag('console.command');
|
||||
$container->setDefinition('my-command', $definition);
|
||||
$container->setDefinition($id, $definition);
|
||||
|
||||
$container->compile();
|
||||
|
||||
$alias = 'console.command.symfony_component_console_tests_dependencyinjection_mycommand';
|
||||
$alias = 'console.command.public_alias.my-command';
|
||||
|
||||
if ($public) {
|
||||
$this->assertFalse($container->hasAlias($alias));
|
||||
$id = 'my-command';
|
||||
} else {
|
||||
$id = $alias;
|
||||
// The alias is replaced by a Definition by the ReplaceAliasByActualDefinitionPass
|
||||
// in case the original service is private
|
||||
$this->assertFalse($container->hasDefinition('my-command'));
|
||||
$this->assertFalse($container->hasDefinition($id));
|
||||
$this->assertTrue($container->hasDefinition($alias));
|
||||
}
|
||||
|
||||
$this->assertTrue($container->hasParameter('console.command.ids'));
|
||||
$this->assertSame(array($alias => $id), $container->getParameter('console.command.ids'));
|
||||
$this->assertSame(array($public ? $id : $alias), $container->getParameter('console.command.ids'));
|
||||
}
|
||||
|
||||
public function testProcessRegistersLazyCommands()
|
||||
@@ -75,8 +74,7 @@ class AddConsoleCommandPassTest extends TestCase
|
||||
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
||||
$this->assertSame(array('my:command' => 'my-command', 'my:alias' => 'my-command'), $commandLoader->getArgument(1));
|
||||
$this->assertEquals(array(array('my-command' => new ServiceClosureArgument(new TypedReference('my-command', MyCommand::class)))), $commandLocator->getArguments());
|
||||
$this->assertSame(array('console.command.symfony_component_console_tests_dependencyinjection_mycommand' => 'my-command'), $container->getParameter('console.command.ids'));
|
||||
$this->assertSame(array('my-command' => true), $container->getParameter('console.lazy_command.ids'));
|
||||
$this->assertSame(array(), $container->getParameter('console.command.ids'));
|
||||
$this->assertSame(array(array('setName', array('my:command')), array('setAliases', array(array('my:alias')))), $command->getMethodCalls());
|
||||
}
|
||||
|
||||
@@ -98,8 +96,7 @@ class AddConsoleCommandPassTest extends TestCase
|
||||
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
||||
$this->assertSame(array('default' => 'with-default-name'), $commandLoader->getArgument(1));
|
||||
$this->assertEquals(array(array('with-default-name' => new ServiceClosureArgument(new TypedReference('with-default-name', NamedCommand::class)))), $commandLocator->getArguments());
|
||||
$this->assertSame(array('console.command.symfony_component_console_tests_dependencyinjection_namedcommand' => 'with-default-name'), $container->getParameter('console.command.ids'));
|
||||
$this->assertSame(array('with-default-name' => true), $container->getParameter('console.lazy_command.ids'));
|
||||
$this->assertSame(array(), $container->getParameter('console.command.ids'));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
@@ -172,10 +169,9 @@ class AddConsoleCommandPassTest extends TestCase
|
||||
|
||||
(new AddConsoleCommandPass())->process($container);
|
||||
|
||||
$alias1 = 'console.command.symfony_component_console_tests_dependencyinjection_mycommand';
|
||||
$alias2 = $alias1.'_my-command2';
|
||||
$this->assertTrue($container->hasAlias($alias1));
|
||||
$this->assertTrue($container->hasAlias($alias2));
|
||||
$aliasPrefix = 'console.command.public_alias.';
|
||||
$this->assertTrue($container->hasAlias($aliasPrefix.'my-command1'));
|
||||
$this->assertTrue($container->hasAlias($aliasPrefix.'my-command2'));
|
||||
}
|
||||
|
||||
public function testProcessOnChildDefinitionWithClass()
|
||||
|
21
vendor/symfony/console/Tests/Fixtures/FooWithoutAliasCommand.php
vendored
Normal file
21
vendor/symfony/console/Tests/Fixtures/FooWithoutAliasCommand.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooWithoutAliasCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo')
|
||||
->setDescription('The foo command')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('called');
|
||||
}
|
||||
}
|
34
vendor/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php
vendored
Normal file
34
vendor/symfony/console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure has single blank line after any text and a title
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
|
||||
$output->write('Lorem ipsum dolor sit amet');
|
||||
$output->title('First title');
|
||||
|
||||
$output->writeln('Lorem ipsum dolor sit amet');
|
||||
$output->title('Second title');
|
||||
|
||||
$output->write('Lorem ipsum dolor sit amet');
|
||||
$output->write('');
|
||||
$output->title('Third title');
|
||||
|
||||
//Ensure edge case by appending empty strings to history:
|
||||
$output->write('Lorem ipsum dolor sit amet');
|
||||
$output->write(new \ArrayIterator(array('', '', '')));
|
||||
$output->title('Fourth title');
|
||||
|
||||
//Ensure have manual control over number of blank lines:
|
||||
$output->writeln('Lorem ipsum dolor sit amet');
|
||||
$output->writeln(new \ArrayIterator(array('', ''))); //Should append an extra blank line
|
||||
$output->title('Fifth title');
|
||||
|
||||
$output->writeln('Lorem ipsum dolor sit amet');
|
||||
$output->newLine(2); //Should append an extra blank line
|
||||
$output->title('Fifth title');
|
||||
};
|
32
vendor/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_4_with_iterators.txt
vendored
Normal file
32
vendor/symfony/console/Tests/Fixtures/Style/SymfonyStyle/output/output_4_with_iterators.txt
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
Lorem ipsum dolor sit amet
|
||||
|
||||
First title
|
||||
===========
|
||||
|
||||
Lorem ipsum dolor sit amet
|
||||
|
||||
Second title
|
||||
============
|
||||
|
||||
Lorem ipsum dolor sit amet
|
||||
|
||||
Third title
|
||||
===========
|
||||
|
||||
Lorem ipsum dolor sit amet
|
||||
|
||||
Fourth title
|
||||
============
|
||||
|
||||
Lorem ipsum dolor sit amet
|
||||
|
||||
|
||||
Fifth title
|
||||
===========
|
||||
|
||||
Lorem ipsum dolor sit amet
|
||||
|
||||
|
||||
Fifth title
|
||||
===========
|
||||
|
@@ -1,3 +1,6 @@
|
||||
Description:
|
||||
Lists commands
|
||||
|
||||
Usage:
|
||||
list [options] [--] [<namespace>]
|
||||
|
||||
|
@@ -1,3 +1,6 @@
|
||||
Description:
|
||||
Lists commands
|
||||
|
||||
Usage:
|
||||
list [options] [--] [<namespace>]
|
||||
|
||||
|
@@ -1,3 +1,6 @@
|
||||
<comment>Description:</comment>
|
||||
command 1 description
|
||||
|
||||
<comment>Usage:</comment>
|
||||
descriptor:command1
|
||||
alias1
|
||||
|
@@ -1,3 +1,6 @@
|
||||
<comment>Description:</comment>
|
||||
command 2 description
|
||||
|
||||
<comment>Usage:</comment>
|
||||
descriptor:command2 [options] [--] \<argument_name>
|
||||
descriptor:command2 -o|--option_name \<argument_name>
|
||||
|
@@ -1,3 +1,6 @@
|
||||
<comment>Description:</comment>
|
||||
command åèä description
|
||||
|
||||
<comment>Usage:</comment>
|
||||
descriptor:åèä [options] [--] \<argument_åèä>
|
||||
descriptor:åèä -o|--option_name \<argument_name>
|
||||
|
@@ -196,17 +196,6 @@ class OutputFormatterTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider provideInlineStyleTagsWithUnknownOptions
|
||||
* @expectedDeprecation Unknown style options are deprecated since Symfony 3.2 and will be removed in 4.0. Exception "Invalid option specified: "%s". Expected one of (bold, underscore, blink, reverse, conceal)".
|
||||
*/
|
||||
public function testInlineStyleOptionsUnknownAreDeprecated($tag, $option)
|
||||
{
|
||||
$formatter = new OutputFormatter(true);
|
||||
$formatter->format($tag);
|
||||
}
|
||||
|
||||
public function provideInlineStyleTagsWithUnknownOptions()
|
||||
{
|
||||
return array(
|
||||
|
@@ -12,8 +12,10 @@
|
||||
namespace Symfony\Component\Console\Tests\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Helper\Helper;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
/**
|
||||
@@ -310,6 +312,88 @@ class ProgressBarTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testOverwriteWithSectionOutput()
|
||||
{
|
||||
$sections = array();
|
||||
$stream = $this->getOutputStream(true);
|
||||
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
|
||||
$bar = new ProgressBar($output, 50);
|
||||
$bar->start();
|
||||
$bar->display();
|
||||
$bar->advance();
|
||||
$bar->advance();
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals(
|
||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
||||
"\x1b[1A\x1b[0J".' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
||||
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
||||
"\x1b[1A\x1b[0J".' 2/50 [=>--------------------------] 4%'.PHP_EOL,
|
||||
stream_get_contents($output->getStream())
|
||||
);
|
||||
}
|
||||
|
||||
public function testOverwriteMultipleProgressBarsWithSectionOutputs()
|
||||
{
|
||||
$sections = array();
|
||||
$stream = $this->getOutputStream(true);
|
||||
$output1 = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
$output2 = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
|
||||
$progress = new ProgressBar($output1, 50);
|
||||
$progress2 = new ProgressBar($output2, 50);
|
||||
|
||||
$progress->start();
|
||||
$progress2->start();
|
||||
|
||||
$progress2->advance();
|
||||
$progress->advance();
|
||||
|
||||
rewind($stream->getStream());
|
||||
|
||||
$this->assertEquals(
|
||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
||||
' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
||||
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
||||
"\x1b[2A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
||||
"\x1b[1A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
||||
' 1/50 [>---------------------------] 2%'.PHP_EOL,
|
||||
stream_get_contents($stream->getStream())
|
||||
);
|
||||
}
|
||||
|
||||
public function testMultipleSectionsWithCustomFormat()
|
||||
{
|
||||
$sections = array();
|
||||
$stream = $this->getOutputStream(true);
|
||||
$output1 = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
$output2 = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
|
||||
ProgressBar::setFormatDefinition('test', '%current%/%max% [%bar%] %percent:3s%% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.');
|
||||
|
||||
$progress = new ProgressBar($output1, 50);
|
||||
$progress2 = new ProgressBar($output2, 50);
|
||||
$progress2->setFormat('test');
|
||||
|
||||
$progress->start();
|
||||
$progress2->start();
|
||||
|
||||
$progress->advance();
|
||||
$progress2->advance();
|
||||
|
||||
rewind($stream->getStream());
|
||||
|
||||
$this->assertEquals(' 0/50 [>---------------------------] 0%'.PHP_EOL.
|
||||
' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL.
|
||||
"\x1b[4A\x1b[0J".' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL.
|
||||
"\x1b[3A\x1b[0J".' 1/50 [>---------------------------] 2%'.PHP_EOL.
|
||||
' 0/50 [>] 0% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL.
|
||||
"\x1b[3A\x1b[0J".' 1/50 [>] 2% Fruitcake marzipan toffee. Cupcake gummi bears tart dessert ice cream chupa chups cupcake chocolate bar sesame snaps. Croissant halvah cookie jujubes powder macaroon. Fruitcake bear claw bonbon jelly beans oat cake pie muffin Fruitcake marzipan toffee.'.PHP_EOL,
|
||||
stream_get_contents($stream->getStream())
|
||||
);
|
||||
}
|
||||
|
||||
public function testStartWithMax()
|
||||
{
|
||||
$bar = new ProgressBar($output = $this->getOutputStream());
|
||||
@@ -592,6 +676,29 @@ class ProgressBarTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testSettingMaxStepsDuringProgressing()
|
||||
{
|
||||
$output = $this->getOutputStream();
|
||||
$bar = new ProgressBar($output);
|
||||
$bar->start();
|
||||
$bar->setProgress(2);
|
||||
$bar->setMaxSteps(10);
|
||||
$bar->setProgress(5);
|
||||
$bar->setMaxSteps(100);
|
||||
$bar->setProgress(10);
|
||||
$bar->finish();
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals(
|
||||
rtrim(' 0 [>---------------------------]').
|
||||
rtrim($this->generateOutput(' 2 [-->-------------------------]')).
|
||||
rtrim($this->generateOutput(' 5/10 [==============>-------------] 50%')).
|
||||
rtrim($this->generateOutput(' 10/100 [==>-------------------------] 10%')).
|
||||
rtrim($this->generateOutput(' 100/100 [============================] 100%')),
|
||||
stream_get_contents($output->getStream())
|
||||
);
|
||||
}
|
||||
|
||||
public function testWithSmallScreen()
|
||||
{
|
||||
$output = $this->getOutputStream();
|
||||
|
@@ -490,357 +490,6 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("\n")), $output, $question);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAskChoice()
|
||||
{
|
||||
$questionHelper = new QuestionHelper();
|
||||
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$questionHelper->setHelperSet($helperSet);
|
||||
|
||||
$heroes = array('Superman', 'Batman', 'Spiderman');
|
||||
|
||||
$questionHelper->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n"));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '2');
|
||||
$question->setMaxAttempts(1);
|
||||
// first answer is an empty answer, we're supposed to receive the default value
|
||||
$this->assertEquals('Spiderman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
|
||||
$question->setMaxAttempts(1);
|
||||
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
|
||||
$question->setErrorMessage('Input "%s" is not a superhero!');
|
||||
$question->setMaxAttempts(2);
|
||||
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), $question));
|
||||
|
||||
rewind($output->getStream());
|
||||
$stream = stream_get_contents($output->getStream());
|
||||
$this->assertContains('Input "Fabien" is not a superhero!', $stream);
|
||||
|
||||
try {
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '1');
|
||||
$question->setMaxAttempts(1);
|
||||
$questionHelper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), $question);
|
||||
$this->fail();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->assertEquals('Value "Fabien" is invalid', $e->getMessage());
|
||||
}
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
|
||||
$question->setMaxAttempts(1);
|
||||
$question->setMultiselect(true);
|
||||
|
||||
$this->assertEquals(array('Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0,1');
|
||||
$question->setMaxAttempts(1);
|
||||
$question->setMultiselect(true);
|
||||
|
||||
$this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, ' 0 , 1 ');
|
||||
$question->setMaxAttempts(1);
|
||||
$question->setMultiselect(true);
|
||||
|
||||
$this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsk()
|
||||
{
|
||||
$dialog = new QuestionHelper();
|
||||
|
||||
$dialog->setInputStream($this->getInputStream("\n8AM\n"));
|
||||
|
||||
$question = new Question('What time is it?', '2PM');
|
||||
$this->assertEquals('2PM', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
|
||||
$question = new Question('What time is it?', '2PM');
|
||||
$this->assertEquals('8AM', $dialog->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), $question));
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals('What time is it?', stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAskWithAutocomplete()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
// Acm<NEWLINE>
|
||||
// Ac<BACKSPACE><BACKSPACE>s<TAB>Test<NEWLINE>
|
||||
// <NEWLINE>
|
||||
// <UP ARROW><UP ARROW><NEWLINE>
|
||||
// <UP ARROW><UP ARROW><UP ARROW><UP ARROW><UP ARROW><TAB>Test<NEWLINE>
|
||||
// <DOWN ARROW><NEWLINE>
|
||||
// S<BACKSPACE><BACKSPACE><DOWN ARROW><DOWN ARROW><NEWLINE>
|
||||
// F00<BACKSPACE><BACKSPACE>oo<TAB><NEWLINE>
|
||||
$inputStream = $this->getInputStream("Acm\nAc\177\177s\tTest\n\n\033[A\033[A\n\033[A\033[A\033[A\033[A\033[A\tTest\n\033[B\nS\177\177\033[B\033[B\nF00\177\177oo\t\n");
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($inputStream);
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$question = new Question('Please select a bundle', 'FrameworkBundle');
|
||||
$question->setAutocompleterValues(array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle'));
|
||||
|
||||
$this->assertEquals('AcmeDemoBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('AsseticBundleTest', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('FrameworkBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('SecurityBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('FooBundleTest', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('AcmeDemoBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('AsseticBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('FooBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAskWithAutocompleteWithNonSequentialKeys()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
// <UP ARROW><UP ARROW><NEWLINE><DOWN ARROW><DOWN ARROW><NEWLINE>
|
||||
$inputStream = $this->getInputStream("\033[A\033[A\n\033[B\033[B\n");
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($inputStream);
|
||||
$dialog->setHelperSet(new HelperSet(array(new FormatterHelper())));
|
||||
|
||||
$question = new ChoiceQuestion('Please select a bundle', array(1 => 'AcmeDemoBundle', 4 => 'AsseticBundle'));
|
||||
$question->setMaxAttempts(1);
|
||||
|
||||
$this->assertEquals('AcmeDemoBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('AsseticBundle', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAskHiddenResponse()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('This test is not supported on Windows');
|
||||
}
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($this->getInputStream("8AM\n"));
|
||||
|
||||
$question = new Question('What time is it?');
|
||||
$question->setHidden(true);
|
||||
|
||||
$this->assertEquals('8AM', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider getAskConfirmationData
|
||||
*/
|
||||
public function testLegacyAskConfirmation($question, $expected, $default = true)
|
||||
{
|
||||
$dialog = new QuestionHelper();
|
||||
|
||||
$dialog->setInputStream($this->getInputStream($question."\n"));
|
||||
$question = new ConfirmationQuestion('Do you like French fries?', $default);
|
||||
$this->assertEquals($expected, $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question), 'confirmation question should '.($expected ? 'pass' : 'cancel'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAskConfirmationWithCustomTrueAnswer()
|
||||
{
|
||||
$dialog = new QuestionHelper();
|
||||
|
||||
$dialog->setInputStream($this->getInputStream("j\ny\n"));
|
||||
$question = new ConfirmationQuestion('Do you like French fries?', false, '/^(j|y)/i');
|
||||
$this->assertTrue($dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$question = new ConfirmationQuestion('Do you like French fries?', false, '/^(j|y)/i');
|
||||
$this->assertTrue($dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAskAndValidate()
|
||||
{
|
||||
$dialog = new QuestionHelper();
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$error = 'This is not a color!';
|
||||
$validator = function ($color) use ($error) {
|
||||
if (!\in_array($color, array('white', 'black'))) {
|
||||
throw new \InvalidArgumentException($error);
|
||||
}
|
||||
|
||||
return $color;
|
||||
};
|
||||
|
||||
$question = new Question('What color was the white horse of Henry IV?', 'white');
|
||||
$question->setValidator($validator);
|
||||
$question->setMaxAttempts(2);
|
||||
|
||||
$dialog->setInputStream($this->getInputStream("\nblack\n"));
|
||||
$this->assertEquals('white', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
$this->assertEquals('black', $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
|
||||
|
||||
$dialog->setInputStream($this->getInputStream("green\nyellow\norange\n"));
|
||||
try {
|
||||
$dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
|
||||
$this->fail();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->assertEquals($error, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider simpleAnswerProvider
|
||||
*/
|
||||
public function testLegacySelectChoiceFromSimpleChoices($providedAnswer, $expectedValue)
|
||||
{
|
||||
$possibleChoices = array(
|
||||
'My environment 1',
|
||||
'My environment 2',
|
||||
'My environment 3',
|
||||
);
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($this->getInputStream($providedAnswer."\n"));
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
|
||||
$question->setMaxAttempts(1);
|
||||
$answer = $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
|
||||
|
||||
$this->assertSame($expectedValue, $answer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider mixedKeysChoiceListAnswerProvider
|
||||
*/
|
||||
public function testLegacyChoiceFromChoicelistWithMixedKeys($providedAnswer, $expectedValue)
|
||||
{
|
||||
$possibleChoices = array(
|
||||
'0' => 'No environment',
|
||||
'1' => 'My environment 1',
|
||||
'env_2' => 'My environment 2',
|
||||
3 => 'My environment 3',
|
||||
);
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($this->getInputStream($providedAnswer."\n"));
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
|
||||
$question->setMaxAttempts(1);
|
||||
$answer = $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
|
||||
|
||||
$this->assertSame($expectedValue, $answer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider answerProvider
|
||||
*/
|
||||
public function testLegacySelectChoiceFromChoiceList($providedAnswer, $expectedValue)
|
||||
{
|
||||
$possibleChoices = array(
|
||||
'env_1' => 'My environment 1',
|
||||
'env_2' => 'My environment',
|
||||
'env_3' => 'My environment',
|
||||
);
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($this->getInputStream($providedAnswer."\n"));
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
|
||||
$question->setMaxAttempts(1);
|
||||
$answer = $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
|
||||
|
||||
$this->assertSame($expectedValue, $answer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The provided answer is ambiguous. Value should be one of env_2 or env_3.
|
||||
*/
|
||||
public function testLegacyAmbiguousChoiceFromChoicelist()
|
||||
{
|
||||
$possibleChoices = array(
|
||||
'env_1' => 'My first environment',
|
||||
'env_2' => 'My environment',
|
||||
'env_3' => 'My environment',
|
||||
);
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($this->getInputStream("My environment\n"));
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
|
||||
$question->setMaxAttempts(1);
|
||||
|
||||
$dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires function mb_strwidth
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyChoiceOutputFormattingQuestionForUtf8Keys()
|
||||
{
|
||||
$question = 'Lorem ipsum?';
|
||||
$possibleChoices = array(
|
||||
'foo' => 'foo',
|
||||
'żółw' => 'bar',
|
||||
'łabądź' => 'baz',
|
||||
);
|
||||
$outputShown = array(
|
||||
$question,
|
||||
' [<info>foo </info>] foo',
|
||||
' [<info>żółw </info>] bar',
|
||||
' [<info>łabądź</info>] baz',
|
||||
);
|
||||
$output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
|
||||
$output->method('getFormatter')->willReturn(new OutputFormatter());
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setInputStream($this->getInputStream("\n"));
|
||||
$helperSet = new HelperSet(array(new FormatterHelper()));
|
||||
$dialog->setHelperSet($helperSet);
|
||||
|
||||
$output->expects($this->once())->method('writeln')->with($this->equalTo($outputShown));
|
||||
|
||||
$question = new ChoiceQuestion($question, $possibleChoices, 'foo');
|
||||
$dialog->ask($this->createInputInterfaceMock(), $output, $question);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Aborted
|
||||
|
156
vendor/symfony/console/Tests/Helper/TableTest.php
vendored
156
vendor/symfony/console/Tests/Helper/TableTest.php
vendored
@@ -12,10 +12,12 @@
|
||||
namespace Symfony\Component\Console\Tests\Helper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
use Symfony\Component\Console\Helper\TableSeparator;
|
||||
use Symfony\Component\Console\Helper\TableStyle;
|
||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
class TableTest extends TestCase
|
||||
@@ -136,6 +138,45 @@ TABLE
|
||||
80-902734-1-6 And Then There Were None Agatha Christie
|
||||
=============== ========================== ==================
|
||||
|
||||
TABLE
|
||||
),
|
||||
array(
|
||||
array('ISBN', 'Title', 'Author'),
|
||||
$books,
|
||||
'box',
|
||||
<<<'TABLE'
|
||||
┌───────────────┬──────────────────────────┬──────────────────┐
|
||||
│ ISBN │ Title │ Author │
|
||||
├───────────────┼──────────────────────────┼──────────────────┤
|
||||
│ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri │
|
||||
│ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens │
|
||||
│ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien │
|
||||
│ 80-902734-1-6 │ And Then There Were None │ Agatha Christie │
|
||||
└───────────────┴──────────────────────────┴──────────────────┘
|
||||
|
||||
TABLE
|
||||
),
|
||||
array(
|
||||
array('ISBN', 'Title', 'Author'),
|
||||
array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
|
||||
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
|
||||
new TableSeparator(),
|
||||
array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
|
||||
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
|
||||
),
|
||||
'box-double',
|
||||
<<<'TABLE'
|
||||
╔═══════════════╤══════════════════════════╤══════════════════╗
|
||||
║ ISBN │ Title │ Author ║
|
||||
╠═══════════════╪══════════════════════════╪══════════════════╣
|
||||
║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
|
||||
║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
|
||||
╟───────────────┼──────────────────────────┼──────────────────╢
|
||||
║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
|
||||
║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
|
||||
╚═══════════════╧══════════════════════════╧══════════════════╝
|
||||
|
||||
TABLE
|
||||
),
|
||||
array(
|
||||
@@ -610,9 +651,9 @@ TABLE;
|
||||
{
|
||||
$style = new TableStyle();
|
||||
$style
|
||||
->setHorizontalBorderChar('.')
|
||||
->setVerticalBorderChar('.')
|
||||
->setCrossingChar('.')
|
||||
->setHorizontalBorderChars('.')
|
||||
->setVerticalBorderChars('.')
|
||||
->setDefaultCrossingChar('.')
|
||||
;
|
||||
|
||||
Table::setStyleDefinition('dotfull', $style);
|
||||
@@ -805,6 +846,115 @@ TABLE;
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function testSectionOutput()
|
||||
{
|
||||
$sections = array();
|
||||
$stream = $this->getOutputStream(true);
|
||||
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
$table = new Table($output);
|
||||
$table
|
||||
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
|
||||
->setRows(array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri', '9.95'),
|
||||
));
|
||||
|
||||
$table->render();
|
||||
|
||||
$table->appendRow(array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25'));
|
||||
|
||||
$expected =
|
||||
<<<TABLE
|
||||
+---------------+---------------+-----------------+-------+
|
||||
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
|
||||
+---------------+---------------+-----------------+-------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri | 9.95 |
|
||||
+---------------+---------------+-----------------+-------+
|
||||
\x1b[5A\x1b[0J+---------------+----------------------+-----------------+--------+
|
||||
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri | 9.95 |
|
||||
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | 139.25 |
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
|
||||
TABLE;
|
||||
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function testSectionOutputDoesntClearIfTableIsntRendered()
|
||||
{
|
||||
$sections = array();
|
||||
$stream = $this->getOutputStream(true);
|
||||
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
$table = new Table($output);
|
||||
$table
|
||||
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
|
||||
->setRows(array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri', '9.95'),
|
||||
));
|
||||
|
||||
$table->appendRow(array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25'));
|
||||
|
||||
$expected =
|
||||
<<<TABLE
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri | 9.95 |
|
||||
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | 139.25 |
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
|
||||
TABLE;
|
||||
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
public function testSectionOutputWithoutDecoration()
|
||||
{
|
||||
$sections = array();
|
||||
$stream = $this->getOutputStream();
|
||||
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
|
||||
$table = new Table($output);
|
||||
$table
|
||||
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
|
||||
->setRows(array(
|
||||
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri', '9.95'),
|
||||
));
|
||||
|
||||
$table->render();
|
||||
|
||||
$table->appendRow(array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25'));
|
||||
|
||||
$expected =
|
||||
<<<TABLE
|
||||
+---------------+---------------+-----------------+-------+
|
||||
| ISBN | Title | Author | Price |
|
||||
+---------------+---------------+-----------------+-------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri | 9.95 |
|
||||
+---------------+---------------+-----------------+-------+
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
| ISBN | Title | Author | Price |
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
| 99921-58-10-7 | Divine Comedy | Dante Alighieri | 9.95 |
|
||||
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | 139.25 |
|
||||
+---------------+----------------------+-----------------+--------+
|
||||
|
||||
TABLE;
|
||||
|
||||
$this->assertEquals($expected, $this->getOutputContent($output));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Output should be an instance of "Symfony\Component\Console\Output\ConsoleSectionOutput" when calling "Symfony\Component\Console\Helper\Table::appendRow".
|
||||
*/
|
||||
public function testAppendRowWithoutSectionOutput()
|
||||
{
|
||||
$table = new Table($this->getOutputStream());
|
||||
|
||||
$table->appendRow(array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Style "absent" is not defined.
|
||||
|
@@ -38,26 +38,12 @@ class InputArgumentTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidModes
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Argument mode "-1" is not valid.
|
||||
*/
|
||||
public function testInvalidModes($mode)
|
||||
public function testInvalidModes()
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('Argument mode "%s" is not valid.', $mode));
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode));
|
||||
}
|
||||
|
||||
new InputArgument('foo', $mode);
|
||||
}
|
||||
|
||||
public function provideInvalidModes()
|
||||
{
|
||||
return array(
|
||||
array('ANOTHER_ONE'),
|
||||
array(-1),
|
||||
);
|
||||
new InputArgument('foo', '-1');
|
||||
}
|
||||
|
||||
public function testIsArray()
|
||||
|
@@ -374,8 +374,9 @@ class InputDefinitionTest extends TestCase
|
||||
|
||||
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))), '<foo>', 'puts arguments in angle brackets'),
|
||||
array(new InputDefinition(array(new InputArgument('foo'))), '[<foo>]', 'puts optional arguments in square brackets'),
|
||||
array(new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))), '[<foo>]...', 'uses an ellipsis for array arguments'),
|
||||
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))), '<foo> (<foo>)...', 'uses parenthesis and ellipsis for required array arguments'),
|
||||
array(new InputDefinition(array(new InputArgument('foo'), new InputArgument('bar'))), '[<foo> [<bar>]]', 'chains optional arguments inside brackets'),
|
||||
array(new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))), '[<foo>...]', 'uses an ellipsis for array arguments'),
|
||||
array(new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))), '<foo>...', 'uses an ellipsis for required array arguments'),
|
||||
|
||||
array(new InputDefinition(array(new InputOption('foo'), new InputArgument('foo', InputArgument::REQUIRED))), '[--foo] [--] <foo>', 'puts [--] between options and arguments'),
|
||||
);
|
||||
|
@@ -74,26 +74,12 @@ class InputOptionTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidModes
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Option mode "-1" is not valid.
|
||||
*/
|
||||
public function testInvalidModes($mode)
|
||||
public function testInvalidModes()
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('Option mode "%s" is not valid.', $mode));
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode));
|
||||
}
|
||||
|
||||
new InputOption('foo', 'f', $mode);
|
||||
}
|
||||
|
||||
public function provideInvalidModes()
|
||||
{
|
||||
return array(
|
||||
array('ANOTHER_ONE'),
|
||||
array(-1),
|
||||
);
|
||||
new InputOption('foo', 'f', '-1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
140
vendor/symfony/console/Tests/Output/ConsoleSectionOutputTest.php
vendored
Normal file
140
vendor/symfony/console/Tests/Output/ConsoleSectionOutputTest.php
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
<?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\Tests\Output;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\StreamOutput;
|
||||
|
||||
class ConsoleSectionOutputTest extends TestCase
|
||||
{
|
||||
private $stream;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->stream = fopen('php://memory', 'r+', false);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->stream = null;
|
||||
}
|
||||
|
||||
public function testClearAll()
|
||||
{
|
||||
$sections = array();
|
||||
$output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output->writeln('Foo'.PHP_EOL.'Bar');
|
||||
$output->clear();
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
public function testClearNumberOfLines()
|
||||
{
|
||||
$sections = array();
|
||||
$output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output->writeln("Foo\nBar\nBaz\nFooBar");
|
||||
$output->clear(2);
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals("Foo\nBar\nBaz\nFooBar".PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
public function testClearNumberOfLinesWithMultipleSections()
|
||||
{
|
||||
$output = new StreamOutput($this->stream);
|
||||
$sections = array();
|
||||
$output1 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
$output2 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output2->writeln('Foo');
|
||||
$output2->writeln('Bar');
|
||||
$output2->clear(1);
|
||||
$output1->writeln('Baz');
|
||||
|
||||
rewind($output->getStream());
|
||||
|
||||
$this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL."\x1b[1A\x1b[0J\e[1A\e[0J".'Baz'.PHP_EOL.'Foo'.PHP_EOL, stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
public function testClearPreservingEmptyLines()
|
||||
{
|
||||
$output = new StreamOutput($this->stream);
|
||||
$sections = array();
|
||||
$output1 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
$output2 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output2->writeln(PHP_EOL.'foo');
|
||||
$output2->clear(1);
|
||||
$output1->writeln('bar');
|
||||
|
||||
rewind($output->getStream());
|
||||
|
||||
$this->assertEquals(PHP_EOL.'foo'.PHP_EOL."\x1b[1A\x1b[0J\x1b[1A\x1b[0J".'bar'.PHP_EOL.PHP_EOL, stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
public function testOverwrite()
|
||||
{
|
||||
$sections = array();
|
||||
$output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output->writeln('Foo');
|
||||
$output->overwrite('Bar');
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals('Foo'.PHP_EOL."\x1b[1A\x1b[0JBar".PHP_EOL, stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
public function testOverwriteMultipleLines()
|
||||
{
|
||||
$sections = array();
|
||||
$output = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output->writeln('Foo'.PHP_EOL.'Bar'.PHP_EOL.'Baz');
|
||||
$output->overwrite('Bar');
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL.'Baz'.PHP_EOL.sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.PHP_EOL, stream_get_contents($output->getStream()));
|
||||
}
|
||||
|
||||
public function testAddingMultipleSections()
|
||||
{
|
||||
$sections = array();
|
||||
$output1 = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
$output2 = new ConsoleSectionOutput($this->stream, $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$this->assertCount(2, $sections);
|
||||
}
|
||||
|
||||
public function testMultipleSectionsOutput()
|
||||
{
|
||||
$output = new StreamOutput($this->stream);
|
||||
$sections = array();
|
||||
$output1 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
$output2 = new ConsoleSectionOutput($output->getStream(), $sections, OutputInterface::VERBOSITY_NORMAL, true, new OutputFormatter());
|
||||
|
||||
$output1->writeln('Foo');
|
||||
$output2->writeln('Bar');
|
||||
|
||||
$output1->overwrite('Baz');
|
||||
$output2->overwrite('Foobar');
|
||||
|
||||
rewind($output->getStream());
|
||||
$this->assertEquals('Foo'.PHP_EOL.'Bar'.PHP_EOL."\x1b[2A\x1b[0JBar".PHP_EOL."\x1b[1A\x1b[0JBaz".PHP_EOL.'Bar'.PHP_EOL."\x1b[1A\x1b[0JFoobar".PHP_EOL, stream_get_contents($output->getStream()));
|
||||
}
|
||||
}
|
@@ -81,6 +81,19 @@ class OutputTest extends TestCase
|
||||
$this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output');
|
||||
}
|
||||
|
||||
public function testWriteAnIterableOfMessages()
|
||||
{
|
||||
$output = new TestOutput();
|
||||
$output->writeln($this->generateMessages());
|
||||
$this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an iterable of messages to output');
|
||||
}
|
||||
|
||||
private function generateMessages(): iterable
|
||||
{
|
||||
yield 'foo';
|
||||
yield 'bar';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideWriteArguments
|
||||
*/
|
||||
|
@@ -13,7 +13,9 @@ namespace Symfony\Component\Console\Tests\Tester;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Tester\ApplicationTester;
|
||||
|
||||
class ApplicationTesterTest extends TestCase
|
||||
@@ -27,7 +29,9 @@ class ApplicationTesterTest extends TestCase
|
||||
$this->application->setAutoExit(false);
|
||||
$this->application->register('foo')
|
||||
->addArgument('foo')
|
||||
->setCode(function ($input, $output) { $output->writeln('foo'); })
|
||||
->setCode(function ($input, $output) {
|
||||
$output->writeln('foo');
|
||||
})
|
||||
;
|
||||
|
||||
$this->tester = new ApplicationTester($this->application);
|
||||
@@ -63,6 +67,25 @@ class ApplicationTesterTest extends TestCase
|
||||
$this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution');
|
||||
}
|
||||
|
||||
public function testSetInputs()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->register('foo')->setCode(function ($input, $output) {
|
||||
$helper = new QuestionHelper();
|
||||
$helper->ask($input, $output, new Question('Q1'));
|
||||
$helper->ask($input, $output, new Question('Q2'));
|
||||
$helper->ask($input, $output, new Question('Q3'));
|
||||
});
|
||||
$tester = new ApplicationTester($application);
|
||||
|
||||
$tester->setInputs(array('I1', 'I2', 'I3'));
|
||||
$tester->run(array('command' => 'foo'));
|
||||
|
||||
$this->assertSame(0, $tester->getStatusCode());
|
||||
$this->assertEquals('Q1Q2Q3', $tester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testGetStatusCode()
|
||||
{
|
||||
$this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code');
|
||||
|
13
vendor/symfony/console/composer.json
vendored
13
vendor/symfony/console/composer.json
vendored
@@ -16,16 +16,15 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/debug": "~2.8|~3.0|~4.0"
|
||||
"php": "^7.1.3",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "~3.3|~4.0",
|
||||
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
|
||||
"symfony/config": "~3.4|~4.0",
|
||||
"symfony/event-dispatcher": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/lock": "~3.4|~4.0",
|
||||
"symfony/process": "~3.3|~4.0",
|
||||
"symfony/process": "~3.4|~4.0",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -47,7 +46,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.4-dev"
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
6
vendor/symfony/debug/CHANGELOG.md
vendored
6
vendor/symfony/debug/CHANGELOG.md
vendored
@@ -1,6 +1,12 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* removed the symfony_debug extension
|
||||
* removed `ContextErrorException`
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
|
2
vendor/symfony/debug/Debug.php
vendored
2
vendor/symfony/debug/Debug.php
vendored
@@ -23,7 +23,7 @@ class Debug
|
||||
/**
|
||||
* Enables the debug tools.
|
||||
*
|
||||
* This method registers an error handler, an exception handler and a special class loader.
|
||||
* This method registers an error handler and an exception handler.
|
||||
*
|
||||
* @param int $errorReportingLevel The level of error reporting you want
|
||||
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
|
||||
|
5
vendor/symfony/debug/DebugClassLoader.php
vendored
5
vendor/symfony/debug/DebugClassLoader.php
vendored
@@ -34,7 +34,6 @@ class DebugClassLoader
|
||||
private static $deprecated = array();
|
||||
private static $internal = array();
|
||||
private static $internalMethods = array();
|
||||
private static $php7Reserved = array('int' => 1, 'float' => 1, 'bool' => 1, 'string' => 1, 'true' => 1, 'false' => 1, 'null' => 1);
|
||||
private static $darwinCache = array('/' => array('/', array()));
|
||||
|
||||
public function __construct(callable $classLoader)
|
||||
@@ -278,10 +277,6 @@ class DebugClassLoader
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset(self::$php7Reserved[\strtolower($refl->getShortName())])) {
|
||||
@trigger_error(sprintf('The "%s" class uses the reserved name "%s", it will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
if ($file) {
|
||||
|
114
vendor/symfony/debug/ErrorHandler.php
vendored
114
vendor/symfony/debug/ErrorHandler.php
vendored
@@ -13,7 +13,6 @@ namespace Symfony\Component\Debug;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Debug\Exception\ContextErrorException;
|
||||
use Symfony\Component\Debug\Exception\FatalErrorException;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\Debug\Exception\OutOfMemoryException;
|
||||
@@ -97,8 +96,6 @@ class ErrorHandler
|
||||
private $bootstrappingLogger;
|
||||
|
||||
private static $reservedMemory;
|
||||
private static $stackedErrors = array();
|
||||
private static $stackedErrorLevels = array();
|
||||
private static $toStringException = null;
|
||||
private static $silencedErrorCache = array();
|
||||
private static $silencedErrorCount = 0;
|
||||
@@ -398,10 +395,8 @@ class ErrorHandler
|
||||
|
||||
if (4 < $numArgs = \func_num_args()) {
|
||||
$context = $scope ? (func_get_arg(4) ?: array()) : array();
|
||||
$backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM
|
||||
} else {
|
||||
$context = array();
|
||||
$backtrace = null;
|
||||
}
|
||||
|
||||
if (isset($context['GLOBALS']) && $scope) {
|
||||
@@ -410,15 +405,6 @@ class ErrorHandler
|
||||
$context = $e;
|
||||
}
|
||||
|
||||
if (null !== $backtrace && $type & E_ERROR) {
|
||||
// E_ERROR fatal errors are triggered on HHVM when
|
||||
// hhvm.error_handling.call_user_handler_on_fatals=1
|
||||
// which is the way to get their backtrace.
|
||||
$this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$logMessage = $this->levels[$type].': '.$message;
|
||||
|
||||
if (null !== self::$toStringException) {
|
||||
@@ -448,19 +434,16 @@ class ErrorHandler
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ($scope) {
|
||||
$errorAsException = new ContextErrorException($logMessage, 0, $type, $file, $line, $context);
|
||||
} else {
|
||||
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
|
||||
}
|
||||
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
|
||||
|
||||
// Clean the trace by removing function arguments and the first frames added by the error handler itself.
|
||||
if ($throw || $this->tracedErrors & $type) {
|
||||
$backtrace = $backtrace ?: $errorAsException->getTrace();
|
||||
$backtrace = $errorAsException->getTrace();
|
||||
$lightTrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw);
|
||||
$this->traceReflector->setValue($errorAsException, $lightTrace);
|
||||
} else {
|
||||
$this->traceReflector->setValue($errorAsException, array());
|
||||
$backtrace = array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,32 +457,25 @@ class ErrorHandler
|
||||
&& ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
|
||||
) {
|
||||
// Here, we know trigger_error() has been called from __toString().
|
||||
// HHVM is fine with throwing from __toString() but PHP triggers a fatal error instead.
|
||||
// PHP triggers a fatal error when throwing from __toString().
|
||||
// A small convention allows working around the limitation:
|
||||
// given a caught $e exception in __toString(), quitting the method with
|
||||
// `return trigger_error($e, E_USER_ERROR);` allows this error handler
|
||||
// to make $e get through the __toString() barrier.
|
||||
|
||||
foreach ($context as $e) {
|
||||
if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
|
||||
if (1 === $i) {
|
||||
// On HHVM
|
||||
$errorAsException = $e;
|
||||
break;
|
||||
}
|
||||
if ($e instanceof \Throwable && $e->__toString() === $message) {
|
||||
self::$toStringException = $e;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (1 < $i) {
|
||||
// On PHP (not on HHVM), display the original error message instead of the default one.
|
||||
$this->handleException($errorAsException);
|
||||
// Display the original error message instead of the default one.
|
||||
$this->handleException($errorAsException);
|
||||
|
||||
// Stop the process by giving back the error to the native handler.
|
||||
return false;
|
||||
}
|
||||
// Stop the process by giving back the error to the native handler.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -509,13 +485,6 @@ class ErrorHandler
|
||||
|
||||
if ($this->isRecursive) {
|
||||
$log = 0;
|
||||
} elseif (self::$stackedErrorLevels) {
|
||||
self::$stackedErrors[] = array(
|
||||
$this->loggers[$type][0],
|
||||
($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG,
|
||||
$logMessage,
|
||||
$errorAsException ? array('exception' => $errorAsException) : array(),
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
$this->isRecursive = true;
|
||||
@@ -569,7 +538,6 @@ class ErrorHandler
|
||||
if ($this->loggedErrors & $type) {
|
||||
try {
|
||||
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, array('exception' => $exception));
|
||||
} catch (\Exception $handlerException) {
|
||||
} catch (\Throwable $handlerException) {
|
||||
}
|
||||
}
|
||||
@@ -588,7 +556,6 @@ class ErrorHandler
|
||||
return \call_user_func($exceptionHandler, $exception);
|
||||
}
|
||||
$handlerException = $handlerException ?: $exception;
|
||||
} catch (\Exception $handlerException) {
|
||||
} catch (\Throwable $handlerException) {
|
||||
}
|
||||
if ($exception === $handlerException) {
|
||||
@@ -649,16 +616,6 @@ class ErrorHandler
|
||||
$error = error_get_last();
|
||||
}
|
||||
|
||||
try {
|
||||
while (self::$stackedErrorLevels) {
|
||||
static::unstackErrors();
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
// Handled below
|
||||
} catch (\Throwable $exception) {
|
||||
// Handled below
|
||||
}
|
||||
|
||||
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
|
||||
// Let's not throw anymore but keep logging
|
||||
$handler->throwAt(0, true);
|
||||
@@ -669,10 +626,12 @@ class ErrorHandler
|
||||
} else {
|
||||
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
|
||||
}
|
||||
} else {
|
||||
$exception = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (isset($exception)) {
|
||||
if (null !== $exception) {
|
||||
self::$exitCode = 255;
|
||||
$handler->handleException($exception, $error);
|
||||
}
|
||||
@@ -686,55 +645,6 @@ class ErrorHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the error handler for delayed handling.
|
||||
* Ensures also that non-catchable fatal errors are never silenced.
|
||||
*
|
||||
* As shown by http://bugs.php.net/42098 and http://bugs.php.net/60724
|
||||
* PHP has a compile stage where it behaves unusually. To workaround it,
|
||||
* we plug an error handler that only stacks errors for later.
|
||||
*
|
||||
* The most important feature of this is to prevent
|
||||
* autoloading until unstackErrors() is called.
|
||||
*
|
||||
* @deprecated since version 3.4, to be removed in 4.0.
|
||||
*/
|
||||
public static function stackErrors()
|
||||
{
|
||||
@trigger_error('Support for stacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
|
||||
self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstacks stacked errors and forwards to the logger.
|
||||
*
|
||||
* @deprecated since version 3.4, to be removed in 4.0.
|
||||
*/
|
||||
public static function unstackErrors()
|
||||
{
|
||||
@trigger_error('Support for unstacking errors is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
|
||||
$level = array_pop(self::$stackedErrorLevels);
|
||||
|
||||
if (null !== $level) {
|
||||
$errorReportingLevel = error_reporting($level);
|
||||
if ($errorReportingLevel !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
|
||||
// If the user changed the error level, do not overwrite it
|
||||
error_reporting($errorReportingLevel);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty(self::$stackedErrorLevels)) {
|
||||
$errors = self::$stackedErrors;
|
||||
self::$stackedErrors = array();
|
||||
|
||||
foreach ($errors as $error) {
|
||||
$error[0]->log($error[1], $error[2], $error[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fatal error handlers.
|
||||
*
|
||||
|
@@ -18,7 +18,7 @@ namespace Symfony\Component\Debug\Exception;
|
||||
*/
|
||||
class ClassNotFoundException extends FatalErrorException
|
||||
{
|
||||
public function __construct($message, \ErrorException $previous)
|
||||
public function __construct(string $message, \ErrorException $previous)
|
||||
{
|
||||
parent::__construct(
|
||||
$message,
|
||||
|
@@ -1,40 +0,0 @@
|
||||
<?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\Debug\Exception;
|
||||
|
||||
/**
|
||||
* Error Exception with Variable Context.
|
||||
*
|
||||
* @author Christian Sciberras <uuf6429@gmail.com>
|
||||
*
|
||||
* @deprecated since version 3.3. Instead, \ErrorException will be used directly in 4.0.
|
||||
*/
|
||||
class ContextErrorException extends \ErrorException
|
||||
{
|
||||
private $context = array();
|
||||
|
||||
public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
|
||||
{
|
||||
parent::__construct($message, $code, $severity, $filename, $lineno);
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Array of variables that existed when the exception occurred
|
||||
*/
|
||||
public function getContext()
|
||||
{
|
||||
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
}
|
@@ -18,7 +18,7 @@ namespace Symfony\Component\Debug\Exception;
|
||||
*/
|
||||
class FatalErrorException extends \ErrorException
|
||||
{
|
||||
public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
|
||||
public function __construct(string $message, int $code, int $severity, string $filename, int $lineno, int $traceOffset = null, bool $traceArgs = true, array $trace = null, \Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
|
||||
|
||||
@@ -60,11 +60,6 @@ class FatalErrorException extends \ErrorException
|
||||
|
||||
unset($frame);
|
||||
$trace = array_reverse($trace);
|
||||
} elseif (\function_exists('symfony_debug_backtrace')) {
|
||||
$trace = symfony_debug_backtrace();
|
||||
if (0 < $traceOffset) {
|
||||
array_splice($trace, 0, $traceOffset);
|
||||
}
|
||||
} else {
|
||||
$trace = array();
|
||||
}
|
||||
|
@@ -18,21 +18,22 @@ namespace Symfony\Component\Debug\Exception;
|
||||
*/
|
||||
class FatalThrowableError extends FatalErrorException
|
||||
{
|
||||
private $originalClassName;
|
||||
|
||||
public function __construct(\Throwable $e)
|
||||
{
|
||||
$this->originalClassName = \get_class($e);
|
||||
|
||||
if ($e instanceof \ParseError) {
|
||||
$message = 'Parse error: '.$e->getMessage();
|
||||
$severity = E_PARSE;
|
||||
} elseif ($e instanceof \TypeError) {
|
||||
$message = 'Type error: '.$e->getMessage();
|
||||
$severity = E_RECOVERABLE_ERROR;
|
||||
} else {
|
||||
$message = $e->getMessage();
|
||||
$severity = E_ERROR;
|
||||
}
|
||||
|
||||
\ErrorException::__construct(
|
||||
$message,
|
||||
$e->getMessage(),
|
||||
$e->getCode(),
|
||||
$severity,
|
||||
$e->getFile(),
|
||||
@@ -42,4 +43,9 @@ class FatalThrowableError extends FatalErrorException
|
||||
|
||||
$this->setTrace($e->getTrace());
|
||||
}
|
||||
|
||||
public function getOriginalClassName(): string
|
||||
{
|
||||
return $this->originalClassName;
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
/**
|
||||
* FlattenException wraps a PHP Exception to be able to serialize it.
|
||||
* FlattenException wraps a PHP Error or Exception to be able to serialize it.
|
||||
*
|
||||
* Basically, this class removes all objects from the trace.
|
||||
*
|
||||
@@ -34,6 +34,11 @@ class FlattenException
|
||||
private $line;
|
||||
|
||||
public static function create(\Exception $exception, $statusCode = null, array $headers = array())
|
||||
{
|
||||
return static::createFromThrowable($exception, $statusCode, $headers);
|
||||
}
|
||||
|
||||
public static function createFromThrowable(\Throwable $exception, ?int $statusCode = null, array $headers = array()): self
|
||||
{
|
||||
$e = new static();
|
||||
$e->setMessage($exception->getMessage());
|
||||
@@ -52,17 +57,15 @@ class FlattenException
|
||||
|
||||
$e->setStatusCode($statusCode);
|
||||
$e->setHeaders($headers);
|
||||
$e->setTraceFromException($exception);
|
||||
$e->setClass(\get_class($exception));
|
||||
$e->setTraceFromThrowable($exception);
|
||||
$e->setClass($exception instanceof FatalThrowableError ? $exception->getOriginalClassName() : \get_class($exception));
|
||||
$e->setFile($exception->getFile());
|
||||
$e->setLine($exception->getLine());
|
||||
|
||||
$previous = $exception->getPrevious();
|
||||
|
||||
if ($previous instanceof \Exception) {
|
||||
$e->setPrevious(static::create($previous));
|
||||
} elseif ($previous instanceof \Throwable) {
|
||||
$e->setPrevious(static::create(new FatalThrowableError($previous)));
|
||||
if ($previous instanceof \Throwable) {
|
||||
$e->setPrevious(static::createFromThrowable($previous));
|
||||
}
|
||||
|
||||
return $e;
|
||||
@@ -178,9 +181,19 @@ class FlattenException
|
||||
return $this->trace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1, use {@see setTraceFromThrowable()} instead.
|
||||
*/
|
||||
public function setTraceFromException(\Exception $exception)
|
||||
{
|
||||
$this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use "setTraceFromThrowable()" instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->setTraceFromThrowable($exception);
|
||||
}
|
||||
|
||||
public function setTraceFromThrowable(\Throwable $throwable): void
|
||||
{
|
||||
$this->setTrace($throwable->getTrace(), $throwable->getFile(), $throwable->getLine());
|
||||
}
|
||||
|
||||
public function setTrace($trace, $file, $line)
|
||||
|
@@ -25,7 +25,7 @@ class SilencedErrorContext implements \JsonSerializable
|
||||
private $line;
|
||||
private $trace;
|
||||
|
||||
public function __construct($severity, $file, $line, array $trace = array(), $count = 1)
|
||||
public function __construct(int $severity, string $file, int $line, array $trace = array(), int $count = 1)
|
||||
{
|
||||
$this->severity = $severity;
|
||||
$this->file = $file;
|
||||
|
@@ -18,7 +18,7 @@ namespace Symfony\Component\Debug\Exception;
|
||||
*/
|
||||
class UndefinedFunctionException extends FatalErrorException
|
||||
{
|
||||
public function __construct($message, \ErrorException $previous)
|
||||
public function __construct(string $message, \ErrorException $previous)
|
||||
{
|
||||
parent::__construct(
|
||||
$message,
|
||||
|
@@ -18,7 +18,7 @@ namespace Symfony\Component\Debug\Exception;
|
||||
*/
|
||||
class UndefinedMethodException extends FatalErrorException
|
||||
{
|
||||
public function __construct($message, \ErrorException $previous)
|
||||
public function __construct(string $message, \ErrorException $previous)
|
||||
{
|
||||
parent::__construct(
|
||||
$message,
|
||||
|
2
vendor/symfony/debug/ExceptionHandler.php
vendored
2
vendor/symfony/debug/ExceptionHandler.php
vendored
@@ -36,7 +36,7 @@ class ExceptionHandler
|
||||
private $caughtLength;
|
||||
private $fileLinkFormat;
|
||||
|
||||
public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
|
||||
public function __construct(bool $debug = true, string $charset = null, $fileLinkFormat = null)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
$this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
|
||||
|
@@ -83,7 +83,7 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
*
|
||||
* @return array An array of possible fully qualified class names
|
||||
*/
|
||||
private function getClassCandidates($class)
|
||||
private function getClassCandidates(string $class): array
|
||||
{
|
||||
if (!\is_array($functions = spl_autoload_functions())) {
|
||||
return array();
|
||||
@@ -124,14 +124,7 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
return array_unique($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $class
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function findClassInPath($path, $class, $prefix)
|
||||
private function findClassInPath(string $path, string $class, string $prefix): array
|
||||
{
|
||||
if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
|
||||
return array();
|
||||
@@ -148,14 +141,7 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $file
|
||||
* @param string $prefix
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function convertFileToClass($path, $file, $prefix)
|
||||
private function convertFileToClass(string $path, string $file, string $prefix): ?string
|
||||
{
|
||||
$candidates = array(
|
||||
// namespaced class
|
||||
@@ -192,14 +178,11 @@ class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function classExists($class)
|
||||
private function classExists(string $class): bool
|
||||
{
|
||||
return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
|
||||
}
|
||||
|
134
vendor/symfony/debug/Resources/ext/README.md
vendored
134
vendor/symfony/debug/Resources/ext/README.md
vendored
@@ -1,134 +0,0 @@
|
||||
Symfony Debug Extension for PHP 5
|
||||
=================================
|
||||
|
||||
This extension publishes several functions to help building powerful debugging tools.
|
||||
It is compatible with PHP 5.3, 5.4, 5.5 and 5.6; with ZTS and non-ZTS modes.
|
||||
It is not required thus not provided for PHP 7.
|
||||
|
||||
symfony_zval_info()
|
||||
-------------------
|
||||
|
||||
- exposes zval_hash/refcounts, allowing e.g. efficient exploration of arbitrary structures in PHP,
|
||||
- does work with references, preventing memory copying.
|
||||
|
||||
Its behavior is about the same as:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
function symfony_zval_info($key, $array, $options = 0)
|
||||
{
|
||||
|
||||
// $options is currently not used, but could be in future version.
|
||||
|
||||
if (!array_key_exists($key, $array)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'type' => gettype($array[$key]),
|
||||
'zval_hash' => /* hashed memory address of $array[$key] */,
|
||||
'zval_refcount' => /* internal zval refcount of $array[$key] */,
|
||||
'zval_isref' => /* is_ref status of $array[$key] */,
|
||||
);
|
||||
|
||||
switch ($info['type']) {
|
||||
case 'object':
|
||||
$info += array(
|
||||
'object_class' => get_class($array[$key]),
|
||||
'object_refcount' => /* internal object refcount of $array[$key] */,
|
||||
'object_hash' => spl_object_hash($array[$key]),
|
||||
'object_handle' => /* internal object handle $array[$key] */,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'resource':
|
||||
$info += array(
|
||||
'resource_handle' => (int) $array[$key],
|
||||
'resource_type' => get_resource_type($array[$key]),
|
||||
'resource_refcount' => /* internal resource refcount of $array[$key] */,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'array':
|
||||
$info += array(
|
||||
'array_count' => count($array[$key]),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
$info += array(
|
||||
'strlen' => strlen($array[$key]),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
```
|
||||
|
||||
symfony_debug_backtrace()
|
||||
-------------------------
|
||||
|
||||
This function works like debug_backtrace(), except that it can fetch the full backtrace in case of fatal errors:
|
||||
|
||||
```php
|
||||
function foo() { fatal(); }
|
||||
function bar() { foo(); }
|
||||
|
||||
function sd() { var_dump(symfony_debug_backtrace()); }
|
||||
|
||||
register_shutdown_function('sd');
|
||||
|
||||
bar();
|
||||
|
||||
/* Will output
|
||||
Fatal error: Call to undefined function fatal() in foo.php on line 42
|
||||
array(3) {
|
||||
[0]=>
|
||||
array(2) {
|
||||
["function"]=>
|
||||
string(2) "sd"
|
||||
["args"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[1]=>
|
||||
array(4) {
|
||||
["file"]=>
|
||||
string(7) "foo.php"
|
||||
["line"]=>
|
||||
int(1)
|
||||
["function"]=>
|
||||
string(3) "foo"
|
||||
["args"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
[2]=>
|
||||
array(4) {
|
||||
["file"]=>
|
||||
string(102) "foo.php"
|
||||
["line"]=>
|
||||
int(2)
|
||||
["function"]=>
|
||||
string(3) "bar"
|
||||
["args"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To enable the extension from source, run:
|
||||
|
||||
```
|
||||
phpize
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
63
vendor/symfony/debug/Resources/ext/config.m4
vendored
63
vendor/symfony/debug/Resources/ext/config.m4
vendored
@@ -1,63 +0,0 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension symfony_debug
|
||||
|
||||
dnl Comments in this file start with the string 'dnl'.
|
||||
dnl Remove where necessary. This file will not work
|
||||
dnl without editing.
|
||||
|
||||
dnl If your extension references something external, use with:
|
||||
|
||||
dnl PHP_ARG_WITH(symfony_debug, for symfony_debug support,
|
||||
dnl Make sure that the comment is aligned:
|
||||
dnl [ --with-symfony_debug Include symfony_debug support])
|
||||
|
||||
dnl Otherwise use enable:
|
||||
|
||||
PHP_ARG_ENABLE(symfony_debug, whether to enable symfony_debug support,
|
||||
dnl Make sure that the comment is aligned:
|
||||
[ --enable-symfony_debug Enable symfony_debug support])
|
||||
|
||||
if test "$PHP_SYMFONY_DEBUG" != "no"; then
|
||||
dnl Write more examples of tests here...
|
||||
|
||||
dnl # --with-symfony_debug -> check with-path
|
||||
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
|
||||
dnl SEARCH_FOR="/include/symfony_debug.h" # you most likely want to change this
|
||||
dnl if test -r $PHP_SYMFONY_DEBUG/$SEARCH_FOR; then # path given as parameter
|
||||
dnl SYMFONY_DEBUG_DIR=$PHP_SYMFONY_DEBUG
|
||||
dnl else # search default path list
|
||||
dnl AC_MSG_CHECKING([for symfony_debug files in default path])
|
||||
dnl for i in $SEARCH_PATH ; do
|
||||
dnl if test -r $i/$SEARCH_FOR; then
|
||||
dnl SYMFONY_DEBUG_DIR=$i
|
||||
dnl AC_MSG_RESULT(found in $i)
|
||||
dnl fi
|
||||
dnl done
|
||||
dnl fi
|
||||
dnl
|
||||
dnl if test -z "$SYMFONY_DEBUG_DIR"; then
|
||||
dnl AC_MSG_RESULT([not found])
|
||||
dnl AC_MSG_ERROR([Please reinstall the symfony_debug distribution])
|
||||
dnl fi
|
||||
|
||||
dnl # --with-symfony_debug -> add include path
|
||||
dnl PHP_ADD_INCLUDE($SYMFONY_DEBUG_DIR/include)
|
||||
|
||||
dnl # --with-symfony_debug -> check for lib and symbol presence
|
||||
dnl LIBNAME=symfony_debug # you may want to change this
|
||||
dnl LIBSYMBOL=symfony_debug # you most likely want to change this
|
||||
|
||||
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
|
||||
dnl [
|
||||
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SYMFONY_DEBUG_DIR/lib, SYMFONY_DEBUG_SHARED_LIBADD)
|
||||
dnl AC_DEFINE(HAVE_SYMFONY_DEBUGLIB,1,[ ])
|
||||
dnl ],[
|
||||
dnl AC_MSG_ERROR([wrong symfony_debug lib version or lib not found])
|
||||
dnl ],[
|
||||
dnl -L$SYMFONY_DEBUG_DIR/lib -lm
|
||||
dnl ])
|
||||
dnl
|
||||
dnl PHP_SUBST(SYMFONY_DEBUG_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(symfony_debug, symfony_debug.c, $ext_shared)
|
||||
fi
|
13
vendor/symfony/debug/Resources/ext/config.w32
vendored
13
vendor/symfony/debug/Resources/ext/config.w32
vendored
@@ -1,13 +0,0 @@
|
||||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
// If your extension references something external, use ARG_WITH
|
||||
// ARG_WITH("symfony_debug", "for symfony_debug support", "no");
|
||||
|
||||
// Otherwise, use ARG_ENABLE
|
||||
// ARG_ENABLE("symfony_debug", "enable symfony_debug support", "no");
|
||||
|
||||
if (PHP_SYMFONY_DEBUG != "no") {
|
||||
EXTENSION("symfony_debug", "symfony_debug.c");
|
||||
}
|
||||
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PHP_SYMFONY_DEBUG_H
|
||||
#define PHP_SYMFONY_DEBUG_H
|
||||
|
||||
extern zend_module_entry symfony_debug_module_entry;
|
||||
#define phpext_symfony_debug_ptr &symfony_debug_module_entry
|
||||
|
||||
#define PHP_SYMFONY_DEBUG_VERSION "2.7"
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# define PHP_SYMFONY_DEBUG_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define PHP_SYMFONY_DEBUG_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
# define PHP_SYMFONY_DEBUG_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(symfony_debug)
|
||||
intptr_t req_rand_init;
|
||||
void (*old_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
||||
zval *debug_bt;
|
||||
ZEND_END_MODULE_GLOBALS(symfony_debug)
|
||||
|
||||
PHP_MINIT_FUNCTION(symfony_debug);
|
||||
PHP_MSHUTDOWN_FUNCTION(symfony_debug);
|
||||
PHP_RINIT_FUNCTION(symfony_debug);
|
||||
PHP_RSHUTDOWN_FUNCTION(symfony_debug);
|
||||
PHP_MINFO_FUNCTION(symfony_debug);
|
||||
PHP_GINIT_FUNCTION(symfony_debug);
|
||||
PHP_GSHUTDOWN_FUNCTION(symfony_debug);
|
||||
|
||||
PHP_FUNCTION(symfony_zval_info);
|
||||
PHP_FUNCTION(symfony_debug_backtrace);
|
||||
|
||||
static char *_symfony_debug_memory_address_hash(void * TSRMLS_DC);
|
||||
static const char *_symfony_debug_zval_type(zval *);
|
||||
static const char* _symfony_debug_get_resource_type(long TSRMLS_DC);
|
||||
static int _symfony_debug_get_resource_refcount(long TSRMLS_DC);
|
||||
|
||||
void symfony_debug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
|
||||
|
||||
#ifdef ZTS
|
||||
#define SYMFONY_DEBUG_G(v) TSRMG(symfony_debug_globals_id, zend_symfony_debug_globals *, v)
|
||||
#else
|
||||
#define SYMFONY_DEBUG_G(v) (symfony_debug_globals.v)
|
||||
#endif
|
||||
|
||||
#endif /* PHP_SYMFONY_DEBUG_H */
|
283
vendor/symfony/debug/Resources/ext/symfony_debug.c
vendored
283
vendor/symfony/debug/Resources/ext/symfony_debug.c
vendored
@@ -1,283 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
#include "php_ini.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_symfony_debug.h"
|
||||
#include "ext/standard/php_rand.h"
|
||||
#include "ext/standard/php_lcg.h"
|
||||
#include "ext/spl/php_spl.h"
|
||||
#include "Zend/zend_gc.h"
|
||||
#include "Zend/zend_builtin_functions.h"
|
||||
#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */
|
||||
#include "ext/standard/php_array.h"
|
||||
#include "Zend/zend_interfaces.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
#define IS_PHP_53 ZEND_EXTENSION_API_NO == 220090626
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(symfony_debug)
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(symfony_zval_arginfo, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, key)
|
||||
ZEND_ARG_ARRAY_INFO(0, array, 0)
|
||||
ZEND_ARG_INFO(0, options)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
const zend_function_entry symfony_debug_functions[] = {
|
||||
PHP_FE(symfony_zval_info, symfony_zval_arginfo)
|
||||
PHP_FE(symfony_debug_backtrace, NULL)
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
PHP_FUNCTION(symfony_debug_backtrace)
|
||||
{
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
}
|
||||
#if IS_PHP_53
|
||||
zend_fetch_debug_backtrace(return_value, 1, 0 TSRMLS_CC);
|
||||
#else
|
||||
zend_fetch_debug_backtrace(return_value, 1, 0, 0 TSRMLS_CC);
|
||||
#endif
|
||||
|
||||
if (!SYMFONY_DEBUG_G(debug_bt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
php_array_merge(Z_ARRVAL_P(return_value), Z_ARRVAL_P(SYMFONY_DEBUG_G(debug_bt)), 0 TSRMLS_CC);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(symfony_zval_info)
|
||||
{
|
||||
zval *key = NULL, *arg = NULL;
|
||||
zval **data = NULL;
|
||||
HashTable *array = NULL;
|
||||
long options = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zh|l", &key, &array, &options) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Z_TYPE_P(key)) {
|
||||
case IS_STRING:
|
||||
if (zend_symtable_find(array, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&data) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case IS_LONG:
|
||||
if (zend_hash_index_find(array, Z_LVAL_P(key), (void **)&data)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
arg = *data;
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
add_assoc_string(return_value, "type", (char *)_symfony_debug_zval_type(arg), 1);
|
||||
add_assoc_stringl(return_value, "zval_hash", _symfony_debug_memory_address_hash((void *)arg TSRMLS_CC), 16, 0);
|
||||
add_assoc_long(return_value, "zval_refcount", Z_REFCOUNT_P(arg));
|
||||
add_assoc_bool(return_value, "zval_isref", (zend_bool)Z_ISREF_P(arg));
|
||||
|
||||
if (Z_TYPE_P(arg) == IS_OBJECT) {
|
||||
char hash[33] = {0};
|
||||
|
||||
php_spl_object_hash(arg, (char *)hash TSRMLS_CC);
|
||||
add_assoc_stringl(return_value, "object_class", (char *)Z_OBJCE_P(arg)->name, Z_OBJCE_P(arg)->name_length, 1);
|
||||
add_assoc_long(return_value, "object_refcount", EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(arg)].bucket.obj.refcount);
|
||||
add_assoc_string(return_value, "object_hash", hash, 1);
|
||||
add_assoc_long(return_value, "object_handle", Z_OBJ_HANDLE_P(arg));
|
||||
} else if (Z_TYPE_P(arg) == IS_ARRAY) {
|
||||
add_assoc_long(return_value, "array_count", zend_hash_num_elements(Z_ARRVAL_P(arg)));
|
||||
} else if(Z_TYPE_P(arg) == IS_RESOURCE) {
|
||||
add_assoc_long(return_value, "resource_handle", Z_LVAL_P(arg));
|
||||
add_assoc_string(return_value, "resource_type", (char *)_symfony_debug_get_resource_type(Z_LVAL_P(arg) TSRMLS_CC), 1);
|
||||
add_assoc_long(return_value, "resource_refcount", _symfony_debug_get_resource_refcount(Z_LVAL_P(arg) TSRMLS_CC));
|
||||
} else if (Z_TYPE_P(arg) == IS_STRING) {
|
||||
add_assoc_long(return_value, "strlen", Z_STRLEN_P(arg));
|
||||
}
|
||||
}
|
||||
|
||||
void symfony_debug_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
zval *retval;
|
||||
|
||||
switch (type) {
|
||||
case E_ERROR:
|
||||
case E_PARSE:
|
||||
case E_CORE_ERROR:
|
||||
case E_CORE_WARNING:
|
||||
case E_COMPILE_ERROR:
|
||||
case E_COMPILE_WARNING:
|
||||
ALLOC_INIT_ZVAL(retval);
|
||||
#if IS_PHP_53
|
||||
zend_fetch_debug_backtrace(retval, 1, 0 TSRMLS_CC);
|
||||
#else
|
||||
zend_fetch_debug_backtrace(retval, 1, 0, 0 TSRMLS_CC);
|
||||
#endif
|
||||
SYMFONY_DEBUG_G(debug_bt) = retval;
|
||||
}
|
||||
|
||||
SYMFONY_DEBUG_G(old_error_cb)(type, error_filename, error_lineno, format, args);
|
||||
}
|
||||
|
||||
static const char* _symfony_debug_get_resource_type(long rsid TSRMLS_DC)
|
||||
{
|
||||
const char *res_type;
|
||||
res_type = zend_rsrc_list_get_rsrc_type(rsid TSRMLS_CC);
|
||||
|
||||
if (!res_type) {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
return res_type;
|
||||
}
|
||||
|
||||
static int _symfony_debug_get_resource_refcount(long rsid TSRMLS_DC)
|
||||
{
|
||||
zend_rsrc_list_entry *le;
|
||||
|
||||
if (zend_hash_index_find(&EG(regular_list), rsid, (void **) &le)==SUCCESS) {
|
||||
return le->refcount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *_symfony_debug_memory_address_hash(void *address TSRMLS_DC)
|
||||
{
|
||||
char *result = NULL;
|
||||
intptr_t address_rand;
|
||||
|
||||
if (!SYMFONY_DEBUG_G(req_rand_init)) {
|
||||
if (!BG(mt_rand_is_seeded)) {
|
||||
php_mt_srand(GENERATE_SEED() TSRMLS_CC);
|
||||
}
|
||||
SYMFONY_DEBUG_G(req_rand_init) = (intptr_t)php_mt_rand(TSRMLS_C);
|
||||
}
|
||||
|
||||
address_rand = (intptr_t)address ^ SYMFONY_DEBUG_G(req_rand_init);
|
||||
|
||||
spprintf(&result, 17, "%016zx", address_rand);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static const char *_symfony_debug_zval_type(zval *zv)
|
||||
{
|
||||
switch (Z_TYPE_P(zv)) {
|
||||
case IS_NULL:
|
||||
return "NULL";
|
||||
break;
|
||||
|
||||
case IS_BOOL:
|
||||
return "boolean";
|
||||
break;
|
||||
|
||||
case IS_LONG:
|
||||
return "integer";
|
||||
break;
|
||||
|
||||
case IS_DOUBLE:
|
||||
return "double";
|
||||
break;
|
||||
|
||||
case IS_STRING:
|
||||
return "string";
|
||||
break;
|
||||
|
||||
case IS_ARRAY:
|
||||
return "array";
|
||||
break;
|
||||
|
||||
case IS_OBJECT:
|
||||
return "object";
|
||||
|
||||
case IS_RESOURCE:
|
||||
return "resource";
|
||||
|
||||
default:
|
||||
return "unknown type";
|
||||
}
|
||||
}
|
||||
|
||||
zend_module_entry symfony_debug_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"symfony_debug",
|
||||
symfony_debug_functions,
|
||||
PHP_MINIT(symfony_debug),
|
||||
PHP_MSHUTDOWN(symfony_debug),
|
||||
PHP_RINIT(symfony_debug),
|
||||
PHP_RSHUTDOWN(symfony_debug),
|
||||
PHP_MINFO(symfony_debug),
|
||||
PHP_SYMFONY_DEBUG_VERSION,
|
||||
PHP_MODULE_GLOBALS(symfony_debug),
|
||||
PHP_GINIT(symfony_debug),
|
||||
PHP_GSHUTDOWN(symfony_debug),
|
||||
NULL,
|
||||
STANDARD_MODULE_PROPERTIES_EX
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_SYMFONY_DEBUG
|
||||
ZEND_GET_MODULE(symfony_debug)
|
||||
#endif
|
||||
|
||||
PHP_GINIT_FUNCTION(symfony_debug)
|
||||
{
|
||||
memset(symfony_debug_globals, 0 , sizeof(*symfony_debug_globals));
|
||||
}
|
||||
|
||||
PHP_GSHUTDOWN_FUNCTION(symfony_debug)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(symfony_debug)
|
||||
{
|
||||
SYMFONY_DEBUG_G(old_error_cb) = zend_error_cb;
|
||||
zend_error_cb = symfony_debug_error_cb;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(symfony_debug)
|
||||
{
|
||||
zend_error_cb = SYMFONY_DEBUG_G(old_error_cb);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_RINIT_FUNCTION(symfony_debug)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_RSHUTDOWN_FUNCTION(symfony_debug)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINFO_FUNCTION(symfony_debug)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "Symfony Debug support", "enabled");
|
||||
php_info_print_table_header(2, "Symfony Debug version", PHP_SYMFONY_DEBUG_VERSION);
|
||||
php_info_print_table_end();
|
||||
}
|
155
vendor/symfony/debug/Resources/ext/tests/001.phpt
vendored
155
vendor/symfony/debug/Resources/ext/tests/001.phpt
vendored
@@ -1,155 +0,0 @@
|
||||
--TEST--
|
||||
Test symfony_zval_info API
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('symfony_debug')) {
|
||||
echo 'skip';
|
||||
} ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$int = 42;
|
||||
$float = 42.42;
|
||||
$str = 'foobar';
|
||||
$object = new StdClass();
|
||||
$array = array('foo', 'bar');
|
||||
$resource = tmpfile();
|
||||
$null = null;
|
||||
$bool = true;
|
||||
|
||||
$anotherint = 42;
|
||||
$refcount2 = &$anotherint;
|
||||
|
||||
$var = array(
|
||||
'int' => $int,
|
||||
'float' => $float,
|
||||
'str' => $str,
|
||||
'object' => $object,
|
||||
'array' => $array,
|
||||
'resource' => $resource,
|
||||
'null' => $null,
|
||||
'bool' => $bool,
|
||||
'refcount' => &$refcount2,
|
||||
);
|
||||
|
||||
var_dump(symfony_zval_info('int', $var));
|
||||
var_dump(symfony_zval_info('float', $var));
|
||||
var_dump(symfony_zval_info('str', $var));
|
||||
var_dump(symfony_zval_info('object', $var));
|
||||
var_dump(symfony_zval_info('array', $var));
|
||||
var_dump(symfony_zval_info('resource', $var));
|
||||
var_dump(symfony_zval_info('null', $var));
|
||||
var_dump(symfony_zval_info('bool', $var));
|
||||
|
||||
var_dump(symfony_zval_info('refcount', $var));
|
||||
var_dump(symfony_zval_info('not-exist', $var));
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(4) {
|
||||
["type"]=>
|
||||
string(7) "integer"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
}
|
||||
array(4) {
|
||||
["type"]=>
|
||||
string(6) "double"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
}
|
||||
array(5) {
|
||||
["type"]=>
|
||||
string(6) "string"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
["strlen"]=>
|
||||
int(6)
|
||||
}
|
||||
array(8) {
|
||||
["type"]=>
|
||||
string(6) "object"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
["object_class"]=>
|
||||
string(8) "stdClass"
|
||||
["object_refcount"]=>
|
||||
int(1)
|
||||
["object_hash"]=>
|
||||
string(32) "%s"
|
||||
["object_handle"]=>
|
||||
int(%d)
|
||||
}
|
||||
array(5) {
|
||||
["type"]=>
|
||||
string(5) "array"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
["array_count"]=>
|
||||
int(2)
|
||||
}
|
||||
array(7) {
|
||||
["type"]=>
|
||||
string(8) "resource"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
["resource_handle"]=>
|
||||
int(%d)
|
||||
["resource_type"]=>
|
||||
string(6) "stream"
|
||||
["resource_refcount"]=>
|
||||
int(1)
|
||||
}
|
||||
array(4) {
|
||||
["type"]=>
|
||||
string(4) "NULL"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
}
|
||||
array(4) {
|
||||
["type"]=>
|
||||
string(7) "boolean"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(2)
|
||||
["zval_isref"]=>
|
||||
bool(false)
|
||||
}
|
||||
array(4) {
|
||||
["type"]=>
|
||||
string(7) "integer"
|
||||
["zval_hash"]=>
|
||||
string(16) "%s"
|
||||
["zval_refcount"]=>
|
||||
int(3)
|
||||
["zval_isref"]=>
|
||||
bool(true)
|
||||
}
|
||||
NULL
|
@@ -1,65 +0,0 @@
|
||||
--TEST--
|
||||
Test symfony_debug_backtrace in case of fatal error
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('symfony_debug')) {
|
||||
echo 'skip';
|
||||
} ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function bar()
|
||||
{
|
||||
foo();
|
||||
}
|
||||
|
||||
function foo()
|
||||
{
|
||||
notexist();
|
||||
}
|
||||
|
||||
function bt()
|
||||
{
|
||||
print_r(symfony_debug_backtrace());
|
||||
}
|
||||
|
||||
register_shutdown_function('bt');
|
||||
|
||||
bar();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Call to undefined function notexist() in %s on line %d
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[function] => bt
|
||||
[args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[file] => %s
|
||||
[line] => %d
|
||||
[function] => foo
|
||||
[args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[file] => %s
|
||||
[line] => %d
|
||||
[function] => bar
|
||||
[args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
@@ -1,48 +0,0 @@
|
||||
--TEST--
|
||||
Test symfony_debug_backtrace in case of non fatal error
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('symfony_debug')) {
|
||||
echo 'skip';
|
||||
} ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function bar()
|
||||
{
|
||||
bt();
|
||||
}
|
||||
|
||||
function bt()
|
||||
{
|
||||
print_r(symfony_debug_backtrace());
|
||||
}
|
||||
|
||||
bar();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[file] => %s
|
||||
[line] => %d
|
||||
[function] => bt
|
||||
[args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[file] => %s
|
||||
[line] => %d
|
||||
[function] => bar
|
||||
[args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
)
|
@@ -1,87 +0,0 @@
|
||||
--TEST--
|
||||
Test ErrorHandler in case of fatal error
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded('symfony_debug')) {
|
||||
echo 'skip';
|
||||
} ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
class LogLevel
|
||||
{
|
||||
const EMERGENCY = 'emergency';
|
||||
const ALERT = 'alert';
|
||||
const CRITICAL = 'critical';
|
||||
const ERROR = 'error';
|
||||
const WARNING = 'warning';
|
||||
const NOTICE = 'notice';
|
||||
const INFO = 'info';
|
||||
const DEBUG = 'debug';
|
||||
}
|
||||
|
||||
namespace Symfony\Component\Debug;
|
||||
|
||||
$dir = __DIR__.'/../../../';
|
||||
require $dir.'ErrorHandler.php';
|
||||
require $dir.'Exception/FatalErrorException.php';
|
||||
require $dir.'Exception/UndefinedFunctionException.php';
|
||||
require $dir.'FatalErrorHandler/FatalErrorHandlerInterface.php';
|
||||
require $dir.'FatalErrorHandler/ClassNotFoundFatalErrorHandler.php';
|
||||
require $dir.'FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php';
|
||||
require $dir.'FatalErrorHandler/UndefinedMethodFatalErrorHandler.php';
|
||||
|
||||
function bar()
|
||||
{
|
||||
foo();
|
||||
}
|
||||
|
||||
function foo()
|
||||
{
|
||||
notexist();
|
||||
}
|
||||
|
||||
$handler = ErrorHandler::register();
|
||||
$handler->setExceptionHandler('print_r');
|
||||
|
||||
if (\function_exists('xdebug_disable')) {
|
||||
xdebug_disable();
|
||||
}
|
||||
|
||||
bar();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Call to undefined function Symfony\Component\Debug\notexist() in %s on line %d
|
||||
Symfony\Component\Debug\Exception\UndefinedFunctionException Object
|
||||
(
|
||||
[message:protected] => Attempted to call function "notexist" from namespace "Symfony\Component\Debug".
|
||||
[string:Exception:private] =>
|
||||
[code:protected] => 0
|
||||
[file:protected] => %s
|
||||
[line:protected] => %d
|
||||
[trace:Exception:private] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
%A [function] => Symfony\Component\Debug\foo
|
||||
%A [args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
%A [function] => Symfony\Component\Debug\bar
|
||||
%A [args] => Array
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
%A
|
||||
)
|
||||
|
||||
[previous:Exception:private] =>
|
||||
[severity:protected] => 1
|
||||
)
|
100
vendor/symfony/debug/Tests/DebugClassLoaderTest.php
vendored
100
vendor/symfony/debug/Tests/DebugClassLoaderTest.php
vendored
@@ -13,7 +13,6 @@ namespace Symfony\Component\Debug\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\DebugClassLoader;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
|
||||
class DebugClassLoaderTest extends TestCase
|
||||
{
|
||||
@@ -76,72 +75,8 @@ class DebugClassLoaderTest extends TestCase
|
||||
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
|
||||
}
|
||||
|
||||
public function testUnsilencing()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
|
||||
}
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM is not handled in this test case.');
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
$this->iniSet('log_errors', 0);
|
||||
$this->iniSet('display_errors', 1);
|
||||
|
||||
// See below: this will fail with parse error
|
||||
// but this should not be @-silenced.
|
||||
@class_exists(__NAMESPACE__.'\TestingUnsilencing', true);
|
||||
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertStringMatchesFormat('%aParse error%a', $output);
|
||||
}
|
||||
|
||||
public function testStacking()
|
||||
{
|
||||
// the ContextErrorException must not be loaded to test the workaround
|
||||
// for https://bugs.php.net/65322.
|
||||
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
|
||||
$this->markTestSkipped('The ContextErrorException class is already loaded.');
|
||||
}
|
||||
if (defined('HHVM_VERSION')) {
|
||||
$this->markTestSkipped('HHVM is not handled in this test case.');
|
||||
}
|
||||
|
||||
ErrorHandler::register();
|
||||
|
||||
try {
|
||||
// Trigger autoloading + E_STRICT at compile time
|
||||
// which in turn triggers $errorHandler->handle()
|
||||
// that again triggers autoloading for ContextErrorException.
|
||||
// Error stacking works around the bug above and everything is fine.
|
||||
|
||||
eval('
|
||||
namespace '.__NAMESPACE__.';
|
||||
class ChildTestingStacking extends TestingStacking { function foo($bar) {} }
|
||||
');
|
||||
$this->fail('ContextErrorException expected');
|
||||
} catch (\ErrorException $exception) {
|
||||
// if an exception is thrown, the test passed
|
||||
$this->assertStringStartsWith(__FILE__, $exception->getFile());
|
||||
if (\PHP_VERSION_ID < 70000) {
|
||||
$this->assertRegExp('/^Runtime Notice: Declaration/', $exception->getMessage());
|
||||
$this->assertEquals(E_STRICT, $exception->getSeverity());
|
||||
} else {
|
||||
$this->assertRegExp('/^Warning: Declaration/', $exception->getMessage());
|
||||
$this->assertEquals(E_WARNING, $exception->getSeverity());
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Case mismatch between loaded and declared class names
|
||||
*/
|
||||
public function testNameCaseMismatch()
|
||||
{
|
||||
@@ -163,7 +98,6 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Case mismatch between loaded and declared class names
|
||||
*/
|
||||
public function testPsr4CaseMismatch()
|
||||
{
|
||||
@@ -262,32 +196,6 @@ class DebugClassLoaderTest extends TestCase
|
||||
$this->assertSame($xError, $lastError);
|
||||
}
|
||||
|
||||
public function testReservedForPhp7()
|
||||
{
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
$this->markTestSkipped('PHP7 already prevents using reserved names.');
|
||||
}
|
||||
|
||||
set_error_handler(function () { return false; });
|
||||
$e = error_reporting(0);
|
||||
trigger_error('', E_USER_NOTICE);
|
||||
|
||||
class_exists('Test\\'.__NAMESPACE__.'\\Float', true);
|
||||
|
||||
error_reporting($e);
|
||||
restore_error_handler();
|
||||
|
||||
$lastError = error_get_last();
|
||||
unset($lastError['file'], $lastError['line']);
|
||||
|
||||
$xError = array(
|
||||
'type' => E_USER_DEPRECATED,
|
||||
'message' => 'The "Test\Symfony\Component\Debug\Tests\Float" class uses the reserved name "Float", it will break on PHP 7 and higher',
|
||||
);
|
||||
|
||||
$this->assertSame($xError, $lastError);
|
||||
}
|
||||
|
||||
public function testExtendedFinalClass()
|
||||
{
|
||||
set_error_handler(function () { return false; });
|
||||
@@ -304,7 +212,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
$xError = array(
|
||||
'type' => E_USER_DEPRECATED,
|
||||
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass" class is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass".',
|
||||
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalClass" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsFinalClass".',
|
||||
);
|
||||
|
||||
$this->assertSame($xError, $lastError);
|
||||
@@ -326,7 +234,7 @@ class DebugClassLoaderTest extends TestCase
|
||||
|
||||
$xError = array(
|
||||
'type' => E_USER_DEPRECATED,
|
||||
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".',
|
||||
'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".',
|
||||
);
|
||||
|
||||
$this->assertSame($xError, $lastError);
|
||||
@@ -361,10 +269,10 @@ class DebugClassLoaderTest extends TestCase
|
||||
restore_error_handler();
|
||||
|
||||
$this->assertSame($deprecations, array(
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal since version 3.4. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\InternalInterface" interface is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait" trait is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait2::internalMethod()" method is considered internal since version 3.4. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".',
|
||||
'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait2::internalMethod()" method is considered internal. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
82
vendor/symfony/debug/Tests/ErrorHandlerTest.php
vendored
82
vendor/symfony/debug/Tests/ErrorHandlerTest.php
vendored
@@ -323,9 +323,6 @@ class ErrorHandlerTest extends TestCase
|
||||
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group no-hhvm
|
||||
*/
|
||||
public function testHandleException()
|
||||
{
|
||||
try {
|
||||
@@ -367,38 +364,6 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testErrorStacking()
|
||||
{
|
||||
try {
|
||||
$handler = ErrorHandler::register();
|
||||
$handler->screamAt(E_USER_WARNING);
|
||||
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
|
||||
$logger
|
||||
->expects($this->exactly(2))
|
||||
->method('log')
|
||||
->withConsecutive(
|
||||
array($this->equalTo(LogLevel::WARNING), $this->equalTo('Dummy log')),
|
||||
array($this->equalTo(LogLevel::DEBUG), $this->equalTo('User Warning: Silenced warning'))
|
||||
)
|
||||
;
|
||||
|
||||
$handler->setDefaultLogger($logger, array(E_USER_WARNING => LogLevel::WARNING));
|
||||
|
||||
ErrorHandler::stackErrors();
|
||||
@trigger_error('Silenced warning', E_USER_WARNING);
|
||||
$logger->log(LogLevel::WARNING, 'Dummy log');
|
||||
ErrorHandler::unstackErrors();
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
}
|
||||
}
|
||||
|
||||
public function testBootstrappingLogger()
|
||||
{
|
||||
$bootLogger = new BufferingLogger();
|
||||
@@ -450,9 +415,6 @@ class ErrorHandlerTest extends TestCase
|
||||
$handler->setLoggers(array(E_DEPRECATED => array($mockLogger, LogLevel::WARNING)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group no-hhvm
|
||||
*/
|
||||
public function testSettingLoggerWhenExceptionIsBuffered()
|
||||
{
|
||||
$bootLogger = new BufferingLogger();
|
||||
@@ -472,9 +434,6 @@ class ErrorHandlerTest extends TestCase
|
||||
$handler->handleException($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group no-hhvm
|
||||
*/
|
||||
public function testHandleFatalError()
|
||||
{
|
||||
try {
|
||||
@@ -515,9 +474,6 @@ class ErrorHandlerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testHandleErrorException()
|
||||
{
|
||||
$exception = new \Error("Class 'Foo' not found");
|
||||
@@ -533,46 +489,8 @@ class ErrorHandlerTest extends TestCase
|
||||
$this->assertStringStartsWith("Attempted to load class \"Foo\" from the global namespace.\nDid you forget a \"use\" statement", $args[0]->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group no-hhvm
|
||||
*/
|
||||
public function testHandleFatalErrorOnHHVM()
|
||||
{
|
||||
try {
|
||||
$handler = ErrorHandler::register();
|
||||
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('log')
|
||||
->with(
|
||||
$this->equalTo(LogLevel::CRITICAL),
|
||||
$this->equalTo('Fatal Error: foo')
|
||||
)
|
||||
;
|
||||
|
||||
$handler->setDefaultLogger($logger, E_ERROR);
|
||||
|
||||
$error = array(
|
||||
'type' => E_ERROR + 0x1000000, // This error level is used by HHVM for fatal errors
|
||||
'message' => 'foo',
|
||||
'file' => 'bar',
|
||||
'line' => 123,
|
||||
'context' => array(123),
|
||||
'backtrace' => array(456),
|
||||
);
|
||||
|
||||
\call_user_func_array(array($handler, 'handleError'), $error);
|
||||
$handler->handleFatalError($error);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
restore_exception_handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @group no-hhvm
|
||||
*/
|
||||
public function testCustomExceptionHandler()
|
||||
{
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Debug\Tests\Exception;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
@@ -39,6 +40,12 @@ class FlattenExceptionTest extends TestCase
|
||||
$flattened = FlattenException::create(new \RuntimeException());
|
||||
$this->assertEquals('500', $flattened->getStatusCode());
|
||||
|
||||
$flattened = FlattenException::createFromThrowable(new \DivisionByZeroError(), 403);
|
||||
$this->assertEquals('403', $flattened->getStatusCode());
|
||||
|
||||
$flattened = FlattenException::createFromThrowable(new \DivisionByZeroError());
|
||||
$this->assertEquals('500', $flattened->getStatusCode());
|
||||
|
||||
$flattened = FlattenException::create(new NotFoundHttpException());
|
||||
$this->assertEquals('404', $flattened->getStatusCode());
|
||||
|
||||
@@ -111,10 +118,10 @@ class FlattenExceptionTest extends TestCase
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testFlattenHttpException(\Exception $exception)
|
||||
public function testFlattenHttpException(\Throwable $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened2 = FlattenException::create($exception);
|
||||
$flattened = FlattenException::createFromThrowable($exception);
|
||||
$flattened2 = FlattenException::createFromThrowable($exception);
|
||||
|
||||
$flattened->setPrevious($flattened2);
|
||||
|
||||
@@ -123,13 +130,33 @@ class FlattenExceptionTest extends TestCase
|
||||
$this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception');
|
||||
}
|
||||
|
||||
public function testWrappedThrowable()
|
||||
{
|
||||
$exception = new FatalThrowableError(new \DivisionByZeroError('Ouch', 42));
|
||||
$flattened = FlattenException::create($exception);
|
||||
|
||||
$this->assertSame('Ouch', $flattened->getMessage(), 'The message is copied from the original error.');
|
||||
$this->assertSame(42, $flattened->getCode(), 'The code is copied from the original error.');
|
||||
$this->assertSame('DivisionByZeroError', $flattened->getClass(), 'The class is set to the class of the original error');
|
||||
}
|
||||
|
||||
public function testThrowable()
|
||||
{
|
||||
$error = new \DivisionByZeroError('Ouch', 42);
|
||||
$flattened = FlattenException::createFromThrowable($error);
|
||||
|
||||
$this->assertSame('Ouch', $flattened->getMessage(), 'The message is copied from the original error.');
|
||||
$this->assertSame(42, $flattened->getCode(), 'The code is copied from the original error.');
|
||||
$this->assertSame('DivisionByZeroError', $flattened->getClass(), 'The class is set to the class of the original error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testPrevious(\Exception $exception)
|
||||
public function testPrevious(\Throwable $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened2 = FlattenException::create($exception);
|
||||
$flattened = FlattenException::createFromThrowable($exception);
|
||||
$flattened2 = FlattenException::createFromThrowable($exception);
|
||||
|
||||
$flattened->setPrevious($flattened2);
|
||||
|
||||
@@ -138,50 +165,47 @@ class FlattenExceptionTest extends TestCase
|
||||
$this->assertSame(array($flattened2), $flattened->getAllPrevious());
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
public function testPreviousError()
|
||||
{
|
||||
$exception = new \Exception('test', 123, new \ParseError('Oh noes!', 42));
|
||||
|
||||
$flattened = FlattenException::create($exception)->getPrevious();
|
||||
|
||||
$this->assertEquals($flattened->getMessage(), 'Parse error: Oh noes!', 'The message is copied from the original exception.');
|
||||
$this->assertEquals($flattened->getMessage(), 'Oh noes!', 'The message is copied from the original exception.');
|
||||
$this->assertEquals($flattened->getCode(), 42, 'The code is copied from the original exception.');
|
||||
$this->assertEquals($flattened->getClass(), 'Symfony\Component\Debug\Exception\FatalThrowableError', 'The class is set to the class of the original exception');
|
||||
$this->assertEquals($flattened->getClass(), 'ParseError', 'The class is set to the class of the original exception');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testLine(\Exception $exception)
|
||||
public function testLine(\Throwable $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened = FlattenException::createFromThrowable($exception);
|
||||
$this->assertSame($exception->getLine(), $flattened->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testFile(\Exception $exception)
|
||||
public function testFile(\Throwable $exception)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened = FlattenException::createFromThrowable($exception);
|
||||
$this->assertSame($exception->getFile(), $flattened->getFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider flattenDataProvider
|
||||
*/
|
||||
public function testToArray(\Exception $exception)
|
||||
public function testToArray(\Throwable $exception, string $expectedClass)
|
||||
{
|
||||
$flattened = FlattenException::create($exception);
|
||||
$flattened = FlattenException::createFromThrowable($exception);
|
||||
$flattened->setTrace(array(), 'foo.php', 123);
|
||||
|
||||
$this->assertEquals(array(
|
||||
array(
|
||||
'message' => 'test',
|
||||
'class' => 'Exception',
|
||||
'class' => $expectedClass,
|
||||
'trace' => array(array(
|
||||
'namespace' => '', 'short_class' => '', 'class' => '', 'type' => '', 'function' => '', 'file' => 'foo.php', 'line' => 123,
|
||||
'args' => array(),
|
||||
@@ -190,10 +214,24 @@ class FlattenExceptionTest extends TestCase
|
||||
), $flattened->toArray());
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$exception = new NotFoundHttpException(
|
||||
'test',
|
||||
new \RuntimeException('previous', 123)
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
FlattenException::createFromThrowable($exception)->toArray(),
|
||||
FlattenException::create($exception)->toArray()
|
||||
);
|
||||
}
|
||||
|
||||
public function flattenDataProvider()
|
||||
{
|
||||
return array(
|
||||
array(new \Exception('test', 123)),
|
||||
array(new \Exception('test', 123), 'Exception'),
|
||||
array(new \Error('test', 123), 'Error'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -236,7 +274,7 @@ class FlattenExceptionTest extends TestCase
|
||||
$this->assertSame(array('object', 'stdClass'), $array[$i++]);
|
||||
$this->assertSame(array('object', 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'), $array[$i++]);
|
||||
$this->assertSame(array('incomplete-object', 'BogusTestClass'), $array[$i++]);
|
||||
$this->assertSame(array('resource', \defined('HHVM_VERSION') ? 'Directory' : 'stream'), $array[$i++]);
|
||||
$this->assertSame(array('resource', 'stream'), $array[$i++]);
|
||||
$this->assertSame(array('resource', 'stream'), $array[$i++]);
|
||||
|
||||
$args = $array[$i++];
|
||||
|
@@ -26,7 +26,7 @@ class UndefinedFunctionFatalErrorHandlerTest extends TestCase
|
||||
$exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line']));
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception);
|
||||
// class names are case insensitive and PHP/HHVM do not return the same
|
||||
// class names are case insensitive and PHP do not return the same
|
||||
$this->assertSame(strtolower($translatedMessage), strtolower($exception->getMessage()));
|
||||
$this->assertSame($error['type'], $exception->getSeverity());
|
||||
$this->assertSame($error['file'], $exception->getFile());
|
||||
|
@@ -5,7 +5,7 @@ namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
class AnnotatedClass
|
||||
{
|
||||
/**
|
||||
* @deprecated since version 3.4.
|
||||
* @deprecated
|
||||
*/
|
||||
public function deprecatedMethod()
|
||||
{
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* @final since version 3.3.
|
||||
* @final
|
||||
*/
|
||||
class FinalClass
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
class FinalMethod
|
||||
{
|
||||
/**
|
||||
* @final since version 3.3.
|
||||
* @final
|
||||
*/
|
||||
public function finalMethod()
|
||||
{
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
|
||||
/**
|
||||
* @internal since version 3.4.
|
||||
* @internal
|
||||
*/
|
||||
class InternalClass
|
||||
{
|
||||
|
@@ -8,7 +8,7 @@ namespace Symfony\Component\Debug\Tests\Fixtures;
|
||||
trait InternalTrait2
|
||||
{
|
||||
/**
|
||||
* @internal since version 3.4
|
||||
* @internal
|
||||
*/
|
||||
public function internalMethod()
|
||||
{
|
||||
|
@@ -23,4 +23,4 @@ class_exists(ExtendedFinalMethod::class);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final since version 3.3. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".
|
||||
The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".
|
||||
|
8
vendor/symfony/debug/composer.json
vendored
8
vendor/symfony/debug/composer.json
vendored
@@ -16,14 +16,14 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"php": "^7.1.3",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
|
||||
"symfony/http-kernel": "<3.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/http-kernel": "~2.8|~3.0|~4.0"
|
||||
"symfony/http-kernel": "~3.4|~4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Debug\\": "" },
|
||||
@@ -34,7 +34,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.4-dev"
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user