Skip to content
Browse files

removed vendor to prepare for composer

  • Loading branch information...
1 parent 8410afb commit a65f6d6c28b3361e99d1b53ba6c775d885483723 Alex Knol committed
Showing with 0 additions and 9,879 deletions.
  1. +0 −809 vendor__/Symfony/Component/Console/Application.php
  2. +0 −576 vendor__/Symfony/Component/Console/Command/Command.php
  3. +0 −82 vendor__/Symfony/Component/Console/Command/HelpCommand.php
  4. +0 −67 vendor__/Symfony/Component/Console/Command/ListCommand.php
  5. +0 −243 vendor__/Symfony/Component/Console/Formatter/OutputFormatter.php
  6. +0 −83 vendor__/Symfony/Component/Console/Formatter/OutputFormatterInterface.php
  7. +0 −217 vendor__/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
  8. +0 −77 vendor__/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php
  9. +0 −110 vendor__/Symfony/Component/Console/Helper/DialogHelper.php
  10. +0 −91 vendor__/Symfony/Component/Console/Helper/FormatterHelper.php
  11. +0 −42 vendor__/Symfony/Component/Console/Helper/Helper.php
  12. +0 −49 vendor__/Symfony/Component/Console/Helper/HelperInterface.php
  13. +0 −102 vendor__/Symfony/Component/Console/Helper/HelperSet.php
  14. +0 −307 vendor__/Symfony/Component/Console/Input/ArgvInput.php
  15. +0 −194 vendor__/Symfony/Component/Console/Input/ArrayInput.php
  16. +0 −211 vendor__/Symfony/Component/Console/Input/Input.php
  17. +0 −132 vendor__/Symfony/Component/Console/Input/InputArgument.php
  18. +0 −508 vendor__/Symfony/Component/Console/Input/InputDefinition.php
  19. +0 −103 vendor__/Symfony/Component/Console/Input/InputInterface.php
  20. +0 −182 vendor__/Symfony/Component/Console/Input/InputOption.php
  21. +0 −78 vendor__/Symfony/Component/Console/Input/StringInput.php
  22. +0 −19 vendor__/Symfony/Component/Console/LICENSE
  23. +0 −46 vendor__/Symfony/Component/Console/Output/ConsoleOutput.php
  24. +0 −34 vendor__/Symfony/Component/Console/Output/NullOutput.php
  25. +0 −186 vendor__/Symfony/Component/Console/Output/Output.php
  26. +0 −107 vendor__/Symfony/Component/Console/Output/OutputInterface.php
  27. +0 −112 vendor__/Symfony/Component/Console/Output/StreamOutput.php
  28. +0 −136 vendor__/Symfony/Component/Console/Shell.php
  29. +0 −100 vendor__/Symfony/Component/Console/Tester/ApplicationTester.php
  30. +0 −100 vendor__/Symfony/Component/Console/Tester/CommandTester.php
  31. +0 −72 vendor__/Symfony/Component/Process/ExecutableFinder.php
  32. +0 −19 vendor__/Symfony/Component/Process/LICENSE
  33. +0 −59 vendor__/Symfony/Component/Process/PhpExecutableFinder.php
  34. +0 −78 vendor__/Symfony/Component/Process/PhpProcess.php
  35. +0 −365 vendor__/Symfony/Component/Process/Process.php
  36. BIN vendor__/silex.phar
  37. +0 −61 vendor__/swift/CHANGES
  38. +0 −165 vendor__/swift/LICENSE
  39. +0 −30 vendor__/swift/README
  40. +0 −1 vendor__/swift/VERSION
  41. +0 −57 vendor__/swift/lib/classes/Swift.php
  42. +0 −75 vendor__/swift/lib/classes/Swift/Attachment.php
  43. +0 −178 vendor__/swift/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php
  44. +0 −190 vendor__/swift/lib/classes/Swift/ByteStream/ArrayByteStream.php
  45. +0 −177 vendor__/swift/lib/classes/Swift/ByteStream/FileByteStream.php
  46. +0 −60 vendor__/swift/lib/classes/Swift/CharacterReader.php
  47. +0 −96 vendor__/swift/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php
  48. +0 −83 vendor__/swift/lib/classes/Swift/CharacterReader/UsAsciiReader.php
  49. +0 −183 vendor__/swift/lib/classes/Swift/CharacterReader/Utf8Reader.php
  50. +0 −29 vendor__/swift/lib/classes/Swift/CharacterReaderFactory.php
  51. +0 −119 vendor__/swift/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php
  52. +0 −86 vendor__/swift/lib/classes/Swift/CharacterStream.php
  53. +0 −319 vendor__/swift/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php
  54. +0 −300 vendor__/swift/lib/classes/Swift/CharacterStream/NgCharacterStream.php
  55. +0 −349 vendor__/swift/lib/classes/Swift/DependencyContainer.php
  56. +0 −30 vendor__/swift/lib/classes/Swift/DependencyException.php
  57. +0 −73 vendor__/swift/lib/classes/Swift/EmbeddedFile.php
  58. +0 −32 vendor__/swift/lib/classes/Swift/Encoder.php
  59. +0 −63 vendor__/swift/lib/classes/Swift/Encoder/Base64Encoder.php
  60. +0 −263 vendor__/swift/lib/classes/Swift/Encoder/QpEncoder.php
  61. +0 −89 vendor__/swift/lib/classes/Swift/Encoder/Rfc2231Encoder.php
  62. +0 −70 vendor__/swift/lib/classes/Swift/Encoding.php
  63. +0 −67 vendor__/swift/lib/classes/Swift/Events/CommandEvent.php
  64. +0 −29 vendor__/swift/lib/classes/Swift/Events/CommandListener.php
  65. +0 −39 vendor__/swift/lib/classes/Swift/Events/Event.php
  66. +0 −81 vendor__/swift/lib/classes/Swift/Events/EventDispatcher.php
  67. +0 −19 vendor__/swift/lib/classes/Swift/Events/EventListener.php
  68. +0 −65 vendor__/swift/lib/classes/Swift/Events/EventObject.php
  69. +0 −65 vendor__/swift/lib/classes/Swift/Events/ResponseEvent.php
  70. +0 −29 vendor__/swift/lib/classes/Swift/Events/ResponseListener.php
  71. +0 −127 vendor__/swift/lib/classes/Swift/Events/SendEvent.php
  72. +0 −35 vendor__/swift/lib/classes/Swift/Events/SendListener.php
  73. +0 −175 vendor__/swift/lib/classes/Swift/Events/SimpleEventDispatcher.php
  74. +0 −31 vendor__/swift/lib/classes/Swift/Events/TransportChangeEvent.php
  75. +0 −53 vendor__/swift/lib/classes/Swift/Events/TransportChangeListener.php
  76. +0 −50 vendor__/swift/lib/classes/Swift/Events/TransportExceptionEvent.php
  77. +0 −30 vendor__/swift/lib/classes/Swift/Events/TransportExceptionListener.php
  78. +0 −48 vendor__/swift/lib/classes/Swift/FailoverTransport.php
  79. +0 −28 vendor__/swift/lib/classes/Swift/FileStream.php
  80. +0 −34 vendor__/swift/lib/classes/Swift/Filterable.php
Sorry, we could not display the entire diff because too many files (686) changed.
View
809 vendor__/Symfony/Component/Console/Application.php
@@ -1,809 +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;
-
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Input\ArgvInput;
-use Symfony\Component\Console\Input\ArrayInput;
-use Symfony\Component\Console\Input\InputDefinition;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Output\Output;
-use Symfony\Component\Console\Output\ConsoleOutput;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Command\HelpCommand;
-use Symfony\Component\Console\Command\ListCommand;
-use Symfony\Component\Console\Helper\HelperSet;
-use Symfony\Component\Console\Helper\FormatterHelper;
-use Symfony\Component\Console\Helper\DialogHelper;
-
-/**
- * An Application is the container for a collection of commands.
- *
- * It is the main entry point of a Console application.
- *
- * This class is optimized for a standard CLI environment.
- *
- * Usage:
- *
- * $app = new Application('myapp', '1.0 (stable)');
- * $app->add(new SimpleCommand());
- * $app->run();
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @api
- */
-class Application
-{
- private $commands;
- private $aliases;
- private $wantHelps = false;
- private $runningCommand;
- private $name;
- private $version;
- private $catchExceptions;
- private $autoExit;
- private $definition;
- private $helperSet;
-
- /**
- * Constructor.
- *
- * @param string $name The name of the application
- * @param string $version The version of the application
- *
- * @api
- */
- public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
- {
- $this->name = $name;
- $this->version = $version;
- $this->catchExceptions = true;
- $this->autoExit = true;
- $this->commands = array();
- $this->aliases = array();
- $this->helperSet = new HelperSet(array(
- new FormatterHelper(),
- new DialogHelper(),
- ));
-
- $this->add(new HelpCommand());
- $this->add(new ListCommand());
-
- $this->definition = new InputDefinition(array(
- new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
-
- new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'),
- new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'),
- new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'),
- new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this program version.'),
- new InputOption('--ansi', '-a', InputOption::VALUE_NONE, 'Force ANSI output.'),
- new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'),
- ));
- }
-
- /**
- * Runs the current application.
- *
- * @param InputInterface $input An Input instance
- * @param OutputInterface $output An Output instance
- *
- * @return integer 0 if everything went fine, or an error code
- *
- * @throws \Exception When doRun returns Exception
- *
- * @api
- */
- public function run(InputInterface $input = null, OutputInterface $output = null)
- {
- if (null === $input) {
- $input = new ArgvInput();
- }
-
- if (null === $output) {
- $output = new ConsoleOutput();
- }
-
- try {
- $statusCode = $this->doRun($input, $output);
- } catch (\Exception $e) {
- if (!$this->catchExceptions) {
- throw $e;
- }
-
- $this->renderException($e, $output);
- $statusCode = $e->getCode();
-
- $statusCode = is_numeric($statusCode) && $statusCode ? $statusCode : 1;
- }
-
- if ($this->autoExit) {
- if ($statusCode > 255) {
- $statusCode = 255;
- }
- // @codeCoverageIgnoreStart
- exit($statusCode);
- // @codeCoverageIgnoreEnd
- }
-
- return $statusCode;
- }
-
- /**
- * Runs the current application.
- *
- * @param InputInterface $input An Input instance
- * @param OutputInterface $output An Output instance
- *
- * @return integer 0 if everything went fine, or an error code
- */
- public function doRun(InputInterface $input, OutputInterface $output)
- {
- $name = $this->getCommandName($input);
-
- if (true === $input->hasParameterOption(array('--ansi', '-a'))) {
- $output->setDecorated(true);
- }
-
- if (true === $input->hasParameterOption(array('--help', '-h'))) {
- if (!$name) {
- $name = 'help';
- $input = new ArrayInput(array('command' => 'help'));
- } else {
- $this->wantHelps = true;
- }
- }
-
- if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
- $input->setInteractive(false);
- }
-
- if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
- $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
- } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
- $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
- }
-
- if (true === $input->hasParameterOption(array('--version', '-V'))) {
- $output->writeln($this->getLongVersion());
-
- return 0;
- }
-
- if (!$name) {
- $name = 'list';
- $input = new ArrayInput(array('command' => 'list'));
- }
-
- // the command name MUST be the first element of the input
- $command = $this->find($name);
-
- $this->runningCommand = $command;
- $statusCode = $command->run($input, $output);
- $this->runningCommand = null;
-
- return is_numeric($statusCode) ? $statusCode : 0;
- }
-
- /**
- * Set a helper set to be used with the command.
- *
- * @param HelperSet $helperSet The helper set
- *
- * @api
- */
- public function setHelperSet(HelperSet $helperSet)
- {
- $this->helperSet = $helperSet;
- }
-
- /**
- * Get the helper set associated with the command.
- *
- * @return HelperSet The HelperSet instance associated with this command
- *
- * @api
- */
- public function getHelperSet()
- {
- return $this->helperSet;
- }
-
- /**
- * Gets the InputDefinition related to this Application.
- *
- * @return InputDefinition The InputDefinition instance
- */
- public function getDefinition()
- {
- return $this->definition;
- }
-
- /**
- * Gets the help message.
- *
- * @return string A help message.
- */
- public function getHelp()
- {
- $messages = array(
- $this->getLongVersion(),
- '',
- '<comment>Usage:</comment>',
- sprintf(" [options] command [arguments]\n"),
- '<comment>Options:</comment>',
- );
-
- foreach ($this->getDefinition()->getOptions() as $option) {
- $messages[] = sprintf(' %-29s %s %s',
- '<info>--'.$option->getName().'</info>',
- $option->getShortcut() ? '<info>-'.$option->getShortcut().'</info>' : ' ',
- $option->getDescription()
- );
- }
-
- return implode("\n", $messages);
- }
-
- /**
- * Sets whether to catch exceptions or not during commands execution.
- *
- * @param Boolean $boolean Whether to catch exceptions or not during commands execution
- *
- * @api
- */
- public function setCatchExceptions($boolean)
- {
- $this->catchExceptions = (Boolean) $boolean;
- }
-
- /**
- * Sets whether to automatically exit after a command execution or not.
- *
- * @param Boolean $boolean Whether to automatically exit after a command execution or not
- *
- * @api
- */
- public function setAutoExit($boolean)
- {
- $this->autoExit = (Boolean) $boolean;
- }
-
- /**
- * Gets the name of the application.
- *
- * @return string The application name
- *
- * @api
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Sets the application name.
- *
- * @param string $name The application name
- *
- * @api
- */
- public function setName($name)
- {
- $this->name = $name;
- }
-
- /**
- * Gets the application version.
- *
- * @return string The application version
- *
- * @api
- */
- public function getVersion()
- {
- return $this->version;
- }
-
- /**
- * Sets the application version.
- *
- * @param string $version The application version
- *
- * @api
- */
- public function setVersion($version)
- {
- $this->version = $version;
- }
-
- /**
- * Returns the long version of the application.
- *
- * @return string The long application version
- *
- * @api
- */
- public function getLongVersion()
- {
- if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) {
- return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
- }
-
- return '<info>Console Tool</info>';
- }
-
- /**
- * Registers a new command.
- *
- * @param string $name The command name
- *
- * @return Command The newly created command
- *
- * @api
- */
- public function register($name)
- {
- return $this->add(new Command($name));
- }
-
- /**
- * Adds an array of command objects.
- *
- * @param Command[] $commands An array of commands
- *
- * @api
- */
- public function addCommands(array $commands)
- {
- foreach ($commands as $command) {
- $this->add($command);
- }
- }
-
- /**
- * Adds a command object.
- *
- * If a command with the same name already exists, it will be overridden.
- *
- * @param Command $command A Command object
- *
- * @return Command The registered command
- *
- * @api
- */
- public function add(Command $command)
- {
- $command->setApplication($this);
-
- $this->commands[$command->getFullName()] = $command;
-
- foreach ($command->getAliases() as $alias) {
- $this->aliases[$alias] = $command;
- }
-
- return $command;
- }
-
- /**
- * Returns a registered command by name or alias.
- *
- * @param string $name The command name or alias
- *
- * @return Command A Command object
- *
- * @throws \InvalidArgumentException When command name given does not exist
- *
- * @api
- */
- public function get($name)
- {
- if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
- throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name));
- }
-
- $command = isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
-
- if ($this->wantHelps) {
- $this->wantHelps = false;
-
- $helpCommand = $this->get('help');
- $helpCommand->setCommand($command);
-
- return $helpCommand;
- }
-
- return $command;
- }
-
- /**
- * Returns true if the command exists, false otherwise.
- *
- * @param string $name The command name or alias
- *
- * @return Boolean true if the command exists, false otherwise
- *
- * @api
- */
- public function has($name)
- {
- return isset($this->commands[$name]) || isset($this->aliases[$name]);
- }
-
- /**
- * Returns an array of all unique namespaces used by currently registered commands.
- *
- * It does not returns the global namespace which always exists.
- *
- * @return array An array of namespaces
- */
- public function getNamespaces()
- {
- $namespaces = array();
- foreach ($this->commands as $command) {
- if ($command->getNamespace()) {
- $namespaces[$command->getNamespace()] = true;
- }
- }
-
- return array_keys($namespaces);
- }
-
- /**
- * Finds a registered namespace by a name or an abbreviation.
- *
- * @param string $namespace A namespace or abbreviation to search for
- *
- * @return string A registered namespace
- *
- * @throws \InvalidArgumentException When namespace is incorrect or ambiguous
- */
- public function findNamespace($namespace)
- {
- $abbrevs = static::getAbbreviations($this->getNamespaces());
-
- if (!isset($abbrevs[$namespace])) {
- throw new \InvalidArgumentException(sprintf('There are no commands defined in the "%s" namespace.', $namespace));
- }
-
- if (count($abbrevs[$namespace]) > 1) {
- throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($abbrevs[$namespace])));
- }
-
- return $abbrevs[$namespace][0];
- }
-
- /**
- * Finds a command by name or alias.
- *
- * Contrary to get, this command tries to find the best
- * match if you give it an abbreviation of a name or alias.
- *
- * @param string $name A command name or a command alias
- *
- * @return Command A Command instance
- *
- * @throws \InvalidArgumentException When command name is incorrect or ambiguous
- *
- * @api
- */
- public function find($name)
- {
- // namespace
- $namespace = '';
- if (false !== $pos = strrpos($name, ':')) {
- $namespace = $this->findNamespace(substr($name, 0, $pos));
- $name = substr($name, $pos + 1);
- }
-
- $fullName = $namespace ? $namespace.':'.$name : $name;
-
- // name
- $commands = array();
- foreach ($this->commands as $command) {
- if ($command->getNamespace() == $namespace) {
- $commands[] = $command->getName();
- }
- }
-
- $abbrevs = static::getAbbreviations($commands);
- if (isset($abbrevs[$name]) && 1 == count($abbrevs[$name])) {
- return $this->get($namespace ? $namespace.':'.$abbrevs[$name][0] : $abbrevs[$name][0]);
- }
-
- if (isset($abbrevs[$name]) && count($abbrevs[$name]) > 1) {
- $suggestions = $this->getAbbreviationSuggestions(array_map(function ($command) use ($namespace) { return $namespace.':'.$command; }, $abbrevs[$name]));
-
- throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $fullName, $suggestions));
- }
-
- // aliases
- $abbrevs = static::getAbbreviations(array_keys($this->aliases));
- if (!isset($abbrevs[$fullName])) {
- throw new \InvalidArgumentException(sprintf('Command "%s" is not defined.', $fullName));
- }
-
- if (count($abbrevs[$fullName]) > 1) {
- throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $fullName, $this->getAbbreviationSuggestions($abbrevs[$fullName])));
- }
-
- return $this->get($abbrevs[$fullName][0]);
- }
-
- /**
- * Gets the commands (registered in the given namespace if provided).
- *
- * The array keys are the full names and the values the command instances.
- *
- * @param string $namespace A namespace name
- *
- * @return array An array of Command instances
- *
- * @api
- */
- public function all($namespace = null)
- {
- if (null === $namespace) {
- return $this->commands;
- }
-
- $commands = array();
- foreach ($this->commands as $name => $command) {
- if ($namespace === $command->getNamespace()) {
- $commands[$name] = $command;
- }
- }
-
- return $commands;
- }
-
- /**
- * Returns an array of possible abbreviations given a set of names.
- *
- * @param array $names An array of names
- *
- * @return array An array of abbreviations
- */
- static public function getAbbreviations($names)
- {
- $abbrevs = array();
- foreach ($names as $name) {
- for ($len = strlen($name) - 1; $len > 0; --$len) {
- $abbrev = substr($name, 0, $len);
- if (!isset($abbrevs[$abbrev])) {
- $abbrevs[$abbrev] = array($name);
- } else {
- $abbrevs[$abbrev][] = $name;
- }
- }
- }
-
- // Non-abbreviations always get entered, even if they aren't unique
- foreach ($names as $name) {
- $abbrevs[$name] = array($name);
- }
-
- return $abbrevs;
- }
-
- /**
- * Returns a text representation of the Application.
- *
- * @param string $namespace An optional namespace name
- *
- * @return string A string representing the Application
- */
- public function asText($namespace = null)
- {
- $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands;
-
- $messages = array($this->getHelp(), '');
- if ($namespace) {
- $messages[] = sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $namespace);
- } else {
- $messages[] = '<comment>Available commands:</comment>';
- }
-
- $width = 0;
- foreach ($commands as $command) {
- $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;
- }
- $width += 2;
-
- // add commands by namespace
- foreach ($this->sortCommands($commands) as $space => $commands) {
- if (!$namespace && '_global' !== $space) {
- $messages[] = '<comment>'.$space.'</comment>';
- }
-
- foreach ($commands as $command) {
- $aliases = $command->getAliases() ? '<comment> ('.implode(', ', $command->getAliases()).')</comment>' : '';
-
- $messages[] = sprintf(" <info>%-${width}s</info> %s%s", ($command->getNamespace() ? ':' : '').$command->getName(), $command->getDescription(), $aliases);
- }
- }
-
- return implode("\n", $messages);
- }
-
- /**
- * Returns an XML representation of the Application.
- *
- * @param string $namespace An optional namespace name
- * @param Boolean $asDom Whether to return a DOM or an XML string
- *
- * @return string|DOMDocument An XML string representing the Application
- */
- public function asXml($namespace = null, $asDom = false)
- {
- $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands;
-
- $dom = new \DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = true;
- $dom->appendChild($xml = $dom->createElement('symfony'));
-
- $xml->appendChild($commandsXML = $dom->createElement('commands'));
-
- if ($namespace) {
- $commandsXML->setAttribute('namespace', $namespace);
- } else {
- $namespacesXML = $dom->createElement('namespaces');
- $xml->appendChild($namespacesXML);
- }
-
- // add commands by namespace
- foreach ($this->sortCommands($commands) as $space => $commands) {
- if (!$namespace) {
- $namespaceArrayXML = $dom->createElement('namespace');
- $namespacesXML->appendChild($namespaceArrayXML);
- $namespaceArrayXML->setAttribute('id', $space);
- }
-
- foreach ($commands as $command) {
- if (!$namespace) {
- $commandXML = $dom->createElement('command');
- $namespaceArrayXML->appendChild($commandXML);
- $commandXML->appendChild($dom->createTextNode($command->getName()));
- }
-
- $node = $command->asXml(true)->getElementsByTagName('command')->item(0);
- $node = $dom->importNode($node, true);
-
- $commandsXML->appendChild($node);
- }
- }
-
- return $asDom ? $dom : $dom->saveXml();
- }
-
- /**
- * Renders a catched exception.
- *
- * @param Exception $e An exception instance
- * @param OutputInterface $output An OutputInterface instance
- */
- public function renderException($e, $output)
- {
- $strlen = function ($string)
- {
- return function_exists('mb_strlen') ? mb_strlen($string) : strlen($string);
- };
-
- do {
- $title = sprintf(' [%s] ', get_class($e));
- $len = $strlen($title);
- $lines = array();
- foreach (explode("\n", $e->getMessage()) as $line) {
- $lines[] = sprintf(' %s ', $line);
- $len = max($strlen($line) + 4, $len);
- }
-
- $messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title)));
-
- foreach ($lines as $line) {
- $messages[] = $line.str_repeat(' ', $len - $strlen($line));
- }
-
- $messages[] = str_repeat(' ', $len);
-
- $output->writeln("\n");
- foreach ($messages as $message) {
- $output->writeln('<error>'.$message.'</error>');
- }
- $output->writeln("\n");
-
- if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
- $output->writeln('</comment>Exception trace:</comment>');
-
- // exception related properties
- $trace = $e->getTrace();
- array_unshift($trace, array(
- 'function' => '',
- 'file' => $e->getFile() != null ? $e->getFile() : 'n/a',
- 'line' => $e->getLine() != null ? $e->getLine() : 'n/a',
- 'args' => array(),
- ));
-
- for ($i = 0, $count = count($trace); $i < $count; $i++) {
- $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
- $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
- $function = $trace[$i]['function'];
- $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
- $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
-
- $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line));
- }
-
- $output->writeln("\n");
- }
- } while ($e = $e->getPrevious());
-
- if (null !== $this->runningCommand) {
- $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())));
- $output->writeln("\n");
- }
- }
-
- /**
- * Gets the name of the command based on input.
- *
- * @param InputInterface $input The input interface
- *
- * @return string The command name
- */
- protected function getCommandName(InputInterface $input)
- {
- return $input->getFirstArgument('command');
- }
-
- /**
- * Sorts commands in alphabetical order.
- *
- * @param array $commands An associative array of commands to sort
- *
- * @return array A sorted array of commands
- */
- private function sortCommands($commands)
- {
- $namespacedCommands = array();
- foreach ($commands as $name => $command) {
- $key = $command->getNamespace() ? $command->getNamespace() : '_global';
-
- if (!isset($namespacedCommands[$key])) {
- $namespacedCommands[$key] = array();
- }
-
- $namespacedCommands[$key][$name] = $command;
- }
- ksort($namespacedCommands);
-
- foreach ($namespacedCommands as &$commands) {
- ksort($commands);
- }
-
- return $namespacedCommands;
- }
-
- /**
- * Returns abbreviated suggestions in string format.
- *
- * @param array $abbrevs Abbreviated suggestions to convert
- *
- * @return string A formatted string of abbreviated suggestions
- */
- private function getAbbreviationSuggestions($abbrevs)
- {
- return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : '');
- }
-}
View
576 vendor__/Symfony/Component/Console/Command/Command.php
@@ -1,576 +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\Command;
-
-use Symfony\Component\Console\Input\InputDefinition;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Application;
-
-/**
- * Base class for all commands.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @api
- */
-class Command
-{
- private $application;
- private $name;
- private $namespace;
- private $aliases;
- private $definition;
- private $help;
- private $description;
- private $ignoreValidationErrors;
- private $applicationDefinitionMerged;
- private $code;
- private $synopsis;
-
- /**
- * Constructor.
- *
- * @param string $name The name of the command
- *
- * @throws \LogicException When the command name is empty
- *
- * @api
- */
- public function __construct($name = null)
- {
- $this->definition = new InputDefinition();
- $this->ignoreValidationErrors = false;
- $this->applicationDefinitionMerged = false;
- $this->aliases = array();
-
- if (null !== $name) {
- $this->setName($name);
- }
-
- $this->configure();
-
- if (!$this->name) {
- throw new \LogicException('The command name cannot be empty.');
- }
- }
-
- /**
- * Sets the application instance for this command.
- *
- * @param Application $application An Application instance
- *
- * @api
- */
- public function setApplication(Application $application = null)
- {
- $this->application = $application;
- }
-
- /**
- * Gets the application instance for this command.
- *
- * @return Application An Application instance
- *
- * @api
- */
- public function getApplication()
- {
- return $this->application;
- }
-
- /**
- * Configures the current command.
- */
- protected function configure()
- {
- }
-
- /**
- * Executes the current command.
- *
- * This method is not abstract because you can use this class
- * as a concrete class. In this case, instead of defining the
- * execute() method, you set the code to execute by passing
- * a Closure to the setCode() method.
- *
- * @param InputInterface $input An InputInterface instance
- * @param OutputInterface $output An OutputInterface instance
- *
- * @return integer 0 if everything went fine, or an error code
- *
- * @throws \LogicException When this abstract class is not implemented
- * @see setCode()
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- throw new \LogicException('You must override the execute() method in the concrete command class.');
- }
-
- /**
- * Interacts with the user.
- *
- * @param InputInterface $input An InputInterface instance
- * @param OutputInterface $output An OutputInterface instance
- */
- protected function interact(InputInterface $input, OutputInterface $output)
- {
- }
-
- /**
- * Initializes the command just after the input has been validated.
- *
- * This is mainly useful when a lot of commands extends one main command
- * where some things need to be initialized based on the input arguments and options.
- *
- * @param InputInterface $input An InputInterface instance
- * @param OutputInterface $output An OutputInterface instance
- */
- protected function initialize(InputInterface $input, OutputInterface $output)
- {
- }
-
- /**
- * Runs the command.
- *
- * The code to execute is either defined directly with the
- * setCode() method or by overriding the execute() method
- * in a sub-class.
- *
- * @param InputInterface $input An InputInterface instance
- * @param OutputInterface $output An OutputInterface instance
- *
- * @see setCode()
- * @see execute()
- *
- * @api
- */
- public function run(InputInterface $input, OutputInterface $output)
- {
- // force the creation of the synopsis before the merge with the app definition
- $this->getSynopsis();
-
- // add the application arguments and options
- $this->mergeApplicationDefinition();
-
- // bind the input against the command specific arguments/options
- try {
- $input->bind($this->definition);
- } catch (\Exception $e) {
- if (!$this->ignoreValidationErrors) {
- throw $e;
- }
- }
-
- $this->initialize($input, $output);
-
- if ($input->isInteractive()) {
- $this->interact($input, $output);
- }
-
- $input->validate();
-
- if ($this->code) {
- return call_user_func($this->code, $input, $output);
- }
-
- return $this->execute($input, $output);
- }
-
- /**
- * Sets the code to execute when running this command.
- *
- * If this method is used, it overrides the code defined
- * in the execute() method.
- *
- * @param \Closure $code A \Closure
- *
- * @return Command The current instance
- *
- * @see execute()
- *
- * @api
- */
- public function setCode(\Closure $code)
- {
- $this->code = $code;
-
- return $this;
- }
-
- /**
- * Merges the application definition with the command definition.
- */
- private function mergeApplicationDefinition()
- {
- if (null === $this->application || true === $this->applicationDefinitionMerged) {
- return;
- }
-
- $this->definition->setArguments(array_merge(
- $this->application->getDefinition()->getArguments(),
- $this->definition->getArguments()
- ));
-
- $this->definition->addOptions($this->application->getDefinition()->getOptions());
-
- $this->applicationDefinitionMerged = true;
- }
-
- /**
- * Sets an array of argument and option instances.
- *
- * @param array|Definition $definition An array of argument and option instances or a definition instance
- *
- * @return Command The current instance
- *
- * @api
- */
- public function setDefinition($definition)
- {
- if ($definition instanceof InputDefinition) {
- $this->definition = $definition;
- } else {
- $this->definition->setDefinition($definition);
- }
-
- $this->applicationDefinitionMerged = false;
-
- return $this;
- }
-
- /**
- * Gets the InputDefinition attached to this Command.
- *
- * @return InputDefinition An InputDefinition instance
- *
- * @api
- */
- public function getDefinition()
- {
- return $this->definition;
- }
-
- /**
- * Adds an argument.
- *
- * @param string $name The argument name
- * @param integer $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
- * @param string $description A description text
- * @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
- *
- * @return Command The current instance
- *
- * @api
- */
- public function addArgument($name, $mode = null, $description = '', $default = null)
- {
- $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
-
- return $this;
- }
-
- /**
- * Adds an option.
- *
- * @param string $name The option name
- * @param string $shortcut The shortcut (can be null)
- * @param integer $mode The option mode: One of the InputOption::VALUE_* constants
- * @param string $description A description text
- * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or self::VALUE_NONE)
- *
- * @return Command The current instance
- *
- * @api
- */
- public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
- {
- $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
-
- return $this;
- }
-
- /**
- * Sets the name of the command.
- *
- * This method can set both the namespace and the name if
- * you separate them by a colon (:)
- *
- * $command->setName('foo:bar');
- *
- * @param string $name The command name
- *
- * @return Command The current instance
- *
- * @throws \InvalidArgumentException When command name given is empty
- *
- * @api
- */
- public function setName($name)
- {
- if (false !== $pos = strrpos($name, ':')) {
- $namespace = substr($name, 0, $pos);
- $name = substr($name, $pos + 1);
- } else {
- $namespace = $this->namespace;
- }
-
- if (!$name) {
- throw new \InvalidArgumentException('A command name cannot be empty.');
- }
-
- $this->namespace = $namespace;
- $this->name = $name;
-
- return $this;
- }
-
- /**
- * Returns the command namespace.
- *
- * @return string The command namespace
- *
- * @api
- */
- public function getNamespace()
- {
- return $this->namespace;
- }
-
- /**
- * Returns the command name
- *
- * @return string The command name
- *
- * @api
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Returns the fully qualified command name.
- *
- * @return string The fully qualified command name
- *
- * @api
- */
- public function getFullName()
- {
- return $this->getNamespace() ? $this->getNamespace().':'.$this->getName() : $this->getName();
- }
-
- /**
- * Sets the description for the command.
- *
- * @param string $description The description for the command
- *
- * @return Command The current instance
- *
- * @api
- */
- public function setDescription($description)
- {
- $this->description = $description;
-
- return $this;
- }
-
- /**
- * Returns the description for the command.
- *
- * @return string The description for the command
- *
- * @api
- */
- public function getDescription()
- {
- return $this->description;
- }
-
- /**
- * Sets the help for the command.
- *
- * @param string $help The help for the command
- *
- * @return Command The current instance
- *
- * @api
- */
- public function setHelp($help)
- {
- $this->help = $help;
-
- return $this;
- }
-
- /**
- * Returns the help for the command.
- *
- * @return string The help for the command
- *
- * @api
- */
- public function getHelp()
- {
- return $this->help;
- }
-
- /**
- * Returns the processed help for the command replacing the %command.name% and
- * %command.full_name% patterns with the real values dynamically.
- *
- * @return string The processed help for the command
- */
- public function getProcessedHelp()
- {
- $name = $this->namespace.':'.$this->name;
-
- $placeholders = array(
- '%command.name%',
- '%command.full_name%'
- );
- $replacements = array(
- $name,
- $_SERVER['PHP_SELF'].' '.$name
- );
-
- return str_replace($placeholders, $replacements, $this->getHelp());
- }
-
- /**
- * Sets the aliases for the command.
- *
- * @param array $aliases An array of aliases for the command
- *
- * @return Command The current instance
- *
- * @api
- */
- public function setAliases($aliases)
- {
- $this->aliases = $aliases;
-
- return $this;
- }
-
- /**
- * Returns the aliases for the command.
- *
- * @return array An array of aliases for the command
- *
- * @api
- */
- public function getAliases()
- {
- return $this->aliases;
- }
-
- /**
- * Returns the synopsis for the command.
- *
- * @return string The synopsis
- */
- public function getSynopsis()
- {
- if (null === $this->synopsis) {
- $this->synopsis = trim(sprintf('%s %s', $this->getFullName(), $this->definition->getSynopsis()));
- }
-
- return $this->synopsis;
- }
-
- /**
- * Gets a helper instance by name.
- *
- * @param string $name The helper name
- *
- * @return mixed The helper value
- *
- * @throws \InvalidArgumentException if the helper is not defined
- *
- * @api
- */
- public function getHelper($name)
- {
- return $this->application->getHelperSet()->get($name);
- }
-
- /**
- * Returns a text representation of the command.
- *
- * @return string A string representing the command
- */
- public function asText()
- {
- $messages = array(
- '<comment>Usage:</comment>',
- ' '.$this->getSynopsis(),
- '',
- );
-
- if ($this->getAliases()) {
- $messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';
- }
-
- $messages[] = $this->definition->asText();
-
- if ($help = $this->getProcessedHelp()) {
- $messages[] = '<comment>Help:</comment>';
- $messages[] = ' '.implode("\n ", explode("\n", $help))."\n";
- }
-
- return implode("\n", $messages);
- }
-
- /**
- * Returns an XML representation of the command.
- *
- * @param Boolean $asDom Whether to return a DOM or an XML string
- *
- * @return string|DOMDocument An XML string representing the command
- */
- public function asXml($asDom = false)
- {
- $dom = new \DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = true;
- $dom->appendChild($commandXML = $dom->createElement('command'));
- $commandXML->setAttribute('id', $this->getFullName());
- $commandXML->setAttribute('namespace', $this->getNamespace() ? $this->getNamespace() : '_global');
- $commandXML->setAttribute('name', $this->getName());
-
- $commandXML->appendChild($usageXML = $dom->createElement('usage'));
- $usageXML->appendChild($dom->createTextNode(sprintf($this->getSynopsis(), '')));
-
- $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
- $descriptionXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $this->getDescription()))));
-
- $commandXML->appendChild($helpXML = $dom->createElement('help'));
- $help = $this->help;
- $helpXML->appendChild($dom->createTextNode(implode("\n ", explode("\n", $help))));
-
- $commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
- foreach ($this->getAliases() as $alias) {
- $aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));
- $aliasXML->appendChild($dom->createTextNode($alias));
- }
-
- $definition = $this->definition->asXml(true);
- $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));
- $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));
-
- return $asDom ? $dom : $dom->saveXml();
- }
-}
View
82 vendor__/Symfony/Component/Console/Command/HelpCommand.php
@@ -1,82 +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\Command;
-
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Output\Output;
-use Symfony\Component\Console\Command\Command;
-
-/**
- * HelpCommand displays the help for a given command.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class HelpCommand extends Command
-{
- private $command;
-
- /**
- * {@inheritdoc}
- */
- protected function configure()
- {
- $this->ignoreValidationErrors = true;
-
- $this
- ->setDefinition(array(
- new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
- new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
- ))
- ->setName('help')
- ->setAliases(array('?'))
- ->setDescription('Displays help for a command')
- ->setHelp(<<<EOF
-The <info>help</info> command displays help for a given command:
-
- <info>./symfony help list</info>
-
-You can also output the help as XML by using the <comment>--xml</comment> option:
-
- <info>./symfony help --xml list</info>
-EOF
- );
- }
-
- /**
- * Sets the command
- *
- * @param Command $command The command to set
- */
- public function setCommand(Command $command)
- {
- $this->command = $command;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if (null === $this->command) {
- $this->command = $this->getApplication()->get($input->getArgument('command_name'));
- }
-
- if ($input->getOption('xml')) {
- $output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW);
- } else {
- $output->writeln($this->command->asText());
- }
- }
-}
View
67 vendor__/Symfony/Component/Console/Command/ListCommand.php
@@ -1,67 +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\Command;
-
-use Symfony\Component\Console\Input\InputArgument;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Output\Output;
-use Symfony\Component\Console\Command\Command;
-
-/**
- * ListCommand displays the list of all available commands for the application.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class ListCommand extends Command
-{
- /**
- * {@inheritdoc}
- */
- protected function configure()
- {
- $this
- ->setDefinition(array(
- new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
- new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
- ))
- ->setName('list')
- ->setDescription('Lists commands')
- ->setHelp(<<<EOF
-The <info>list</info> command lists all commands:
-
- <info>./symfony list</info>
-
-You can also display the commands for a specific namespace:
-
- <info>./symfony list test</info>
-
-You can also output the information as XML by using the <comment>--xml</comment> option:
-
- <info>./symfony list --xml</info>
-EOF
- );
- }
-
- /**
- * {@inheritdoc}
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- if ($input->getOption('xml')) {
- $output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW);
- } else {
- $output->writeln($this->getApplication()->asText($input->getArgument('namespace')));
- }
- }
-}
View
243 vendor__/Symfony/Component/Console/Formatter/OutputFormatter.php
@@ -1,243 +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\Formatter;
-
-/**
- * Formatter class for console output.
- *
- * @author Konstantin Kudryashov <ever.zet@gmail.com>
- *
- * @api
- */
-class OutputFormatter implements OutputFormatterInterface
-{
- private $decorated;
- private $styles = array();
-
- /**
- * Initializes console output formatter.
- *
- * @param boolean $decorated Whether this formatter should actually decorate strings
- * @param array $styles Array of "name => FormatterStyle" instance
- *
- * @api
- */
- public function __construct($decorated = null, array $styles = array())
- {
- $this->decorated = (Boolean) $decorated;
-
- $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
- $this->setStyle('info', new OutputFormatterStyle('green'));
- $this->setStyle('comment', new OutputFormatterStyle('yellow'));
- $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
-
- foreach ($styles as $name => $style) {
- $this->setStyle($name, $style);
- }
- }
-
- /**
- * Sets the decorated flag.
- *
- * @param Boolean $decorated Whether to decorated the messages or not
- *
- * @api
- */
- public function setDecorated($decorated)
- {
- $this->decorated = (Boolean) $decorated;
- }
-
- /**
- * Gets the decorated flag.
- *
- * @return Boolean true if the output will decorate messages, false otherwise
- *
- * @api
- */
- public function isDecorated()
- {
- return $this->decorated;
- }
-
- /**
- * Sets a new style.
- *
- * @param string $name The style name
- * @param OutputFormatterStyleInterface $options The style instance
- *
- * @api
- */
- public function setStyle($name, OutputFormatterStyleInterface $style)
- {
- $this->styles[strtolower($name)] = $style;
- }
-
- /**
- * Checks if output formatter has style with specified name.
- *
- * @param string $name
- *
- * @return boolean
- *
- * @api
- */
- public function hasStyle($name)
- {
- return isset($this->styles[strtolower($name)]);
- }
-
- /**
- * Gets style options from style with specified name.
- *
- * @param string $name
- *
- * @return OutputFormatterStyleInterface
- *
- * @api
- */
- public function getStyle($name)
- {
- if (!$this->hasStyle($name)) {
- throw new \InvalidArgumentException('Undefined style: ' . $name);
- }
-
- return $this->styles[strtolower($name)];
- }
-
- /**
- * Formats a message according to the given styles.
- *
- * @param string $message The message to style
- *
- * @return string The styled message
- *
- * @api
- */
- public function format($message)
- {
- $message = preg_replace_callback(
- $this->getBeginStyleRegex(), array($this, 'replaceBeginStyle'), $message
- );
-
- return preg_replace_callback(
- $this->getEndStyleRegex(), array($this, 'replaceEndStyle'), $message
- );
- }
-
- /**
- * Gets regex for a style start.
- *
- * @return string
- */
- protected function getBeginStyleRegex()
- {
- return '#<([a-z][a-z0-9\-_=;]+)>#i';
- }
-
- /**
- * Gets regex for a style end.
- *
- * @return string
- */
- protected function getEndStyleRegex()
- {
- return '#</([a-z][a-z0-9\-_]*)?>#i';
- }
-
- /**
- * Replaces the starting style of the output.
- *
- * @param array $match
- *
- * @return string The replaced style
- *
- * @throws \InvalidArgumentException When style is unknown
- */
- private function replaceBeginStyle($match)
- {
- if (!$this->isDecorated()) {
- return '';
- }
-
- if (isset($this->styles[strtolower($match[1])])) {
- $style = $this->styles[strtolower($match[1])];
- } else {
- $style = $this->createStyleFromString($match[1]);
-
- if (false === $style) {
- return $match[0];
- }
- }
-
- return $style->getBeginStyle();
- }
-
- /**
- * Replaces the end style.
- *
- * @param string $match The text to match
- *
- * @return string The end style
- */
- private function replaceEndStyle($match)
- {
- if (!$this->isDecorated()) {
- return '';
- }
-
- if (!isset($match[1])) {
- $match[1] = '';
- }
-
- if ('' == $match[1]) {
- $style = new OutputFormatterStyle();
- } else {
- if (!isset($this->styles[strtolower($match[1])])) {
- return $match[0];
- }
-
- $style = $this->styles[strtolower($match[1])];
- }
-
- return $style->getEndStyle();
- }
-
- /**
- * Tryes to create new style instance from string.
- *
- * @param string $string
- *
- * @return Symfony\Component\Console\Format\FormatterStyle|boolean false if string is not format string
- */
- private function createStyleFromString($string)
- {
- if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
- return false;
- }
-
- $style = new OutputFormatterStyle();
- foreach ($matches as $match) {
- array_shift($match);
-
- if ('fg' == $match[0]) {
- $style->setForeground($match[1]);
- } elseif ('bg' == $match[0]) {
- $style->setBackground($match[1]);
- } else {
- $style->setOption($match[1]);
- }
- }
-
- return $style;
- }
-}
View
83 vendor__/Symfony/Component/Console/Formatter/OutputFormatterInterface.php
@@ -1,83 +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\Formatter;
-
-/**
- * Formatter interface for console output.
- *
- * @author Konstantin Kudryashov <ever.zet@gmail.com>
- *
- * @api
- */
-interface OutputFormatterInterface
-{
- /**
- * Sets the decorated flag.
- *
- * @param Boolean $decorated Whether to decorated the messages or not
- *
- * @api
- */
- function setDecorated($decorated);
-
- /**
- * Gets the decorated flag.
- *
- * @return Boolean true if the output will decorate messages, false otherwise
- *
- * @api
- */
- function isDecorated();
-
- /**
- * Sets a new style.
- *
- * @param string $name The style name
- * @param OutputFormatterStyleInterface $options The style instance
- *
- * @api
- */
- function setStyle($name, OutputFormatterStyleInterface $style);
-
- /**
- * Checks if output formatter has style with specified name.
- *
- * @param string $name
- *
- * @return boolean
- *
- * @api
- */
- function hasStyle($name);
-
- /**
- * Gets style options from style with specified name.
- *
- * @param string $name
- *
- * @return OutputFormatterStyleInterface
- *
- * @api
- */
- function getStyle($name);
-
- /**
- * Formats a message according to the given styles.
- *
- * @param string $message The message to style
- *
- * @return string The styled message
- *
- * @api
- */
- function format($message);
-}
View
217 vendor__/Symfony/Component/Console/Formatter/OutputFormatterStyle.php
@@ -1,217 +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\Formatter;
-
-/**
- * Formatter style class for defining styles.
- *
- * @author Konstantin Kudryashov <ever.zet@gmail.com>
- *
- * @api
- */
-class OutputFormatterStyle implements OutputFormatterStyleInterface
-{
- static private $availableForegroundColors = array(
- 'black' => 30,
- 'red' => 31,
- 'green' => 32,
- 'yellow' => 33,
- 'blue' => 34,
- 'magenta' => 35,
- 'cyan' => 36,
- 'white' => 37
- );
- static private $availableBackgroundColors = array(
- 'black' => 40,
- 'red' => 41,
- 'green' => 42,
- 'yellow' => 43,
- 'blue' => 44,
- 'magenta' => 45,
- 'cyan' => 46,
- 'white' => 47
- );
- static private $availableOptions = array(
- 'bold' => 1,
- 'underscore' => 4,
- 'blink' => 5,
- 'reverse' => 7,
- 'conceal' => 8
- );
-
- private $foreground;
- private $background;
- private $options = array();
-
- /**
- * Initializes output formatter style.
- *
- * @param string $foreground style foreground color name
- * @param string $background style background color name
- * @param array $options style options
- *
- * @api
- */
- public function __construct($foreground = null, $background = null, array $options = array())
- {
- if (null !== $foreground) {
- $this->setForeground($foreground);
- }
- if (null !== $background) {
- $this->setBackground($background);
- }
- if (count($options)) {
- $this->setOptions($options);
- }
- }
-
- /**
- * Sets style foreground color.
- *
- * @param string $color color name
- *
- * @api
- */
- public function setForeground($color = null)
- {
- if (null === $color) {
- $this->foreground = null;
-
- return;
- }
-
- if (!isset(static::$availableForegroundColors[$color])) {
- throw new \InvalidArgumentException(sprintf(
- 'Invalid foreground color specified: "%s". Expected one of (%s)',
- $color,
- implode(', ', array_keys(static::$availableForegroundColors))
- ));
- }
-
- $this->foreground = static::$availableForegroundColors[$color];
- }
-
- /**
- * Sets style background color.
- *
- * @param string $color color name
- *
- * @api
- */
- public function setBackground($color = null)
- {
- if (null === $color) {
- $this->background = null;
-
- return;
- }
-
- if (!isset(static::$availableBackgroundColors[$color])) {
- throw new \InvalidArgumentException(sprintf(
- 'Invalid background color specified: "%s". Expected one of (%s)',
- $color,
- implode(', ', array_keys(static::$availableBackgroundColors))
- ));
- }
-
- $this->background = static::$availableBackgroundColors[$color];
- }
-
- /**
- * Sets some specific style option.
- *
- * @param string $option option name
- *
- * @api
- */
- public function setOption($option)
- {
- if (!isset(static::$availableOptions[$option])) {
- throw new \InvalidArgumentException(sprintf(
- 'Invalid option specified: "%s". Expected one of (%s)',
- $option,
- implode(', ', array_keys(static::$availableOptions))
- ));
- }
-
- if (false === array_search(static::$availableOptions[$option], $this->options)) {
- $this->options[] = static::$availableOptions[$option];
- }
- }
-
- /**
- * Unsets some specific style option.
- *
- * @param string $option option name
- */
- public function unsetOption($option)
- {
- if (!isset(static::$availableOptions[$option])) {
- throw new \InvalidArgumentException(sprintf(
- 'Invalid option specified: "%s". Expected one of (%s)',
- $option,
- implode(', ', array_keys(static::$availableOptions))
- ));
- }
-
- $pos = array_search(static::$availableOptions[$option], $this->options);
- if (false !== $pos) {
- unset($this->options[$pos]);
- }
- }
-
- /**
- * Set multiple style options at once.
- *
- * @param array $options
- */
- public function setOptions(array $options)
- {
- $this->options = array();
-
- foreach ($options as $option) {
- $this->setOption($option);
- }
- }
-
- /**
- * Returns begin style code.
- *
- * @return string
- */
- public function getBeginStyle()
- {
- $codes = array();
-
- if (null !== $this->foreground) {
- $codes[] = $this->foreground;
- }
- if (null !== $this->background) {
- $codes[] = $this->background;
- }
- if (count($this->options)) {
- $codes = array_merge($codes, $this->options);
- }
-
- return "\033[" . implode(';', $codes) . 'm';
- }
-
- /**
- * Returns end style code.
- *
- * @return string
- */
- public function getEndStyle()
- {
- return "\033[0m";
- }
-}
View
77 vendor__/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php
@@ -1,77 +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\Formatter;
-
-/**
- * Formatter style interface for defining styles.
- *
- * @author Konstantin Kudryashov <ever.zet@gmail.com>
- *
- * @api
- */
-interface OutputFormatterStyleInterface
-{
- /**
- * Sets style foreground color.
- *
- * @param string $color color name
- *
- * @api
- */
- function setForeground($color = null);
-