diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-05-11 15:02:33 +0200 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-05-11 15:02:33 +0200 |
| commit | a7e17cb70e9306f8887bd2b5ca1a37edcbe3ea0f (patch) | |
| tree | bf6e04c9bdba66e249fd6b78391e132da130848c /Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor | |
| parent | ea3fed0df4eaedd820f3f405502b62efe5952f8f (diff) | |
| download | InternetTechnologien-a7e17cb70e9306f8887bd2b5ca1a37edcbe3ea0f.tar.gz InternetTechnologien-a7e17cb70e9306f8887bd2b5ca1a37edcbe3ea0f.zip | |
Let composer manage its own files
Diffstat (limited to 'Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor')
7 files changed, 0 insertions, 1136 deletions
diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php deleted file mode 100644 index a0a5df2..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ /dev/null @@ -1,155 +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\Descriptor; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; - -/** - * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> - * - * @internal - */ -class ApplicationDescription -{ - const GLOBAL_NAMESPACE = '_global'; - - /** - * @var Application - */ - private $application; - - /** - * @var null|string - */ - private $namespace; - - /** - * @var array - */ - private $namespaces; - - /** - * @var Command[] - */ - private $commands; - - /** - * @var Command[] - */ - private $aliases; - - /** - * Constructor. - * - * @param Application $application - * @param string|null $namespace - */ - public function __construct(Application $application, $namespace = null) - { - $this->application = $application; - $this->namespace = $namespace; - } - - /** - * @return array - */ - public function getNamespaces() - { - if (null === $this->namespaces) { - $this->inspectApplication(); - } - - return $this->namespaces; - } - - /** - * @return Command[] - */ - public function getCommands() - { - if (null === $this->commands) { - $this->inspectApplication(); - } - - return $this->commands; - } - - /** - * @param string $name - * - * @return Command - * - * @throws \InvalidArgumentException - */ - public function getCommand($name) - { - if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { - throw new \InvalidArgumentException(sprintf('Command %s does not exist.', $name)); - } - - return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; - } - - private function inspectApplication() - { - $this->commands = array(); - $this->namespaces = array(); - - $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null); - foreach ($this->sortCommands($all) as $namespace => $commands) { - $names = array(); - - /** @var Command $command */ - foreach ($commands as $name => $command) { - if (!$command->getName()) { - continue; - } - - if ($command->getName() === $name) { - $this->commands[$name] = $command; - } else { - $this->aliases[$name] = $command; - } - - $names[] = $name; - } - - $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names); - } - } - - /** - * @param array $commands - * - * @return array - */ - private function sortCommands(array $commands) - { - $namespacedCommands = array(); - foreach ($commands as $name => $command) { - $key = $this->application->extractNamespace($name, 1); - if (!$key) { - $key = '_global'; - } - - $namespacedCommands[$key][$name] = $command; - } - ksort($namespacedCommands); - - foreach ($namespacedCommands as &$commands) { - ksort($commands); - } - - return $namespacedCommands; - } -} diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php deleted file mode 100644 index 49e2193..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php +++ /dev/null @@ -1,121 +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\Descriptor; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com> - * - * @internal - */ -abstract class Descriptor implements DescriptorInterface -{ - /** - * @var OutputInterface - */ - private $output; - - /** - * {@inheritdoc} - */ - public function describe(OutputInterface $output, $object, array $options = array()) - { - $this->output = $output; - - switch (true) { - case $object instanceof InputArgument: - $this->describeInputArgument($object, $options); - break; - case $object instanceof InputOption: - $this->describeInputOption($object, $options); - break; - case $object instanceof InputDefinition: - $this->describeInputDefinition($object, $options); - break; - case $object instanceof Command: - $this->describeCommand($object, $options); - break; - case $object instanceof Application: - $this->describeApplication($object, $options); - break; - default: - throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); - } - } - - /** - * Writes content to output. - * - * @param string $content - * @param bool $decorated - */ - protected function write($content, $decorated = false) - { - $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); - } - - /** - * Describes an InputArgument instance. - * - * @param InputArgument $argument - * @param array $options - * - * @return string|mixed - */ - abstract protected function describeInputArgument(InputArgument $argument, array $options = array()); - - /** - * Describes an InputOption instance. - * - * @param InputOption $option - * @param array $options - * - * @return string|mixed - */ - abstract protected function describeInputOption(InputOption $option, array $options = array()); - - /** - * Describes an InputDefinition instance. - * - * @param InputDefinition $definition - * @param array $options - * - * @return string|mixed - */ - abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array()); - - /** - * Describes a Command instance. - * - * @param Command $command - * @param array $options - * - * @return string|mixed - */ - abstract protected function describeCommand(Command $command, array $options = array()); - - /** - * Describes an Application instance. - * - * @param Application $application - * @param array $options - * - * @return string|mixed - */ - abstract protected function describeApplication(Application $application, array $options = array()); -} diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php deleted file mode 100644 index 3929b6d..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php +++ /dev/null @@ -1,31 +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\Descriptor; - -use Symfony\Component\Console\Output\OutputInterface; - -/** - * Descriptor interface. - * - * @author Jean-François Simon <contact@jfsimon.fr> - */ -interface DescriptorInterface -{ - /** - * Describes an InputArgument instance. - * - * @param OutputInterface $output - * @param object $object - * @param array $options - */ - public function describe(OutputInterface $output, $object, array $options = array()); -} diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php deleted file mode 100644 index 13785a4..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php +++ /dev/null @@ -1,167 +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\Descriptor; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; - -/** - * JSON descriptor. - * - * @author Jean-François Simon <contact@jfsimon.fr> - * - * @internal - */ -class JsonDescriptor extends Descriptor -{ - /** - * {@inheritdoc} - */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) - { - $this->writeData($this->getInputArgumentData($argument), $options); - } - - /** - * {@inheritdoc} - */ - protected function describeInputOption(InputOption $option, array $options = array()) - { - $this->writeData($this->getInputOptionData($option), $options); - } - - /** - * {@inheritdoc} - */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) - { - $this->writeData($this->getInputDefinitionData($definition), $options); - } - - /** - * {@inheritdoc} - */ - protected function describeCommand(Command $command, array $options = array()) - { - $this->writeData($this->getCommandData($command), $options); - } - - /** - * {@inheritdoc} - */ - protected function describeApplication(Application $application, array $options = array()) - { - $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; - $description = new ApplicationDescription($application, $describedNamespace); - $commands = array(); - - foreach ($description->getCommands() as $command) { - $commands[] = $this->getCommandData($command); - } - - $data = $describedNamespace - ? array('commands' => $commands, 'namespace' => $describedNamespace) - : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces())); - - $this->writeData($data, $options); - } - - /** - * Writes data as json. - * - * @param array $data - * @param array $options - * - * @return array|string - */ - private function writeData(array $data, array $options) - { - $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0)); - } - - /** - * @param InputArgument $argument - * - * @return array - */ - private function getInputArgumentData(InputArgument $argument) - { - return array( - 'name' => $argument->getName(), - 'is_required' => $argument->isRequired(), - 'is_array' => $argument->isArray(), - 'description' => $argument->getDescription(), - 'default' => $argument->getDefault(), - ); - } - - /** - * @param InputOption $option - * - * @return array - */ - private function getInputOptionData(InputOption $option) - { - return array( - 'name' => '--'.$option->getName(), - 'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '', - 'accept_value' => $option->acceptValue(), - 'is_value_required' => $option->isValueRequired(), - 'is_multiple' => $option->isArray(), - 'description' => $option->getDescription(), - 'default' => $option->getDefault(), - ); - } - - /** - * @param InputDefinition $definition - * - * @return array - */ - private function getInputDefinitionData(InputDefinition $definition) - { - $inputArguments = array(); - foreach ($definition->getArguments() as $name => $argument) { - $inputArguments[$name] = $this->getInputArgumentData($argument); - } - - $inputOptions = array(); - foreach ($definition->getOptions() as $name => $option) { - $inputOptions[$name] = $this->getInputOptionData($option); - } - - return array('arguments' => $inputArguments, 'options' => $inputOptions); - } - - /** - * @param Command $command - * - * @return array - */ - private function getCommandData(Command $command) - { - $command->getSynopsis(); - $command->mergeApplicationDefinition(false); - - return array( - 'name' => $command->getName(), - 'usage' => $command->getSynopsis(), - 'description' => $command->getDescription(), - 'help' => $command->getProcessedHelp(), - 'aliases' => $command->getAliases(), - 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()), - ); - } -} diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php deleted file mode 100644 index 78d48b9..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ /dev/null @@ -1,141 +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\Descriptor; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; - -/** - * Markdown descriptor. - * - * @author Jean-François Simon <contact@jfsimon.fr> - * - * @internal - */ -class MarkdownDescriptor extends Descriptor -{ - /** - * {@inheritdoc} - */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) - { - $this->write( - '**'.$argument->getName().':**'."\n\n" - .'* Name: '.($argument->getName() ?: '<none>')."\n" - .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" - .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n" - .'* Description: '.($argument->getDescription() ?: '<none>')."\n" - .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`' - ); - } - - /** - * {@inheritdoc} - */ - protected function describeInputOption(InputOption $option, array $options = array()) - { - $this->write( - '**'.$option->getName().':**'."\n\n" - .'* Name: `--'.$option->getName().'`'."\n" - .'* Shortcut: '.($option->getShortcut() ? '`-'.implode('|-', explode('|', $option->getShortcut())).'`' : '<none>')."\n" - .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" - .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" - .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" - .'* Description: '.($option->getDescription() ?: '<none>')."\n" - .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`' - ); - } - - /** - * {@inheritdoc} - */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) - { - if ($showArguments = count($definition->getArguments()) > 0) { - $this->write('### Arguments:'); - foreach ($definition->getArguments() as $argument) { - $this->write("\n\n"); - $this->write($this->describeInputArgument($argument)); - } - } - - if (count($definition->getOptions()) > 0) { - if ($showArguments) { - $this->write("\n\n"); - } - - $this->write('### Options:'); - foreach ($definition->getOptions() as $option) { - $this->write("\n\n"); - $this->write($this->describeInputOption($option)); - } - } - } - - /** - * {@inheritdoc} - */ - protected function describeCommand(Command $command, array $options = array()) - { - $command->getSynopsis(); - $command->mergeApplicationDefinition(false); - - $this->write( - $command->getName()."\n" - .str_repeat('-', strlen($command->getName()))."\n\n" - .'* Description: '.($command->getDescription() ?: '<none>')."\n" - .'* Usage: `'.$command->getSynopsis().'`'."\n" - .'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '<none>') - ); - - if ($help = $command->getProcessedHelp()) { - $this->write("\n\n"); - $this->write($help); - } - - if ($command->getNativeDefinition()) { - $this->write("\n\n"); - $this->describeInputDefinition($command->getNativeDefinition()); - } - } - - /** - * {@inheritdoc} - */ - protected function describeApplication(Application $application, array $options = array()) - { - $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; - $description = new ApplicationDescription($application, $describedNamespace); - - $this->write($application->getName()."\n".str_repeat('=', strlen($application->getName()))); - - foreach ($description->getNamespaces() as $namespace) { - if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { - $this->write("\n\n"); - $this->write('**'.$namespace['id'].':**'); - } - - $this->write("\n\n"); - $this->write(implode("\n", array_map(function ($commandName) { - return '* '.$commandName; - }, $namespace['commands']))); - } - - foreach ($description->getCommands() as $command) { - $this->write("\n\n"); - $this->write($this->describeCommand($command)); - } - } -} diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php deleted file mode 100644 index 0b3dd5a..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ /dev/null @@ -1,255 +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\Descriptor; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; - -/** - * Text descriptor. - * - * @author Jean-François Simon <contact@jfsimon.fr> - * - * @internal - */ -class TextDescriptor extends Descriptor -{ - /** - * {@inheritdoc} - */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) - { - if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) { - $default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault())); - } else { - $default = ''; - } - - $nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($argument->getName()); - - $this->writeText(sprintf(" <info>%-${nameWidth}s</info> %s%s", - $argument->getName(), - str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $argument->getDescription()), - $default - ), $options); - } - - /** - * {@inheritdoc} - */ - protected function describeInputOption(InputOption $option, array $options = array()) - { - if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { - $default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault())); - } else { - $default = ''; - } - - $nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($option->getName()); - $nameWithShortcutWidth = $nameWidth - strlen($option->getName()) - 2; - - $this->writeText(sprintf(" <info>%s</info> %-${nameWithShortcutWidth}s%s%s%s", - '--'.$option->getName(), - $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', - str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $option->getDescription()), - $default, - $option->isArray() ? '<comment> (multiple values allowed)</comment>' : '' - ), $options); - } - - /** - * {@inheritdoc} - */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) - { - $nameWidth = 0; - foreach ($definition->getOptions() as $option) { - $nameLength = strlen($option->getName()) + 2; - if ($option->getShortcut()) { - $nameLength += strlen($option->getShortcut()) + 3; - } - $nameWidth = max($nameWidth, $nameLength); - } - foreach ($definition->getArguments() as $argument) { - $nameWidth = max($nameWidth, strlen($argument->getName())); - } - ++$nameWidth; - - if ($definition->getArguments()) { - $this->writeText('<comment>Arguments:</comment>', $options); - $this->writeText("\n"); - foreach ($definition->getArguments() as $argument) { - $this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth))); - $this->writeText("\n"); - } - } - - if ($definition->getArguments() && $definition->getOptions()) { - $this->writeText("\n"); - } - - if ($definition->getOptions()) { - $this->writeText('<comment>Options:</comment>', $options); - $this->writeText("\n"); - foreach ($definition->getOptions() as $option) { - $this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth))); - $this->writeText("\n"); - } - } - } - - /** - * {@inheritdoc} - */ - protected function describeCommand(Command $command, array $options = array()) - { - $command->getSynopsis(); - $command->mergeApplicationDefinition(false); - - $this->writeText('<comment>Usage:</comment>', $options); - $this->writeText("\n"); - $this->writeText(' '.$command->getSynopsis(), $options); - $this->writeText("\n"); - - if (count($command->getAliases()) > 0) { - $this->writeText("\n"); - $this->writeText('<comment>Aliases:</comment> <info>'.implode(', ', $command->getAliases()).'</info>', $options); - } - - if ($definition = $command->getNativeDefinition()) { - $this->writeText("\n"); - $this->describeInputDefinition($definition, $options); - } - - $this->writeText("\n"); - - if ($help = $command->getProcessedHelp()) { - $this->writeText('<comment>Help:</comment>', $options); - $this->writeText("\n"); - $this->writeText(' '.str_replace("\n", "\n ", $help), $options); - $this->writeText("\n"); - } - } - - /** - * {@inheritdoc} - */ - protected function describeApplication(Application $application, array $options = array()) - { - $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; - $description = new ApplicationDescription($application, $describedNamespace); - - if (isset($options['raw_text']) && $options['raw_text']) { - $width = $this->getColumnWidth($description->getCommands()); - - foreach ($description->getCommands() as $command) { - $this->writeText(sprintf("%-${width}s %s", $command->getName(), $command->getDescription()), $options); - $this->writeText("\n"); - } - } else { - if ('' != $help = $application->getHelp()) { - $this->writeText("$help\n\n", $options); - } - - $this->writeText("<comment>Usage:</comment>\n", $options); - $this->writeText(" command [options] [arguments]\n\n", $options); - $this->writeText('<comment>Options:</comment>', $options); - - $inputOptions = $application->getDefinition()->getOptions(); - - $width = 0; - foreach ($inputOptions as $option) { - $nameLength = strlen($option->getName()) + 2; - if ($option->getShortcut()) { - $nameLength += strlen($option->getShortcut()) + 3; - } - $width = max($width, $nameLength); - } - ++$width; - - foreach ($inputOptions as $option) { - $this->writeText("\n", $options); - $this->describeInputOption($option, array_merge($options, array('name_width' => $width))); - } - - $this->writeText("\n\n", $options); - - $width = $this->getColumnWidth($description->getCommands()); - - if ($describedNamespace) { - $this->writeText(sprintf("<comment>Available commands for the \"%s\" namespace:</comment>", $describedNamespace), $options); - } else { - $this->writeText('<comment>Available commands:</comment>', $options); - } - - // add commands by namespace - foreach ($description->getNamespaces() as $namespace) { - if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { - $this->writeText("\n"); - $this->writeText('<comment>'.$namespace['id'].'</comment>', $options); - } - - foreach ($namespace['commands'] as $name) { - $this->writeText("\n"); - $this->writeText(sprintf(" <info>%-${width}s</info> %s", $name, $description->getCommand($name)->getDescription()), $options); - } - } - - $this->writeText("\n"); - } - } - - /** - * {@inheritdoc} - */ - private function writeText($content, array $options = array()) - { - $this->write( - isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, - isset($options['raw_output']) ? !$options['raw_output'] : true - ); - } - - /** - * Formats input option/argument default value. - * - * @param mixed $default - * - * @return string - */ - private function formatDefaultValue($default) - { - if (PHP_VERSION_ID < 50400) { - return str_replace('\/', '/', json_encode($default)); - } - - return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - } - - /** - * @param Command[] $commands - * - * @return int - */ - private function getColumnWidth(array $commands) - { - $width = 0; - foreach ($commands as $command) { - $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; - } - - return $width + 2; - } -} diff --git a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php deleted file mode 100644 index 5054686..0000000 --- a/Aufgabe06/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php +++ /dev/null @@ -1,266 +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\Descriptor; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; - -/** - * XML descriptor. - * - * @author Jean-François Simon <contact@jfsimon.fr> - * - * @internal - */ -class XmlDescriptor extends Descriptor -{ - /** - * @param InputDefinition $definition - * - * @return \DOMDocument - */ - public function getInputDefinitionDocument(InputDefinition $definition) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->appendChild($definitionXML = $dom->createElement('definition')); - - $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments')); - foreach ($definition->getArguments() as $argument) { - $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument)); - } - - $definitionXML->appendChild($optionsXML = $dom->createElement('options')); - foreach ($definition->getOptions() as $option) { - $this->appendDocument($optionsXML, $this->getInputOptionDocument($option)); - } - - return $dom; - } - - /** - * @param Command $command - * - * @return \DOMDocument - */ - public function getCommandDocument(Command $command) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->appendChild($commandXML = $dom->createElement('command')); - - $command->getSynopsis(); - $command->mergeApplicationDefinition(false); - - $commandXML->setAttribute('id', $command->getName()); - $commandXML->setAttribute('name', $command->getName()); - - $commandXML->appendChild($usageXML = $dom->createElement('usage')); - $usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), ''))); - - $commandXML->appendChild($descriptionXML = $dom->createElement('description')); - $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription()))); - - $commandXML->appendChild($helpXML = $dom->createElement('help')); - $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp()))); - - $commandXML->appendChild($aliasesXML = $dom->createElement('aliases')); - foreach ($command->getAliases() as $alias) { - $aliasesXML->appendChild($aliasXML = $dom->createElement('alias')); - $aliasXML->appendChild($dom->createTextNode($alias)); - } - - $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition()); - $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0)); - - return $dom; - } - - /** - * @param Application $application - * @param string|null $namespace - * - * @return \DOMDocument - */ - public function getApplicationDocument(Application $application, $namespace = null) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->appendChild($rootXml = $dom->createElement('symfony')); - - if ($application->getName() !== 'UNKNOWN') { - $rootXml->setAttribute('name', $application->getName()); - if ($application->getVersion() !== 'UNKNOWN') { - $rootXml->setAttribute('version', $application->getVersion()); - } - } - - $rootXml->appendChild($commandsXML = $dom->createElement('commands')); - - $description = new ApplicationDescription($application, $namespace); - - if ($namespace) { - $commandsXML->setAttribute('namespace', $namespace); - } - - foreach ($description->getCommands() as $command) { - $this->appendDocument($commandsXML, $this->getCommandDocument($command)); - } - - if (!$namespace) { - $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces')); - - foreach ($description->getNamespaces() as $namespaceDescription) { - $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace')); - $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']); - - foreach ($namespaceDescription['commands'] as $name) { - $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command')); - $commandXML->appendChild($dom->createTextNode($name)); - } - } - } - - return $dom; - } - - /** - * {@inheritdoc} - */ - protected function describeInputArgument(InputArgument $argument, array $options = array()) - { - $this->writeDocument($this->getInputArgumentDocument($argument)); - } - - /** - * {@inheritdoc} - */ - protected function describeInputOption(InputOption $option, array $options = array()) - { - $this->writeDocument($this->getInputOptionDocument($option)); - } - - /** - * {@inheritdoc} - */ - protected function describeInputDefinition(InputDefinition $definition, array $options = array()) - { - $this->writeDocument($this->getInputDefinitionDocument($definition)); - } - - /** - * {@inheritdoc} - */ - protected function describeCommand(Command $command, array $options = array()) - { - $this->writeDocument($this->getCommandDocument($command)); - } - - /** - * {@inheritdoc} - */ - protected function describeApplication(Application $application, array $options = array()) - { - $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null)); - } - - /** - * Appends document children to parent node. - * - * @param \DOMNode $parentNode - * @param \DOMNode $importedParent - */ - private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent) - { - foreach ($importedParent->childNodes as $childNode) { - $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true)); - } - } - - /** - * Writes DOM document. - * - * @param \DOMDocument $dom - * - * @return \DOMDocument|string - */ - private function writeDocument(\DOMDocument $dom) - { - $dom->formatOutput = true; - $this->write($dom->saveXML()); - } - - /** - * @param InputArgument $argument - * - * @return \DOMDocument - */ - private function getInputArgumentDocument(InputArgument $argument) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - - $dom->appendChild($objectXML = $dom->createElement('argument')); - $objectXML->setAttribute('name', $argument->getName()); - $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0); - $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0); - $objectXML->appendChild($descriptionXML = $dom->createElement('description')); - $descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); - - $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); - $defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); - foreach ($defaults as $default) { - $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); - $defaultXML->appendChild($dom->createTextNode($default)); - } - - return $dom; - } - - /** - * @param InputOption $option - * - * @return \DOMDocument - */ - private function getInputOptionDocument(InputOption $option) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - - $dom->appendChild($objectXML = $dom->createElement('option')); - $objectXML->setAttribute('name', '--'.$option->getName()); - $pos = strpos($option->getShortcut(), '|'); - if (false !== $pos) { - $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos)); - $objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut()))); - } else { - $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); - } - $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); - $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); - $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); - $objectXML->appendChild($descriptionXML = $dom->createElement('description')); - $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); - - if ($option->acceptValue()) { - $defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); - $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); - - if (!empty($defaults)) { - foreach ($defaults as $default) { - $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); - $defaultXML->appendChild($dom->createTextNode($default)); - } - } - } - - return $dom; - } -} |
