Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/console/Descriptor/MarkdownDescriptor.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
29 class MarkdownDescriptor extends Descriptor | 29 class MarkdownDescriptor extends Descriptor |
30 { | 30 { |
31 /** | 31 /** |
32 * {@inheritdoc} | 32 * {@inheritdoc} |
33 */ | 33 */ |
34 public function describe(OutputInterface $output, $object, array $options = array()) | 34 public function describe(OutputInterface $output, $object, array $options = []) |
35 { | 35 { |
36 $decorated = $output->isDecorated(); | 36 $decorated = $output->isDecorated(); |
37 $output->setDecorated(false); | 37 $output->setDecorated(false); |
38 | 38 |
39 parent::describe($output, $object, $options); | 39 parent::describe($output, $object, $options); |
50 } | 50 } |
51 | 51 |
52 /** | 52 /** |
53 * {@inheritdoc} | 53 * {@inheritdoc} |
54 */ | 54 */ |
55 protected function describeInputArgument(InputArgument $argument, array $options = array()) | 55 protected function describeInputArgument(InputArgument $argument, array $options = []) |
56 { | 56 { |
57 $this->write( | 57 $this->write( |
58 '#### `'.($argument->getName() ?: '<none>')."`\n\n" | 58 '#### `'.($argument->getName() ?: '<none>')."`\n\n" |
59 .($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '') | 59 .($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '') |
60 .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" | 60 .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" |
64 } | 64 } |
65 | 65 |
66 /** | 66 /** |
67 * {@inheritdoc} | 67 * {@inheritdoc} |
68 */ | 68 */ |
69 protected function describeInputOption(InputOption $option, array $options = array()) | 69 protected function describeInputOption(InputOption $option, array $options = []) |
70 { | 70 { |
71 $name = '--'.$option->getName(); | 71 $name = '--'.$option->getName(); |
72 if ($option->getShortcut()) { | 72 if ($option->getShortcut()) { |
73 $name .= '|-'.str_replace('|', '|-', $option->getShortcut()).''; | 73 $name .= '|-'.str_replace('|', '|-', $option->getShortcut()).''; |
74 } | 74 } |
84 } | 84 } |
85 | 85 |
86 /** | 86 /** |
87 * {@inheritdoc} | 87 * {@inheritdoc} |
88 */ | 88 */ |
89 protected function describeInputDefinition(InputDefinition $definition, array $options = array()) | 89 protected function describeInputDefinition(InputDefinition $definition, array $options = []) |
90 { | 90 { |
91 if ($showArguments = count($definition->getArguments()) > 0) { | 91 if ($showArguments = \count($definition->getArguments()) > 0) { |
92 $this->write('### Arguments'); | 92 $this->write('### Arguments'); |
93 foreach ($definition->getArguments() as $argument) { | 93 foreach ($definition->getArguments() as $argument) { |
94 $this->write("\n\n"); | 94 $this->write("\n\n"); |
95 $this->write($this->describeInputArgument($argument)); | 95 $this->write($this->describeInputArgument($argument)); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 if (count($definition->getOptions()) > 0) { | 99 if (\count($definition->getOptions()) > 0) { |
100 if ($showArguments) { | 100 if ($showArguments) { |
101 $this->write("\n\n"); | 101 $this->write("\n\n"); |
102 } | 102 } |
103 | 103 |
104 $this->write('### Options'); | 104 $this->write('### Options'); |
110 } | 110 } |
111 | 111 |
112 /** | 112 /** |
113 * {@inheritdoc} | 113 * {@inheritdoc} |
114 */ | 114 */ |
115 protected function describeCommand(Command $command, array $options = array()) | 115 protected function describeCommand(Command $command, array $options = []) |
116 { | 116 { |
117 $command->getSynopsis(); | 117 $command->getSynopsis(); |
118 $command->mergeApplicationDefinition(false); | 118 $command->mergeApplicationDefinition(false); |
119 | 119 |
120 $this->write( | 120 $this->write( |
121 '`'.$command->getName()."`\n" | 121 '`'.$command->getName()."`\n" |
122 .str_repeat('-', Helper::strlen($command->getName()) + 2)."\n\n" | 122 .str_repeat('-', Helper::strlen($command->getName()) + 2)."\n\n" |
123 .($command->getDescription() ? $command->getDescription()."\n\n" : '') | 123 .($command->getDescription() ? $command->getDescription()."\n\n" : '') |
124 .'### Usage'."\n\n" | 124 .'### Usage'."\n\n" |
125 .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) { | 125 .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) { |
126 return $carry.'* `'.$usage.'`'."\n"; | 126 return $carry.'* `'.$usage.'`'."\n"; |
127 }) | 127 }) |
128 ); | 128 ); |
129 | 129 |
130 if ($help = $command->getProcessedHelp()) { | 130 if ($help = $command->getProcessedHelp()) { |
139 } | 139 } |
140 | 140 |
141 /** | 141 /** |
142 * {@inheritdoc} | 142 * {@inheritdoc} |
143 */ | 143 */ |
144 protected function describeApplication(Application $application, array $options = array()) | 144 protected function describeApplication(Application $application, array $options = []) |
145 { | 145 { |
146 $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; | 146 $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
147 $description = new ApplicationDescription($application, $describedNamespace); | 147 $description = new ApplicationDescription($application, $describedNamespace); |
148 $title = $this->getApplicationTitle($application); | 148 $title = $this->getApplicationTitle($application); |
149 | 149 |