Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Symfony2] Removed Symfony2

Symfony2 is not necessary for this version
You can use Symfony\Component\ClassLoader\UniversalClassLoader for autoloading
  • Loading branch information...
commit f9146463d775ab91d43e6fa00a67489d0cce35b3 1 parent 035f02b
@nfabre authored
Showing with 1 addition and 5,949 deletions.
  1. +1 −0  .gitignore
  2. +0 −220 src/vendor/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
  3. +0 −58 src/vendor/symfony/src/Symfony/Component/ClassLoader/MapFileClassLoader.php
  4. +0 −233 src/vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php
  5. +0 −771 src/vendor/symfony/src/Symfony/Component/Console/Application.php
  6. +0 −530 src/vendor/symfony/src/Symfony/Component/Console/Command/Command.php
  7. +0 −82 src/vendor/symfony/src/Symfony/Component/Console/Command/HelpCommand.php
  8. +0 −67 src/vendor/symfony/src/Symfony/Component/Console/Command/ListCommand.php
  9. +0 −110 src/vendor/symfony/src/Symfony/Component/Console/Helper/DialogHelper.php
  10. +0 −91 src/vendor/symfony/src/Symfony/Component/Console/Helper/FormatterHelper.php
  11. +0 −42 src/vendor/symfony/src/Symfony/Component/Console/Helper/Helper.php
  12. +0 −41 src/vendor/symfony/src/Symfony/Component/Console/Helper/HelperInterface.php
  13. +0 −102 src/vendor/symfony/src/Symfony/Component/Console/Helper/HelperSet.php
  14. +0 −287 src/vendor/symfony/src/Symfony/Component/Console/Input/ArgvInput.php
  15. +0 −190 src/vendor/symfony/src/Symfony/Component/Console/Input/ArrayInput.php
  16. +0 −211 src/vendor/symfony/src/Symfony/Component/Console/Input/Input.php
  17. +0 −128 src/vendor/symfony/src/Symfony/Component/Console/Input/InputArgument.php
  18. +0 −478 src/vendor/symfony/src/Symfony/Component/Console/Input/InputDefinition.php
  19. +0 −103 src/vendor/symfony/src/Symfony/Component/Console/Input/InputInterface.php
  20. +0 −178 src/vendor/symfony/src/Symfony/Component/Console/Input/InputOption.php
  21. +0 −74 src/vendor/symfony/src/Symfony/Component/Console/Input/StringInput.php
  22. +0 −39 src/vendor/symfony/src/Symfony/Component/Console/Output/ConsoleOutput.php
  23. +0 −32 src/vendor/symfony/src/Symfony/Component/Console/Output/NullOutput.php
  24. +0 −244 src/vendor/symfony/src/Symfony/Component/Console/Output/Output.php
  25. +0 −53 src/vendor/symfony/src/Symfony/Component/Console/Output/OutputInterface.php
  26. +0 −105 src/vendor/symfony/src/Symfony/Component/Console/Output/StreamOutput.php
  27. +0 −136 src/vendor/symfony/src/Symfony/Component/Console/Shell.php
  28. +0 −101 src/vendor/symfony/src/Symfony/Component/Console/Tester/ApplicationTester.php
  29. +0 −101 src/vendor/symfony/src/Symfony/Component/Console/Tester/CommandTester.php
  30. +0 −54 src/vendor/symfony/src/Symfony/Component/Yaml/Dumper.php
  31. +0 −21 src/vendor/symfony/src/Symfony/Component/Yaml/Exception.php
  32. +0 −404 src/vendor/symfony/src/Symfony/Component/Yaml/Inline.php
  33. +0 −526 src/vendor/symfony/src/Symfony/Component/Yaml/Parser.php
  34. +0 −21 src/vendor/symfony/src/Symfony/Component/Yaml/ParserException.php
  35. +0 −116 src/vendor/symfony/src/Symfony/Component/Yaml/Yaml.php
View
1  .gitignore
@@ -3,5 +3,6 @@
.settings/*
.externalToolBuilders/*
src/vendor/imagine
+src/vendor/symfony
build
phpunit.xml
View
220 src/vendor/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
@@ -1,220 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\ClassLoader;
-
-/**
- * ClassCollectionLoader.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class ClassCollectionLoader
-{
- static protected $loaded;
-
- /**
- * Loads a list of classes and caches them in one big file.
- *
- * @param array $classes An array of classes to load
- * @param string $cacheDir A cache directory
- * @param string $name The cache name prefix
- * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not
- * @param Boolean $adaptive Whether to remove already declared classes or not
- *
- * @throws \InvalidArgumentException When class can't be loaded
- */
- static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false)
- {
- // each $name can only be loaded once per PHP process
- if (isset(self::$loaded[$name])) {
- return;
- }
-
- self::$loaded[$name] = true;
-
- $classes = array_unique($classes);
-
- if ($adaptive) {
- // don't include already declared classes
- $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());
-
- // the cache is different depending on which classes are already declared
- $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);
- }
-
- $cache = $cacheDir.'/'.$name.'.php';
-
- // auto-reload
- $reload = false;
- if ($autoReload) {
- $metadata = $cacheDir.'/'.$name.'.meta';
- if (!file_exists($metadata) || !file_exists($cache)) {
- $reload = true;
- } else {
- $time = filemtime($cache);
- $meta = unserialize(file_get_contents($metadata));
-
- if ($meta[1] != $classes) {
- $reload = true;
- } else {
- foreach ($meta[0] as $resource) {
- if (!file_exists($resource) || filemtime($resource) > $time) {
- $reload = true;
-
- break;
- }
- }
- }
- }
- }
-
- if (!$reload && file_exists($cache)) {
- require_once $cache;
-
- return;
- }
-
- $files = array();
- $content = '';
- foreach ($classes as $class) {
- if (!class_exists($class) && !interface_exists($class)) {
- throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
- }
-
- $r = new \ReflectionClass($class);
- $files[] = $r->getFileName();
-
- $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName()));
-
- // add namespace declaration for global code
- if (!$r->inNamespace()) {
- $c = "\nnamespace\n{\n$c\n}\n";
- } else {
- $c = self::fixNamespaceDeclarations('<?php '.$c);
- $c = preg_replace('/^\s*<\?php/', '', $c);
- }
-
- $content .= $c;
- }
-
- // cache the core classes
- if (!is_dir(dirname($cache))) {
- mkdir(dirname($cache), 0777, true);
- }
- self::writeCacheFile($cache, self::stripComments('<?php '.$content));
-
- if ($autoReload) {
- // save the resources
- self::writeCacheFile($metadata, serialize(array($files, $classes)));
- }
- }
-
- /**
- * Adds brackets around each namespace if it's not already the case.
- *
- * @param string $source Namespace string
- *
- * @return string Namespaces with brackets
- */
- static public function fixNamespaceDeclarations($source)
- {
- if (!function_exists('token_get_all')) {
- return $source;
- }
-
- $output = '';
- $inNamespace = false;
- $tokens = token_get_all($source);
-
- while ($token = array_shift($tokens)) {
- if (is_string($token)) {
- $output .= $token;
- } elseif (T_NAMESPACE === $token[0]) {
- if ($inNamespace) {
- $output .= "}\n";
- }
- $output .= $token[1];
-
- // namespace name and whitespaces
- while (($t = array_shift($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
- $output .= $t[1];
- }
- if (is_string($t) && '{' === $t) {
- $inNamespace = false;
- array_unshift($tokens, $t);
- } else {
- $output .= "\n{";
- $inNamespace = true;
- }
- } else {
- $output .= $token[1];
- }
- }
-
- if ($inNamespace) {
- $output .= "}\n";
- }
-
- return $output;
- }
-
- /**
- * Writes a cache file.
- *
- * @param string $file Filename
- * @param string $content Temporary file content
- *
- * @throws \RuntimeException when a cache file cannot be written
- */
-
- static protected function writeCacheFile($file, $content)
- {
- $tmpFile = tempnam(dirname($file), basename($file));
- if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
- chmod($file, 0644);
-
- return;
- }
-
- throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
- }
-
- /**
- * Removes comments from a PHP source string.
- *
- * We don't use the PHP php_strip_whitespace() function
- * as we want the content to be readable and well-formatted.
- *
- * @param string $source A PHP string
- *
- * @return string The PHP string with the comments removed
- */
- static protected function stripComments($source)
- {
- if (!function_exists('token_get_all')) {
- return $source;
- }
-
- $output = '';
- foreach (token_get_all($source) as $token) {
- if (is_string($token)) {
- $output .= $token;
- } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
- $output .= $token[1];
- }
- }
-
- // replace multiple new lines with a single newline
- $output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output);
-
- return $output;
- }
-}
View
58 src/vendor/symfony/src/Symfony/Component/ClassLoader/MapFileClassLoader.php
@@ -1,58 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\ClassLoader;
-
-/**
- * A class loader that uses a mapping file to look up paths.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.org>
- */
-class MapFileClassLoader
-{
- protected $map = array();
-
- /**
- * Constructor.
- *
- * @param string $file Path to class mapping file
- */
- public function __construct($file)
- {
- $this->map = require $file;
- }
-
- /**
- * Registers this instance as an autoloader.
- *
- * @param Boolean $prepend Whether to prepend the autoloader or not
- */
- public function register($prepend = false)
- {
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
- }
-
- /**
- * Loads the given class or interface.
- *
- * @param string $class The name of the class
- */
- public function loadClass($class)
- {
- if ('\\' === $class[0]) {
- $class = substr($class, 1);
- }
-
- if (isset($this->map[$class])) {
- require $this->map[$class];
- }
- }
-}
View
233 src/vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php
@@ -1,233 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\ClassLoader;
-
-/**
- * UniversalClassLoader implements a "universal" autoloader for PHP 5.3.
- *
- * It is able to load classes that use either:
- *
- * * The technical interoperability standards for PHP 5.3 namespaces and
- * class names (http://groups.google.com/group/php-standards/web/psr-0-final-proposal);
- *
- * * The PEAR naming convention for classes (http://pear.php.net/).
- *
- * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
- * looked for in a list of locations to ease the vendoring of a sub-set of
- * classes for large projects.
- *
- * Example usage:
- *
- * $loader = new UniversalClassLoader();
- *
- * // register classes with namespaces
- * $loader->registerNamespaces(array(
- * 'Symfony\Component' => __DIR__.'/component',
- * 'Symfony' => __DIR__.'/framework',
- * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
- * ));
- *
- * // register a library using the PEAR naming convention
- * $loader->registerPrefixes(array(
- * 'Swift_' => __DIR__.'/Swift',
- * ));
- *
- * // activate the autoloader
- * $loader->register();
- *
- * In this example, if you try to use a class in the Symfony\Component
- * namespace or one of its children (Symfony\Component\Console for instance),
- * the autoloader will first look for the class under the component/
- * directory, and it will then fallback to the framework/ directory if not
- * found before giving up.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.org>
- */
-class UniversalClassLoader
-{
- protected $namespaces = array();
- protected $prefixes = array();
- protected $namespaceFallback = array();
- protected $prefixFallback = array();
-
- /**
- * Gets the configured namespaces.
- *
- * @return array A hash with namespaces as keys and directories as values
- */
- public function getNamespaces()
- {
- return $this->namespaces;
- }
-
- /**
- * Gets the configured class prefixes.
- *
- * @return array A hash with class prefixes as keys and directories as values
- */
- public function getPrefixes()
- {
- return $this->prefixes;
- }
-
- /**
- * Gets the directory(ies) to use as a fallback for namespaces.
- *
- * @return array An array of directories
- */
- public function getNamespaceFallback()
- {
- return $this->namespaceFallback;
- }
-
- /**
- * Gets the directory(ies) to use as a fallback for class prefixes.
- *
- * @return array An array of directories
- */
- public function getPrefixFallback()
- {
- return $this->prefixFallback;
- }
-
- /**
- * Registers the directory to use as a fallback for namespaces.
- *
- * @param string|array $dirs A directory path or an array of directories
- */
- public function registerNamespaceFallback($dirs)
- {
- $this->namespaceFallback = (array) $dirs;
- }
-
- /**
- * Registers the directory to use as a fallback for class prefixes.
- *
- * @param string|array $dirs A directory path or an array of directories
- */
- public function registerPrefixFallback($dirs)
- {
- $this->prefixFallback = (array) $dirs;
- }
-
- /**
- * Registers an array of namespaces
- *
- * @param array $namespaces An array of namespaces (namespaces as keys and locations as values)
- */
- public function registerNamespaces(array $namespaces)
- {
- foreach ($namespaces as $namespace => $locations) {
- $this->namespaces[$namespace] = (array) $locations;
- }
- }
-
- /**
- * Registers a namespace.
- *
- * @param string $namespace The namespace
- * @param array|string $paths The location(s) of the namespace
- */
- public function registerNamespace($namespace, $paths)
- {
- $this->namespaces[$namespace] = (array) $paths;
- }
-
- /**
- * Registers an array of classes using the PEAR naming convention.
- *
- * @param array $classes An array of classes (prefixes as keys and locations as values)
- */
- public function registerPrefixes(array $classes)
- {
- foreach ($classes as $prefix => $locations) {
- $this->prefixes[$prefix] = (array) $locations;
- }
- }
-
- /**
- * Registers a set of classes using the PEAR naming convention.
- *
- * @param string $prefix The classes prefix
- * @param array|string $paths The location(s) of the classes
- */
- public function registerPrefix($prefix, $paths)
- {
- $this->prefixes[$prefix] = (array) $paths;
- }
-
- /**
- * Registers this instance as an autoloader.
- *
- * @param Boolean $prepend Whether to prepend the autoloader or not
- */
- public function register($prepend = false)
- {
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
- }
-
- /**
- * Loads the given class or interface.
- *
- * @param string $class The name of the class
- */
- public function loadClass($class)
- {
- $class = ltrim($class, '\\');
-
- if (false !== ($pos = strrpos($class, '\\'))) {
- // namespaced class name
- $namespace = substr($class, 0, $pos);
- foreach ($this->namespaces as $ns => $dirs) {
- foreach ($dirs as $dir) {
- if (0 === strpos($namespace, $ns)) {
- $className = substr($class, $pos + 1);
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php';
- if (file_exists($file)) {
- require $file;
- return;
- }
- }
- }
- }
-
- foreach ($this->namespaceFallback as $dir) {
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
- if (file_exists($file)) {
- require $file;
- return;
- }
- }
- } else {
- // PEAR-like class name
- foreach ($this->prefixes as $prefix => $dirs) {
- foreach ($dirs as $dir) {
- if (0 === strpos($class, $prefix)) {
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
- if (file_exists($file)) {
- require $file;
- return;
- }
- }
- }
- }
-
- foreach ($this->prefixFallback as $dir) {
- $file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
- if (file_exists($file)) {
- require $file;
- return;
- }
- }
- }
- }
-}
View
771 src/vendor/symfony/src/Symfony/Component/Console/Application.php
@@ -1,771 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.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.potencier@symfony-project.com>
- */
-class Application
-{
- protected $commands;
- protected $aliases;
- protected $wantHelps = false;
- protected $runningCommand;
- protected $name;
- protected $version;
- protected $catchExceptions;
- protected $autoExit;
- protected $definition;
- protected $helperSet;
-
- /**
- * Constructor.
- *
- * @param string $name The name of the application
- * @param string $version The version of the application
- */
- 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
- */
- 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
- } else {
- 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(Output::VERBOSITY_QUIET);
- } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
- $output->setVerbosity(Output::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
- */
- 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
- */
- 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->definition->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
- */
- 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
- */
- public function setAutoExit($boolean)
- {
- $this->autoExit = (Boolean) $boolean;
- }
-
- /**
- * Gets the name of the application.
- *
- * @return string The application name
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Sets the application name.
- *
- * @param string $name The application name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
-
- /**
- * Gets the application version.
- *
- * @return string The application version
- */
- public function getVersion()
- {
- return $this->version;
- }
-
- /**
- * Sets the application version.
- *
- * @param string $version The application version
- */
- public function setVersion($version)
- {
- $this->version = $version;
- }
-
- /**
- * Returns the long version of the application.
- *
- * @return string The long application version
- */
- public function getLongVersion()
- {
- if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) {
- return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
- } else {
- return '<info>Console Tool</info>';
- }
- }
-
- /**
- * Registers a new command.
- *
- * @param string $name The command name
- *
- * @return Command The newly created command
- */
- public function register($name)
- {
- return $this->add(new Command($name));
- }
-
- /**
- * Adds an array of command objects.
- *
- * @param Command[] $commands An array of commands
- */
- 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
- */
- 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
- */
- 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
- */
- 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
- */
- 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
- */
- 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 (Output::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
- */
- protected 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
- */
- protected function getAbbreviationSuggestions($abbrevs)
- {
- return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : '');
- }
-}
View
530 src/vendor/symfony/src/Symfony/Component/Console/Command/Command.php
@@ -1,530 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.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.potencier@symfony-project.com>
- */
-class Command
-{
- protected $name;
- protected $namespace;
- protected $aliases;
- protected $definition;
- protected $help;
- protected $application;
- protected $description;
- protected $ignoreValidationErrors;
- protected $applicationDefinitionMerged;
- protected $code;
-
- /**
- * Constructor.
- *
- * @param string $name The name of the command
- *
- * @throws \LogicException When the command name is empty
- */
- 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
- */
- public function setApplication(Application $application = null)
- {
- $this->application = $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()
- */
- public function run(InputInterface $input, OutputInterface $output)
- {
- // 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);
- } else {
- 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()
- */
- public function setCode(\Closure $code)
- {
- $this->code = $code;
-
- return $this;
- }
-
- /**
- * Merges the application definition with the command definition.
- */
- protected 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
- */
- 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
- */
- 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
- */
- 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
- */
- 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
- */
- 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
- */
- public function getNamespace()
- {
- return $this->namespace;
- }
-
- /**
- * Returns the command name
- *
- * @return string The command name
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Returns the fully qualified command name.
- *
- * @return string The fully qualified command name
- */
- 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
- */
- public function setDescription($description)
- {
- $this->description = $description;
-
- return $this;
- }
-
- /**
- * Returns the description for the command.
- *
- * @return string The description for the command
- */
- 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
- */
- public function setHelp($help)
- {
- $this->help = $help;
-
- return $this;
- }
-
- /**
- * Returns the help for the command.
- *
- * @return string The help for the command
- */
- 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
- */
- public function setAliases($aliases)
- {
- $this->aliases = $aliases;
-
- return $this;
- }
-
- /**
- * Returns the aliases for the command.
- *
- * @return array An array of aliases for the command
- */
- public function getAliases()
- {
- return $this->aliases;
- }
-
- /**
- * Returns the synopsis for the command.
- *
- * @return string The synopsis
- */
- public function getSynopsis()
- {
- return sprintf('%s %s', $this->getFullName(), $this->definition->getSynopsis());
- }
-
- /**
- * 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
- */
- protected function getHelper($name)
- {
- return $this->application->getHelperSet()->get($name);
- }
-
- /**
- * 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
- */
- public function __get($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 src/vendor/symfony/src/Symfony/Component/Console/Command/HelpCommand.php
@@ -1,82 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.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.potencier@symfony-project.com>
- */
-class HelpCommand extends Command
-{
- protected $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->application->get($input->getArgument('command_name'));
- }
-
- if ($input->getOption('xml')) {
- $output->writeln($this->command->asXml(), Output::OUTPUT_RAW);
- } else {
- $output->writeln($this->command->asText());
- }
- }
-}
View
67 src/vendor/symfony/src/Symfony/Component/Console/Command/ListCommand.php
@@ -1,67 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.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.potencier@symfony-project.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->application->asXml($input->getArgument('namespace')), Output::OUTPUT_RAW);
- } else {
- $output->writeln($this->application->asText($input->getArgument('namespace')));
- }
- }
-}
View
110 src/vendor/symfony/src/Symfony/Component/Console/Helper/DialogHelper.php
@@ -1,110 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.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;
-
-use Symfony\Component\Console\Output\OutputInterface;
-
-/**
- * The Dialog class provides helpers to interact with the user.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class DialogHelper extends Helper
-{
- /**
- * Asks a question to the user.
- *
- * @param OutputInterface $output
- * @param string|array $question The question to ask
- * @param string $default The default answer if none is given by the user
- *
- * @return string The user answer
- */
- public function ask(OutputInterface $output, $question, $default = null)
- {
- // @codeCoverageIgnoreStart
- $output->writeln($question);
-
- $ret = trim(fgets(STDIN));
-
- return $ret ? $ret : $default;
- // @codeCoverageIgnoreEnd
- }
-
- /**
- * Asks a confirmation to the user.
- *
- * The question will be asked until the user answer by nothing, yes, or no.
- *
- * @param OutputInterface $output
- * @param string|array $question The question to ask
- * @param Boolean $default The default answer if the user enters nothing
- *
- * @return Boolean true if the user has confirmed, false otherwise
- */
- public function askConfirmation(OutputInterface $output, $question, $default = true)
- {
- // @codeCoverageIgnoreStart
- $answer = 'z';
- while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) {
- $answer = $this->ask($output, $question);
- }
-
- if (false === $default) {
- return $answer && 'y' == strtolower($answer[0]);
- } else {
- return !$answer || 'y' == strtolower($answer[0]);
- }
- // @codeCoverageIgnoreEnd
- }
-
- /**
- * Asks for a value and validates the response.
- *
- * @param OutputInterface $output
- * @param string|array $question
- * @param Closure $validator
- * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
- *
- * @return mixed
- *
- * @throws \Exception When any of the validator returns an error
- */
- public function askAndValidate(OutputInterface $output, $question, \Closure $validator, $attempts = false)
- {
- // @codeCoverageIgnoreStart
- $error = null;
- while (false === $attempts || $attempts--) {
- if (null !== $error) {
- $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
- }
-
- $value = $this->ask($output, $question, null);
-
- try {
- return $validator($value);
- } catch (\Exception $error) {
- }
- }
-
- throw $error;
- // @codeCoverageIgnoreEnd
- }
-
- /**
- * Returns the helper's canonical name
- */
- public function getName()
- {
- return 'dialog';
- }
-}
View
91 src/vendor/symfony/src/Symfony/Component/Console/Helper/FormatterHelper.php
@@ -1,91 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien.potencier@symfony-project.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;
-
-/**
- * The Formatter class provides helpers to format messages.
- *
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- */
-class FormatterHelper extends Helper
-{
- /**
- * Formats a message within a section.
- *
- * @param string $section The section name
- * @param string $message The message
- * @param string $style The style to apply to the section
- */
- public function formatSection($section, $message, $style = 'info')
- {
- return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
- }
-
- /**
- * Formats a message as a block of text.
- *
- * @param string|array $messages The message to write in the block
- * @param string $style The style to apply to the whole block
- * @param Boolean $large Whether to return a large block
- *
- * @return string The formatter message
- */
- public function formatBlock($messages, $style, $large = false)
- {
- if (!is_array($messages)) {
- $messages = array($messages);
- }
-
- $len = 0;
- $lines = array();
- foreach ($messages as $message) {
- $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
- $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
- }
-
- $messages = $large ? array(str_repeat(' ', $len)) : array();
- foreach ($lines as $line) {
- $messages[] = $line.str_repeat(' ', $len - $this->strlen($line));
- }
- if ($large) {
- $messages[] = str_repeat(' ', $len);
- }
-
- foreach ($messages as &$message) {
- $message = sprintf('<%s>%s</%s>', $style, $message, $style);
- }
-
- return implode("\n", $messages);
- }
-
- /**
- * Returns the length of a string, uses mb_strlen if it is available.
- *
- * @param string $string The string to check its length
- *
- * @return integer The length of the string
- */
- protected function strlen($string)
- {
- return function_exists('mb_strlen') ? mb_strlen($string) : strlen($string);
- }
-
- /**
- * Returns the helper's canonical name
- *
- * @return string The canonical name of the helper
- */
- public function getName()
- {
- return 'formatter';
- }
-}
View
42 src/vendor/symfony/src/Symfony/Component/Console/Helper/Helper.php
@@ -1,42 +0,0 @@
-<?php
-