Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/console/Descriptor/JsonDescriptor.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 |
---|---|
27 class JsonDescriptor extends Descriptor | 27 class JsonDescriptor extends Descriptor |
28 { | 28 { |
29 /** | 29 /** |
30 * {@inheritdoc} | 30 * {@inheritdoc} |
31 */ | 31 */ |
32 protected function describeInputArgument(InputArgument $argument, array $options = array()) | 32 protected function describeInputArgument(InputArgument $argument, array $options = []) |
33 { | 33 { |
34 $this->writeData($this->getInputArgumentData($argument), $options); | 34 $this->writeData($this->getInputArgumentData($argument), $options); |
35 } | 35 } |
36 | 36 |
37 /** | 37 /** |
38 * {@inheritdoc} | 38 * {@inheritdoc} |
39 */ | 39 */ |
40 protected function describeInputOption(InputOption $option, array $options = array()) | 40 protected function describeInputOption(InputOption $option, array $options = []) |
41 { | 41 { |
42 $this->writeData($this->getInputOptionData($option), $options); | 42 $this->writeData($this->getInputOptionData($option), $options); |
43 } | 43 } |
44 | 44 |
45 /** | 45 /** |
46 * {@inheritdoc} | 46 * {@inheritdoc} |
47 */ | 47 */ |
48 protected function describeInputDefinition(InputDefinition $definition, array $options = array()) | 48 protected function describeInputDefinition(InputDefinition $definition, array $options = []) |
49 { | 49 { |
50 $this->writeData($this->getInputDefinitionData($definition), $options); | 50 $this->writeData($this->getInputDefinitionData($definition), $options); |
51 } | 51 } |
52 | 52 |
53 /** | 53 /** |
54 * {@inheritdoc} | 54 * {@inheritdoc} |
55 */ | 55 */ |
56 protected function describeCommand(Command $command, array $options = array()) | 56 protected function describeCommand(Command $command, array $options = []) |
57 { | 57 { |
58 $this->writeData($this->getCommandData($command), $options); | 58 $this->writeData($this->getCommandData($command), $options); |
59 } | 59 } |
60 | 60 |
61 /** | 61 /** |
62 * {@inheritdoc} | 62 * {@inheritdoc} |
63 */ | 63 */ |
64 protected function describeApplication(Application $application, array $options = array()) | 64 protected function describeApplication(Application $application, array $options = []) |
65 { | 65 { |
66 $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; | 66 $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
67 $description = new ApplicationDescription($application, $describedNamespace, true); | 67 $description = new ApplicationDescription($application, $describedNamespace, true); |
68 $commands = array(); | 68 $commands = []; |
69 | 69 |
70 foreach ($description->getCommands() as $command) { | 70 foreach ($description->getCommands() as $command) { |
71 $commands[] = $this->getCommandData($command); | 71 $commands[] = $this->getCommandData($command); |
72 } | 72 } |
73 | 73 |
74 $data = array(); | 74 $data = []; |
75 if ('UNKNOWN' !== $application->getName()) { | 75 if ('UNKNOWN' !== $application->getName()) { |
76 $data['application']['name'] = $application->getName(); | 76 $data['application']['name'] = $application->getName(); |
77 if ('UNKNOWN' !== $application->getVersion()) { | 77 if ('UNKNOWN' !== $application->getVersion()) { |
78 $data['application']['version'] = $application->getVersion(); | 78 $data['application']['version'] = $application->getVersion(); |
79 } | 79 } |
103 /** | 103 /** |
104 * @return array | 104 * @return array |
105 */ | 105 */ |
106 private function getInputArgumentData(InputArgument $argument) | 106 private function getInputArgumentData(InputArgument $argument) |
107 { | 107 { |
108 return array( | 108 return [ |
109 'name' => $argument->getName(), | 109 'name' => $argument->getName(), |
110 'is_required' => $argument->isRequired(), | 110 'is_required' => $argument->isRequired(), |
111 'is_array' => $argument->isArray(), | 111 'is_array' => $argument->isArray(), |
112 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), | 112 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()), |
113 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), | 113 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(), |
114 ); | 114 ]; |
115 } | 115 } |
116 | 116 |
117 /** | 117 /** |
118 * @return array | 118 * @return array |
119 */ | 119 */ |
120 private function getInputOptionData(InputOption $option) | 120 private function getInputOptionData(InputOption $option) |
121 { | 121 { |
122 return array( | 122 return [ |
123 'name' => '--'.$option->getName(), | 123 'name' => '--'.$option->getName(), |
124 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', | 124 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '', |
125 'accept_value' => $option->acceptValue(), | 125 'accept_value' => $option->acceptValue(), |
126 'is_value_required' => $option->isValueRequired(), | 126 'is_value_required' => $option->isValueRequired(), |
127 'is_multiple' => $option->isArray(), | 127 'is_multiple' => $option->isArray(), |
128 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), | 128 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()), |
129 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(), | 129 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(), |
130 ); | 130 ]; |
131 } | 131 } |
132 | 132 |
133 /** | 133 /** |
134 * @return array | 134 * @return array |
135 */ | 135 */ |
136 private function getInputDefinitionData(InputDefinition $definition) | 136 private function getInputDefinitionData(InputDefinition $definition) |
137 { | 137 { |
138 $inputArguments = array(); | 138 $inputArguments = []; |
139 foreach ($definition->getArguments() as $name => $argument) { | 139 foreach ($definition->getArguments() as $name => $argument) { |
140 $inputArguments[$name] = $this->getInputArgumentData($argument); | 140 $inputArguments[$name] = $this->getInputArgumentData($argument); |
141 } | 141 } |
142 | 142 |
143 $inputOptions = array(); | 143 $inputOptions = []; |
144 foreach ($definition->getOptions() as $name => $option) { | 144 foreach ($definition->getOptions() as $name => $option) { |
145 $inputOptions[$name] = $this->getInputOptionData($option); | 145 $inputOptions[$name] = $this->getInputOptionData($option); |
146 } | 146 } |
147 | 147 |
148 return array('arguments' => $inputArguments, 'options' => $inputOptions); | 148 return ['arguments' => $inputArguments, 'options' => $inputOptions]; |
149 } | 149 } |
150 | 150 |
151 /** | 151 /** |
152 * @return array | 152 * @return array |
153 */ | 153 */ |
154 private function getCommandData(Command $command) | 154 private function getCommandData(Command $command) |
155 { | 155 { |
156 $command->getSynopsis(); | 156 $command->getSynopsis(); |
157 $command->mergeApplicationDefinition(false); | 157 $command->mergeApplicationDefinition(false); |
158 | 158 |
159 return array( | 159 return [ |
160 'name' => $command->getName(), | 160 'name' => $command->getName(), |
161 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()), | 161 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()), |
162 'description' => $command->getDescription(), | 162 'description' => $command->getDescription(), |
163 'help' => $command->getProcessedHelp(), | 163 'help' => $command->getProcessedHelp(), |
164 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()), | 164 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()), |
165 'hidden' => $command->isHidden(), | 165 'hidden' => $command->isHidden(), |
166 ); | 166 ]; |
167 } | 167 } |
168 } | 168 } |