@@ -33,309 +33,309 @@ |
||
| 33 | 33 | |
| 34 | 34 | final class IO extends SymfonyStyle |
| 35 | 35 | { |
| 36 | - private InputInterface $input; |
|
| 37 | - private OutputInterface $output; |
|
| 36 | + private InputInterface $input; |
|
| 37 | + private OutputInterface $output; |
|
| 38 | 38 | |
| 39 | - public function __construct(InputInterface $input, OutputInterface $output) |
|
| 40 | - { |
|
| 41 | - parent::__construct($input, $output); |
|
| 39 | + public function __construct(InputInterface $input, OutputInterface $output) |
|
| 40 | + { |
|
| 41 | + parent::__construct($input, $output); |
|
| 42 | 42 | |
| 43 | - $this->input = $input; |
|
| 44 | - $this->output = $output; |
|
| 45 | - } |
|
| 43 | + $this->input = $input; |
|
| 44 | + $this->output = $output; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public static function createNull(): self |
|
| 48 | - { |
|
| 49 | - return new self( |
|
| 50 | - new StringInput(''), |
|
| 51 | - new NullOutput() |
|
| 52 | - ); |
|
| 53 | - } |
|
| 47 | + public static function createNull(): self |
|
| 48 | + { |
|
| 49 | + return new self( |
|
| 50 | + new StringInput(''), |
|
| 51 | + new NullOutput() |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function getInput(): InputInterface |
|
| 56 | - { |
|
| 57 | - return $this->input; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function getBooleanArgument(string $name): bool |
|
| 61 | - { |
|
| 62 | - $argument = $this->getArgument($name); |
|
| 63 | - |
|
| 64 | - ConsoleAssert::assertIsNotArray($argument); |
|
| 55 | + public function getInput(): InputInterface |
|
| 56 | + { |
|
| 57 | + return $this->input; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function getBooleanArgument(string $name): bool |
|
| 61 | + { |
|
| 62 | + $argument = $this->getArgument($name); |
|
| 63 | + |
|
| 64 | + ConsoleAssert::assertIsNotArray($argument); |
|
| 65 | 65 | |
| 66 | - return (bool) $argument; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function getNullableBooleanArgument(string $name): ?bool |
|
| 70 | - { |
|
| 71 | - if (null === $this->getArgument($name)) { |
|
| 72 | - return null; |
|
| 73 | - } |
|
| 66 | + return (bool) $argument; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function getNullableBooleanArgument(string $name): ?bool |
|
| 70 | + { |
|
| 71 | + if (null === $this->getArgument($name)) { |
|
| 72 | + return null; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return $this->getBooleanArgument($name); |
|
| 76 | - } |
|
| 75 | + return $this->getBooleanArgument($name); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function getStringArgument(string $name): string |
|
| 79 | - { |
|
| 80 | - $argument = $this->getArgument($name); |
|
| 81 | - |
|
| 82 | - ConsoleAssert::assertIsNotArray($argument); |
|
| 83 | - |
|
| 84 | - return (string) $argument; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - public function getNullableStringArgument(string $name): ?string |
|
| 88 | - { |
|
| 89 | - if (null === $this->getArgument($name)) { |
|
| 90 | - return null; |
|
| 91 | - } |
|
| 78 | + public function getStringArgument(string $name): string |
|
| 79 | + { |
|
| 80 | + $argument = $this->getArgument($name); |
|
| 81 | + |
|
| 82 | + ConsoleAssert::assertIsNotArray($argument); |
|
| 83 | + |
|
| 84 | + return (string) $argument; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + public function getNullableStringArgument(string $name): ?string |
|
| 88 | + { |
|
| 89 | + if (null === $this->getArgument($name)) { |
|
| 90 | + return null; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return $this->getStringArgument($name); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @return string[] |
|
| 98 | - */ |
|
| 99 | - public function getStringArrayArgument(string $name): array |
|
| 100 | - { |
|
| 101 | - $argument = $this->getArgument($name); |
|
| 93 | + return $this->getStringArgument($name); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @return string[] |
|
| 98 | + */ |
|
| 99 | + public function getStringArrayArgument(string $name): array |
|
| 100 | + { |
|
| 101 | + $argument = $this->getArgument($name); |
|
| 102 | 102 | |
| 103 | - ConsoleAssert::assertIsArray($argument); |
|
| 104 | - |
|
| 105 | - return $argument; |
|
| 106 | - } |
|
| 103 | + ConsoleAssert::assertIsArray($argument); |
|
| 104 | + |
|
| 105 | + return $argument; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - public function getIntegerArgument(string $name): int |
|
| 109 | - { |
|
| 110 | - $argument = $this->getArgument($name); |
|
| 108 | + public function getIntegerArgument(string $name): int |
|
| 109 | + { |
|
| 110 | + $argument = $this->getArgument($name); |
|
| 111 | 111 | |
| 112 | - ConsoleAssert::assertIsNotArray($argument); |
|
| 113 | - ConsoleAssert::integer($argument); |
|
| 112 | + ConsoleAssert::assertIsNotArray($argument); |
|
| 113 | + ConsoleAssert::integer($argument); |
|
| 114 | 114 | |
| 115 | - return (int) $argument; |
|
| 116 | - } |
|
| 115 | + return (int) $argument; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - public function getNullableIntegerArgument(string $name): ?int |
|
| 119 | - { |
|
| 120 | - if (null === $this->getArgument($name)) { |
|
| 121 | - return null; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $this->getIntegerArgument($name); |
|
| 125 | - } |
|
| 118 | + public function getNullableIntegerArgument(string $name): ?int |
|
| 119 | + { |
|
| 120 | + if (null === $this->getArgument($name)) { |
|
| 121 | + return null; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $this->getIntegerArgument($name); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * @return int[] |
|
| 129 | - */ |
|
| 130 | - public function getIntegerArrayArgument(string $name): array |
|
| 131 | - { |
|
| 132 | - $argument = $this->getArgument($name); |
|
| 127 | + /** |
|
| 128 | + * @return int[] |
|
| 129 | + */ |
|
| 130 | + public function getIntegerArrayArgument(string $name): array |
|
| 131 | + { |
|
| 132 | + $argument = $this->getArgument($name); |
|
| 133 | 133 | |
| 134 | - ConsoleAssert::assertIsArray($argument); |
|
| 134 | + ConsoleAssert::assertIsArray($argument); |
|
| 135 | 135 | |
| 136 | - return array_map( |
|
| 137 | - static function ($element): int { |
|
| 138 | - ConsoleAssert::integer($element); |
|
| 136 | + return array_map( |
|
| 137 | + static function ($element): int { |
|
| 138 | + ConsoleAssert::integer($element); |
|
| 139 | 139 | |
| 140 | - return (int) $element; |
|
| 141 | - }, |
|
| 142 | - $argument, |
|
| 143 | - ); |
|
| 144 | - } |
|
| 140 | + return (int) $element; |
|
| 141 | + }, |
|
| 142 | + $argument, |
|
| 143 | + ); |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - public function getFloatArgument(string $name): float |
|
| 147 | - { |
|
| 148 | - $argument = $this->getArgument($name); |
|
| 146 | + public function getFloatArgument(string $name): float |
|
| 147 | + { |
|
| 148 | + $argument = $this->getArgument($name); |
|
| 149 | 149 | |
| 150 | - ConsoleAssert::assertIsNotArray($argument); |
|
| 151 | - ConsoleAssert::numeric($argument); |
|
| 150 | + ConsoleAssert::assertIsNotArray($argument); |
|
| 151 | + ConsoleAssert::numeric($argument); |
|
| 152 | 152 | |
| 153 | - return (float) $argument; |
|
| 154 | - } |
|
| 153 | + return (float) $argument; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function getNullableFloatArgument(string $name): ?float |
|
| 157 | - { |
|
| 158 | - if (null === $this->getArgument($name)) { |
|
| 159 | - return null; |
|
| 160 | - } |
|
| 156 | + public function getNullableFloatArgument(string $name): ?float |
|
| 157 | + { |
|
| 158 | + if (null === $this->getArgument($name)) { |
|
| 159 | + return null; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return $this->getFloatArgument($name); |
|
| 163 | - } |
|
| 162 | + return $this->getFloatArgument($name); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * @return float[] |
|
| 167 | - */ |
|
| 168 | - public function getFloatArrayArgument(string $name): array |
|
| 169 | - { |
|
| 170 | - $argument = $this->getArgument($name); |
|
| 165 | + /** |
|
| 166 | + * @return float[] |
|
| 167 | + */ |
|
| 168 | + public function getFloatArrayArgument(string $name): array |
|
| 169 | + { |
|
| 170 | + $argument = $this->getArgument($name); |
|
| 171 | 171 | |
| 172 | - ConsoleAssert::assertIsArray($argument); |
|
| 172 | + ConsoleAssert::assertIsArray($argument); |
|
| 173 | 173 | |
| 174 | - return array_map( |
|
| 175 | - static function ($element): float { |
|
| 176 | - ConsoleAssert::numeric($element); |
|
| 174 | + return array_map( |
|
| 175 | + static function ($element): float { |
|
| 176 | + ConsoleAssert::numeric($element); |
|
| 177 | 177 | |
| 178 | - return (float) $element; |
|
| 179 | - }, |
|
| 180 | - $argument, |
|
| 181 | - ); |
|
| 182 | - } |
|
| 178 | + return (float) $element; |
|
| 179 | + }, |
|
| 180 | + $argument, |
|
| 181 | + ); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - public function getBooleanOption(string $name): bool |
|
| 185 | - { |
|
| 186 | - $option = $this->getOption($name); |
|
| 187 | - |
|
| 188 | - ConsoleAssert::assertIsNotArray($option); |
|
| 184 | + public function getBooleanOption(string $name): bool |
|
| 185 | + { |
|
| 186 | + $option = $this->getOption($name); |
|
| 187 | + |
|
| 188 | + ConsoleAssert::assertIsNotArray($option); |
|
| 189 | 189 | |
| 190 | - return (bool) $option; |
|
| 191 | - } |
|
| 190 | + return (bool) $option; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - public function getNullableBooleanOption(string $name): ?bool |
|
| 194 | - { |
|
| 195 | - if (null === $this->getOption($name)) { |
|
| 196 | - return null; |
|
| 197 | - } |
|
| 193 | + public function getNullableBooleanOption(string $name): ?bool |
|
| 194 | + { |
|
| 195 | + if (null === $this->getOption($name)) { |
|
| 196 | + return null; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - return $this->getBooleanOption($name); |
|
| 200 | - } |
|
| 199 | + return $this->getBooleanOption($name); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - public function getStringOption(string $name): string |
|
| 203 | - { |
|
| 204 | - $option = $this->getOption($name); |
|
| 205 | - |
|
| 206 | - ConsoleAssert::assertIsNotArray($option); |
|
| 202 | + public function getStringOption(string $name): string |
|
| 203 | + { |
|
| 204 | + $option = $this->getOption($name); |
|
| 205 | + |
|
| 206 | + ConsoleAssert::assertIsNotArray($option); |
|
| 207 | 207 | |
| 208 | - return (string) $option; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - public function getNullableStringOption(string $name): ?string |
|
| 212 | - { |
|
| 213 | - if (null === $this->getOption($name)) { |
|
| 214 | - return null; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - return $this->getStringOption($name); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @return string[] |
|
| 222 | - */ |
|
| 223 | - public function getStringArrayOption(string $name): array |
|
| 224 | - { |
|
| 225 | - $option = $this->getOption($name); |
|
| 226 | - |
|
| 227 | - ConsoleAssert::assertIsArray($option); |
|
| 228 | - |
|
| 229 | - return $option; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - public function getIntegerOption(string $name): int |
|
| 233 | - { |
|
| 234 | - $option = $this->getOption($name); |
|
| 235 | - |
|
| 236 | - ConsoleAssert::assertIsNotArray($option); |
|
| 237 | - ConsoleAssert::integer($option); |
|
| 238 | - |
|
| 239 | - return (int) $option; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - public function getNullableIntegerOption(string $name): ?int |
|
| 243 | - { |
|
| 244 | - if (null === $this->getOption($name)) { |
|
| 245 | - return null; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - return $this->getIntegerOption($name); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * @return int[] |
|
| 253 | - */ |
|
| 254 | - public function getIntegerArrayOption(string $name): array |
|
| 255 | - { |
|
| 256 | - $option = $this->getOption($name); |
|
| 257 | - |
|
| 258 | - ConsoleAssert::assertIsArray($option); |
|
| 259 | - |
|
| 260 | - return array_map( |
|
| 261 | - static function ($element): int { |
|
| 262 | - ConsoleAssert::integer($element); |
|
| 263 | - |
|
| 264 | - return (int) $element; |
|
| 265 | - }, |
|
| 266 | - $option, |
|
| 267 | - ); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - public function getFloatOption(string $name): float |
|
| 271 | - { |
|
| 272 | - $option = $this->getOption($name); |
|
| 273 | - |
|
| 274 | - ConsoleAssert::assertIsNotArray($option); |
|
| 275 | - ConsoleAssert::numeric($option); |
|
| 276 | - |
|
| 277 | - return (float) $option; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - public function getNullableFloatOption(string $name): ?float |
|
| 281 | - { |
|
| 282 | - if (null === $this->getOption($name)) { |
|
| 283 | - return null; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - return $this->getFloatOption($name); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * @return float[] |
|
| 291 | - */ |
|
| 292 | - public function getFloatArrayOption(string $name): array |
|
| 293 | - { |
|
| 294 | - $option = $this->getOption($name); |
|
| 295 | - |
|
| 296 | - ConsoleAssert::assertIsArray($option); |
|
| 297 | - |
|
| 298 | - return array_map( |
|
| 299 | - static function ($element): float { |
|
| 300 | - ConsoleAssert::numeric($element); |
|
| 301 | - |
|
| 302 | - return (float) $element; |
|
| 303 | - }, |
|
| 304 | - $option, |
|
| 305 | - ); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - public function isInteractive(): bool |
|
| 309 | - { |
|
| 310 | - return $this->input->isInteractive(); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - public function getOutput(): OutputInterface |
|
| 314 | - { |
|
| 315 | - return $this->output; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * @return null|string|string[] |
|
| 320 | - */ |
|
| 321 | - private function getArgument(string $name) |
|
| 322 | - { |
|
| 323 | - $argument = $this->input->getArgument($name); |
|
| 324 | - |
|
| 325 | - ConsoleAssert::assertIsValidArgumentType($argument); |
|
| 208 | + return (string) $option; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + public function getNullableStringOption(string $name): ?string |
|
| 212 | + { |
|
| 213 | + if (null === $this->getOption($name)) { |
|
| 214 | + return null; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + return $this->getStringOption($name); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @return string[] |
|
| 222 | + */ |
|
| 223 | + public function getStringArrayOption(string $name): array |
|
| 224 | + { |
|
| 225 | + $option = $this->getOption($name); |
|
| 226 | + |
|
| 227 | + ConsoleAssert::assertIsArray($option); |
|
| 228 | + |
|
| 229 | + return $option; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + public function getIntegerOption(string $name): int |
|
| 233 | + { |
|
| 234 | + $option = $this->getOption($name); |
|
| 235 | + |
|
| 236 | + ConsoleAssert::assertIsNotArray($option); |
|
| 237 | + ConsoleAssert::integer($option); |
|
| 238 | + |
|
| 239 | + return (int) $option; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + public function getNullableIntegerOption(string $name): ?int |
|
| 243 | + { |
|
| 244 | + if (null === $this->getOption($name)) { |
|
| 245 | + return null; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + return $this->getIntegerOption($name); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * @return int[] |
|
| 253 | + */ |
|
| 254 | + public function getIntegerArrayOption(string $name): array |
|
| 255 | + { |
|
| 256 | + $option = $this->getOption($name); |
|
| 257 | + |
|
| 258 | + ConsoleAssert::assertIsArray($option); |
|
| 259 | + |
|
| 260 | + return array_map( |
|
| 261 | + static function ($element): int { |
|
| 262 | + ConsoleAssert::integer($element); |
|
| 263 | + |
|
| 264 | + return (int) $element; |
|
| 265 | + }, |
|
| 266 | + $option, |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + public function getFloatOption(string $name): float |
|
| 271 | + { |
|
| 272 | + $option = $this->getOption($name); |
|
| 273 | + |
|
| 274 | + ConsoleAssert::assertIsNotArray($option); |
|
| 275 | + ConsoleAssert::numeric($option); |
|
| 276 | + |
|
| 277 | + return (float) $option; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + public function getNullableFloatOption(string $name): ?float |
|
| 281 | + { |
|
| 282 | + if (null === $this->getOption($name)) { |
|
| 283 | + return null; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + return $this->getFloatOption($name); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * @return float[] |
|
| 291 | + */ |
|
| 292 | + public function getFloatArrayOption(string $name): array |
|
| 293 | + { |
|
| 294 | + $option = $this->getOption($name); |
|
| 295 | + |
|
| 296 | + ConsoleAssert::assertIsArray($option); |
|
| 297 | + |
|
| 298 | + return array_map( |
|
| 299 | + static function ($element): float { |
|
| 300 | + ConsoleAssert::numeric($element); |
|
| 301 | + |
|
| 302 | + return (float) $element; |
|
| 303 | + }, |
|
| 304 | + $option, |
|
| 305 | + ); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + public function isInteractive(): bool |
|
| 309 | + { |
|
| 310 | + return $this->input->isInteractive(); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + public function getOutput(): OutputInterface |
|
| 314 | + { |
|
| 315 | + return $this->output; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * @return null|string|string[] |
|
| 320 | + */ |
|
| 321 | + private function getArgument(string $name) |
|
| 322 | + { |
|
| 323 | + $argument = $this->input->getArgument($name); |
|
| 324 | + |
|
| 325 | + ConsoleAssert::assertIsValidArgumentType($argument); |
|
| 326 | 326 | |
| 327 | - return $argument; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * @return null|bool|string|string[] |
|
| 332 | - */ |
|
| 333 | - private function getOption(string $name) |
|
| 334 | - { |
|
| 335 | - $option = $this->input->getOption($name); |
|
| 336 | - |
|
| 337 | - ConsoleAssert::assertIsValidOptionType($option); |
|
| 338 | - |
|
| 339 | - return $option; |
|
| 340 | - } |
|
| 327 | + return $argument; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * @return null|bool|string|string[] |
|
| 332 | + */ |
|
| 333 | + private function getOption(string $name) |
|
| 334 | + { |
|
| 335 | + $option = $this->input->getOption($name); |
|
| 336 | + |
|
| 337 | + ConsoleAssert::assertIsValidOptionType($option); |
|
| 338 | + |
|
| 339 | + return $option; |
|
| 340 | + } |
|
| 341 | 341 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | ConsoleAssert::assertIsNotArray($argument); |
| 65 | 65 | |
| 66 | - return (bool) $argument; |
|
| 66 | + return (bool)$argument; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function getNullableBooleanArgument(string $name): ?bool |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | ConsoleAssert::assertIsNotArray($argument); |
| 83 | 83 | |
| 84 | - return (string) $argument; |
|
| 84 | + return (string)$argument; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function getNullableStringArgument(string $name): ?string |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ConsoleAssert::assertIsNotArray($argument); |
| 113 | 113 | ConsoleAssert::integer($argument); |
| 114 | 114 | |
| 115 | - return (int) $argument; |
|
| 115 | + return (int)$argument; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function getNullableIntegerArgument(string $name): ?int |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | ConsoleAssert::assertIsArray($argument); |
| 135 | 135 | |
| 136 | 136 | return array_map( |
| 137 | - static function ($element): int { |
|
| 137 | + static function($element): int { |
|
| 138 | 138 | ConsoleAssert::integer($element); |
| 139 | 139 | |
| 140 | - return (int) $element; |
|
| 140 | + return (int)$element; |
|
| 141 | 141 | }, |
| 142 | 142 | $argument, |
| 143 | 143 | ); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | ConsoleAssert::assertIsNotArray($argument); |
| 151 | 151 | ConsoleAssert::numeric($argument); |
| 152 | 152 | |
| 153 | - return (float) $argument; |
|
| 153 | + return (float)$argument; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public function getNullableFloatArgument(string $name): ?float |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | ConsoleAssert::assertIsArray($argument); |
| 173 | 173 | |
| 174 | 174 | return array_map( |
| 175 | - static function ($element): float { |
|
| 175 | + static function($element): float { |
|
| 176 | 176 | ConsoleAssert::numeric($element); |
| 177 | 177 | |
| 178 | - return (float) $element; |
|
| 178 | + return (float)$element; |
|
| 179 | 179 | }, |
| 180 | 180 | $argument, |
| 181 | 181 | ); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | ConsoleAssert::assertIsNotArray($option); |
| 189 | 189 | |
| 190 | - return (bool) $option; |
|
| 190 | + return (bool)$option; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | public function getNullableBooleanOption(string $name): ?bool |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | ConsoleAssert::assertIsNotArray($option); |
| 207 | 207 | |
| 208 | - return (string) $option; |
|
| 208 | + return (string)$option; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | public function getNullableStringOption(string $name): ?string |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | ConsoleAssert::assertIsNotArray($option); |
| 237 | 237 | ConsoleAssert::integer($option); |
| 238 | 238 | |
| 239 | - return (int) $option; |
|
| 239 | + return (int)$option; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | public function getNullableIntegerOption(string $name): ?int |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | ConsoleAssert::assertIsArray($option); |
| 259 | 259 | |
| 260 | 260 | return array_map( |
| 261 | - static function ($element): int { |
|
| 261 | + static function($element): int { |
|
| 262 | 262 | ConsoleAssert::integer($element); |
| 263 | 263 | |
| 264 | - return (int) $element; |
|
| 264 | + return (int)$element; |
|
| 265 | 265 | }, |
| 266 | 266 | $option, |
| 267 | 267 | ); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | ConsoleAssert::assertIsNotArray($option); |
| 275 | 275 | ConsoleAssert::numeric($option); |
| 276 | 276 | |
| 277 | - return (float) $option; |
|
| 277 | + return (float)$option; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | public function getNullableFloatOption(string $name): ?float |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | ConsoleAssert::assertIsArray($option); |
| 297 | 297 | |
| 298 | 298 | return array_map( |
| 299 | - static function ($element): float { |
|
| 299 | + static function($element): float { |
|
| 300 | 300 | ConsoleAssert::numeric($element); |
| 301 | 301 | |
| 302 | - return (float) $element; |
|
| 302 | + return (float)$element; |
|
| 303 | 303 | }, |
| 304 | 304 | $option, |
| 305 | 305 | ); |
@@ -31,8 +31,7 @@ |
||
| 31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
| 32 | 32 | use Symfony\Component\Console\Style\SymfonyStyle; |
| 33 | 33 | |
| 34 | -final class IO extends SymfonyStyle |
|
| 35 | -{ |
|
| 34 | +final class IO extends SymfonyStyle { |
|
| 36 | 35 | private InputInterface $input; |
| 37 | 36 | private OutputInterface $output; |
| 38 | 37 | |
@@ -20,26 +20,26 @@ |
||
| 20 | 20 | |
| 21 | 21 | final class QuestionHelper |
| 22 | 22 | { |
| 23 | - private SymfonyQuestionHelper $helper; |
|
| 23 | + private SymfonyQuestionHelper $helper; |
|
| 24 | 24 | |
| 25 | - public function __construct() |
|
| 26 | - { |
|
| 27 | - $this->helper = new SymfonyQuestionHelper(); |
|
| 28 | - } |
|
| 25 | + public function __construct() |
|
| 26 | + { |
|
| 27 | + $this->helper = new SymfonyQuestionHelper(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Asks a question to the user. |
|
| 32 | - * |
|
| 33 | - * @throws RuntimeException If there is no data to read in the input stream |
|
| 34 | - * |
|
| 35 | - * @return mixed The user answer |
|
| 36 | - */ |
|
| 37 | - public function ask(IO $io, Question $question) |
|
| 38 | - { |
|
| 39 | - return $this->helper->ask( |
|
| 40 | - $io->getInput(), |
|
| 41 | - $io->getOutput(), |
|
| 42 | - $question, |
|
| 43 | - ); |
|
| 44 | - } |
|
| 30 | + /** |
|
| 31 | + * Asks a question to the user. |
|
| 32 | + * |
|
| 33 | + * @throws RuntimeException If there is no data to read in the input stream |
|
| 34 | + * |
|
| 35 | + * @return mixed The user answer |
|
| 36 | + */ |
|
| 37 | + public function ask(IO $io, Question $question) |
|
| 38 | + { |
|
| 39 | + return $this->helper->ask( |
|
| 40 | + $io->getInput(), |
|
| 41 | + $io->getOutput(), |
|
| 42 | + $question, |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | use Symfony\Component\Console\Helper\QuestionHelper as SymfonyQuestionHelper; |
| 19 | 19 | use Symfony\Component\Console\Question\Question; |
| 20 | 20 | |
| 21 | -final class QuestionHelper |
|
| 22 | -{ |
|
| 21 | +final class QuestionHelper { |
|
| 23 | 22 | private SymfonyQuestionHelper $helper; |
| 24 | 23 | |
| 25 | 24 | public function __construct() |
@@ -34,98 +34,98 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | final class SymfonyApplication extends BaseSymfonyApplication |
| 36 | 36 | { |
| 37 | - private Application $application; |
|
| 38 | - |
|
| 39 | - public function __construct(Application $application) |
|
| 40 | - { |
|
| 41 | - $this->application = $application; |
|
| 42 | - |
|
| 43 | - parent::__construct( |
|
| 44 | - $application->getName(), |
|
| 45 | - $application->getVersion(), |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - $this->setDefaultCommand($application->getDefaultCommand()); |
|
| 49 | - $this->setAutoExit($application->isAutoExitEnabled()); |
|
| 50 | - $this->setCatchExceptions($application->areExceptionsCaught()); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function reset(): void |
|
| 54 | - { |
|
| 55 | - if ($this->application instanceof ResetInterface) { |
|
| 56 | - $this->application->reset(); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function setHelperSet(HelperSet $helperSet): void |
|
| 61 | - { |
|
| 62 | - throw new LogicException('Not supported'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function setDefinition(InputDefinition $definition): void |
|
| 66 | - { |
|
| 67 | - throw new LogicException('Not supported'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function getHelp(): string |
|
| 71 | - { |
|
| 72 | - return $this->application->getHelp(); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - public function getLongVersion(): string |
|
| 76 | - { |
|
| 77 | - return $this->application->getLongVersion(); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public function setCommandLoader(CommandLoaderInterface $commandLoader): void |
|
| 81 | - { |
|
| 82 | - throw new LogicException('Not supported'); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent): void |
|
| 86 | - { |
|
| 87 | - throw new LogicException('Not supported'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - public function setName(string $name): void |
|
| 91 | - { |
|
| 92 | - throw new LogicException('Not supported'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function setVersion(string $version): void |
|
| 96 | - { |
|
| 97 | - throw new LogicException('Not supported'); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - protected function configureIO(InputInterface $input, OutputInterface $output): void |
|
| 101 | - { |
|
| 102 | - parent::configureIO($input, $output); |
|
| 103 | - |
|
| 104 | - if ($this->application instanceof ConfigurableIO) { |
|
| 105 | - $this->application->configureIO( |
|
| 106 | - new IO($input, $output), |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - protected function getDefaultCommands(): array |
|
| 112 | - { |
|
| 113 | - return [ |
|
| 114 | - ...parent::getDefaultCommands(), |
|
| 115 | - ...$this->getSymfonyCommands(), |
|
| 116 | - ]; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return list<Command> |
|
| 121 | - */ |
|
| 122 | - private function getSymfonyCommands(): array |
|
| 123 | - { |
|
| 124 | - return array_values( |
|
| 125 | - array_map( |
|
| 126 | - static fn (FidryCommand $command) => new SymfonyCommand($command), |
|
| 127 | - $this->application->getCommands(), |
|
| 128 | - ), |
|
| 129 | - ); |
|
| 130 | - } |
|
| 37 | + private Application $application; |
|
| 38 | + |
|
| 39 | + public function __construct(Application $application) |
|
| 40 | + { |
|
| 41 | + $this->application = $application; |
|
| 42 | + |
|
| 43 | + parent::__construct( |
|
| 44 | + $application->getName(), |
|
| 45 | + $application->getVersion(), |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + $this->setDefaultCommand($application->getDefaultCommand()); |
|
| 49 | + $this->setAutoExit($application->isAutoExitEnabled()); |
|
| 50 | + $this->setCatchExceptions($application->areExceptionsCaught()); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function reset(): void |
|
| 54 | + { |
|
| 55 | + if ($this->application instanceof ResetInterface) { |
|
| 56 | + $this->application->reset(); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function setHelperSet(HelperSet $helperSet): void |
|
| 61 | + { |
|
| 62 | + throw new LogicException('Not supported'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function setDefinition(InputDefinition $definition): void |
|
| 66 | + { |
|
| 67 | + throw new LogicException('Not supported'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function getHelp(): string |
|
| 71 | + { |
|
| 72 | + return $this->application->getHelp(); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + public function getLongVersion(): string |
|
| 76 | + { |
|
| 77 | + return $this->application->getLongVersion(); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public function setCommandLoader(CommandLoaderInterface $commandLoader): void |
|
| 81 | + { |
|
| 82 | + throw new LogicException('Not supported'); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent): void |
|
| 86 | + { |
|
| 87 | + throw new LogicException('Not supported'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + public function setName(string $name): void |
|
| 91 | + { |
|
| 92 | + throw new LogicException('Not supported'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function setVersion(string $version): void |
|
| 96 | + { |
|
| 97 | + throw new LogicException('Not supported'); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + protected function configureIO(InputInterface $input, OutputInterface $output): void |
|
| 101 | + { |
|
| 102 | + parent::configureIO($input, $output); |
|
| 103 | + |
|
| 104 | + if ($this->application instanceof ConfigurableIO) { |
|
| 105 | + $this->application->configureIO( |
|
| 106 | + new IO($input, $output), |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + protected function getDefaultCommands(): array |
|
| 112 | + { |
|
| 113 | + return [ |
|
| 114 | + ...parent::getDefaultCommands(), |
|
| 115 | + ...$this->getSymfonyCommands(), |
|
| 116 | + ]; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return list<Command> |
|
| 121 | + */ |
|
| 122 | + private function getSymfonyCommands(): array |
|
| 123 | + { |
|
| 124 | + return array_values( |
|
| 125 | + array_map( |
|
| 126 | + static fn (FidryCommand $command) => new SymfonyCommand($command), |
|
| 127 | + $this->application->getCommands(), |
|
| 128 | + ), |
|
| 129 | + ); |
|
| 130 | + } |
|
| 131 | 131 | } |
@@ -32,8 +32,7 @@ |
||
| 32 | 32 | * Bridge to create a traditional Symfony application from the new Application |
| 33 | 33 | * API. |
| 34 | 34 | */ |
| 35 | -final class SymfonyApplication extends BaseSymfonyApplication |
|
| 36 | -{ |
|
| 35 | +final class SymfonyApplication extends BaseSymfonyApplication { |
|
| 37 | 36 | private Application $application; |
| 38 | 37 | |
| 39 | 38 | public function __construct(Application $application) |
@@ -17,54 +17,54 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface Application |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Name of the application. Typically shown when running the application |
|
| 22 | - * or displaying the current version. |
|
| 23 | - */ |
|
| 24 | - public function getName(): string; |
|
| 20 | + /** |
|
| 21 | + * Name of the application. Typically shown when running the application |
|
| 22 | + * or displaying the current version. |
|
| 23 | + */ |
|
| 24 | + public function getName(): string; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Version of the application. |
|
| 28 | - */ |
|
| 29 | - public function getVersion(): string; |
|
| 26 | + /** |
|
| 27 | + * Version of the application. |
|
| 28 | + */ |
|
| 29 | + public function getVersion(): string; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Usually a combination of the name and version, typically displayed at |
|
| 33 | - * the beginning when executing a command. |
|
| 34 | - */ |
|
| 35 | - public function getLongVersion(): string; |
|
| 31 | + /** |
|
| 32 | + * Usually a combination of the name and version, typically displayed at |
|
| 33 | + * the beginning when executing a command. |
|
| 34 | + */ |
|
| 35 | + public function getLongVersion(): string; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Message usually show when showing the description of a command. |
|
| 39 | - */ |
|
| 40 | - public function getHelp(): string; |
|
| 37 | + /** |
|
| 38 | + * Message usually show when showing the description of a command. |
|
| 39 | + */ |
|
| 40 | + public function getHelp(): string; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Exhaustive list of the custom commands. A few more commands such as |
|
| 44 | - * the HelpCommand or ListCommand are also included besides those. |
|
| 45 | - * |
|
| 46 | - * @return Command[] |
|
| 47 | - */ |
|
| 48 | - public function getCommands(): array; |
|
| 42 | + /** |
|
| 43 | + * Exhaustive list of the custom commands. A few more commands such as |
|
| 44 | + * the HelpCommand or ListCommand are also included besides those. |
|
| 45 | + * |
|
| 46 | + * @return Command[] |
|
| 47 | + */ |
|
| 48 | + public function getCommands(): array; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The default command executed when the application is being run without |
|
| 52 | - * any command specified. Typically the list command which will display all |
|
| 53 | - * the available commands. |
|
| 54 | - */ |
|
| 55 | - public function getDefaultCommand(): string; |
|
| 50 | + /** |
|
| 51 | + * The default command executed when the application is being run without |
|
| 52 | + * any command specified. Typically the list command which will display all |
|
| 53 | + * the available commands. |
|
| 54 | + */ |
|
| 55 | + public function getDefaultCommand(): string; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * When enabled the process will stop with the returned exit code. Otherwise |
|
| 59 | - * will simply return the exit code. |
|
| 60 | - */ |
|
| 61 | - public function isAutoExitEnabled(): bool; |
|
| 57 | + /** |
|
| 58 | + * When enabled the process will stop with the returned exit code. Otherwise |
|
| 59 | + * will simply return the exit code. |
|
| 60 | + */ |
|
| 61 | + public function isAutoExitEnabled(): bool; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Whether exceptions are caught when executing the application. If yes a CLI |
|
| 65 | - * renderer will render the exception to the output, otherwise the exception |
|
| 66 | - * will be left alone and how the exception is rendered is left to the callee |
|
| 67 | - * (e.g. the regular PHP exception printer). |
|
| 68 | - */ |
|
| 69 | - public function areExceptionsCaught(): bool; |
|
| 63 | + /** |
|
| 64 | + * Whether exceptions are caught when executing the application. If yes a CLI |
|
| 65 | + * renderer will render the exception to the output, otherwise the exception |
|
| 66 | + * will be left alone and how the exception is rendered is left to the callee |
|
| 67 | + * (e.g. the regular PHP exception printer). |
|
| 68 | + */ |
|
| 69 | + public function areExceptionsCaught(): bool; |
|
| 70 | 70 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | use Fidry\Console\Command\Command; |
| 17 | 17 | |
| 18 | -interface Application |
|
| 19 | -{ |
|
| 18 | +interface Application { |
|
| 20 | 19 | /** |
| 21 | 20 | * Name of the application. Typically shown when running the application |
| 22 | 21 | * or displaying the current version. |
@@ -23,36 +23,36 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | abstract class BaseApplication implements Application |
| 25 | 25 | { |
| 26 | - public function getLongVersion(): string |
|
| 27 | - { |
|
| 28 | - if ('UNKNOWN' !== $this->getName()) { |
|
| 29 | - if ('UNKNOWN' !== $this->getVersion()) { |
|
| 30 | - return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - return $this->getName(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - return 'Console Tool'; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public function getHelp(): string |
|
| 40 | - { |
|
| 41 | - return $this->getLongVersion(); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function getDefaultCommand(): string |
|
| 45 | - { |
|
| 46 | - return 'list'; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function isAutoExitEnabled(): bool |
|
| 50 | - { |
|
| 51 | - return true; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function areExceptionsCaught(): bool |
|
| 55 | - { |
|
| 56 | - return true; |
|
| 57 | - } |
|
| 26 | + public function getLongVersion(): string |
|
| 27 | + { |
|
| 28 | + if ('UNKNOWN' !== $this->getName()) { |
|
| 29 | + if ('UNKNOWN' !== $this->getVersion()) { |
|
| 30 | + return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + return $this->getName(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + return 'Console Tool'; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public function getHelp(): string |
|
| 40 | + { |
|
| 41 | + return $this->getLongVersion(); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function getDefaultCommand(): string |
|
| 45 | + { |
|
| 46 | + return 'list'; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function isAutoExitEnabled(): bool |
|
| 50 | + { |
|
| 51 | + return true; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function areExceptionsCaught(): bool |
|
| 55 | + { |
|
| 56 | + return true; |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -21,8 +21,7 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * @see \Symfony\Component\Console\Application |
| 23 | 23 | */ |
| 24 | -abstract class BaseApplication implements Application |
|
| 25 | -{ |
|
| 24 | +abstract class BaseApplication implements Application { |
|
| 26 | 25 | public function getLongVersion(): string |
| 27 | 26 | { |
| 28 | 27 | if ('UNKNOWN' !== $this->getName()) { |
@@ -17,9 +17,9 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface ConfigurableIO |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Configures the input and output instances based on the user arguments and |
|
| 22 | - * options. This is executed before running the application. |
|
| 23 | - */ |
|
| 24 | - public function configureIO(IO $io): void; |
|
| 20 | + /** |
|
| 21 | + * Configures the input and output instances based on the user arguments and |
|
| 22 | + * options. This is executed before running the application. |
|
| 23 | + */ |
|
| 24 | + public function configureIO(IO $io): void; |
|
| 25 | 25 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | |
| 16 | 16 | use Fidry\Console\IO; |
| 17 | 17 | |
| 18 | -interface ConfigurableIO |
|
| 19 | -{ |
|
| 18 | +interface ConfigurableIO { |
|
| 20 | 19 | /** |
| 21 | 20 | * Configures the input and output instances based on the user arguments and |
| 22 | 21 | * options. This is executed before running the application. |
@@ -21,46 +21,46 @@ |
||
| 21 | 21 | |
| 22 | 22 | final class ApplicationRunner |
| 23 | 23 | { |
| 24 | - private SymfonyApplication $application; |
|
| 24 | + private SymfonyApplication $application; |
|
| 25 | 25 | |
| 26 | - public function __construct(Application $application) |
|
| 27 | - { |
|
| 28 | - $this->application = new SymfonyApplication($application); |
|
| 29 | - } |
|
| 26 | + public function __construct(Application $application) |
|
| 27 | + { |
|
| 28 | + $this->application = new SymfonyApplication($application); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Executes the given application command. |
|
| 33 | - * |
|
| 34 | - * @return int 0 if everything went fine, or an exit code |
|
| 35 | - * |
|
| 36 | - * @see ExitCode |
|
| 37 | - */ |
|
| 38 | - public static function runApplication( |
|
| 39 | - Application $application, |
|
| 40 | - ?InputInterface $input, |
|
| 41 | - ?OutputInterface $output |
|
| 42 | - ): int { |
|
| 43 | - return (new self($application))->run( |
|
| 44 | - new IO( |
|
| 45 | - $input ?? new ArgvInput(), |
|
| 46 | - $output ?? new ConsoleOutput(), |
|
| 47 | - ), |
|
| 48 | - ); |
|
| 49 | - } |
|
| 31 | + /** |
|
| 32 | + * Executes the given application command. |
|
| 33 | + * |
|
| 34 | + * @return int 0 if everything went fine, or an exit code |
|
| 35 | + * |
|
| 36 | + * @see ExitCode |
|
| 37 | + */ |
|
| 38 | + public static function runApplication( |
|
| 39 | + Application $application, |
|
| 40 | + ?InputInterface $input, |
|
| 41 | + ?OutputInterface $output |
|
| 42 | + ): int { |
|
| 43 | + return (new self($application))->run( |
|
| 44 | + new IO( |
|
| 45 | + $input ?? new ArgvInput(), |
|
| 46 | + $output ?? new ConsoleOutput(), |
|
| 47 | + ), |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @see ApplicationRunner::runApplication() |
|
| 53 | - */ |
|
| 54 | - public function run(?IO $io = null): int |
|
| 55 | - { |
|
| 56 | - if (null === $io) { |
|
| 57 | - $input = null; |
|
| 58 | - $output = null; |
|
| 59 | - } else { |
|
| 60 | - $input = $io->getInput(); |
|
| 61 | - $output = $io->getOutput(); |
|
| 62 | - } |
|
| 51 | + /** |
|
| 52 | + * @see ApplicationRunner::runApplication() |
|
| 53 | + */ |
|
| 54 | + public function run(?IO $io = null): int |
|
| 55 | + { |
|
| 56 | + if (null === $io) { |
|
| 57 | + $input = null; |
|
| 58 | + $output = null; |
|
| 59 | + } else { |
|
| 60 | + $input = $io->getInput(); |
|
| 61 | + $output = $io->getOutput(); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $this->application->run($input, $output); |
|
| 65 | - } |
|
| 64 | + return $this->application->run($input, $output); |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -19,8 +19,7 @@ |
||
| 19 | 19 | use Symfony\Component\Console\Output\ConsoleOutput; |
| 20 | 20 | use Symfony\Component\Console\Output\OutputInterface; |
| 21 | 21 | |
| 22 | -final class ApplicationRunner |
|
| 23 | -{ |
|
| 22 | +final class ApplicationRunner { |
|
| 24 | 23 | private SymfonyApplication $application; |
| 25 | 24 | |
| 26 | 25 | public function __construct(Application $application) |
@@ -22,20 +22,20 @@ |
||
| 22 | 22 | |
| 23 | 23 | final class FidryConsoleBundle extends Bundle |
| 24 | 24 | { |
| 25 | - public function getContainerExtension(): Extension |
|
| 26 | - { |
|
| 27 | - return new FidryConsoleExtension(); |
|
| 28 | - } |
|
| 25 | + public function getContainerExtension(): Extension |
|
| 26 | + { |
|
| 27 | + return new FidryConsoleExtension(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function build(ContainerBuilder $container): void |
|
| 31 | - { |
|
| 32 | - parent::build($container); |
|
| 30 | + public function build(ContainerBuilder $container): void |
|
| 31 | + { |
|
| 32 | + parent::build($container); |
|
| 33 | 33 | |
| 34 | - $container->addCompilerPass( |
|
| 35 | - new AddConsoleCommandPass(), |
|
| 36 | - PassConfig::TYPE_BEFORE_REMOVING, |
|
| 37 | - // Priority must be higher than Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass in FrameworkBundle |
|
| 38 | - 10, |
|
| 39 | - ); |
|
| 40 | - } |
|
| 34 | + $container->addCompilerPass( |
|
| 35 | + new AddConsoleCommandPass(), |
|
| 36 | + PassConfig::TYPE_BEFORE_REMOVING, |
|
| 37 | + // Priority must be higher than Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass in FrameworkBundle |
|
| 38 | + 10, |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -20,8 +20,7 @@ |
||
| 20 | 20 | use Symfony\Component\HttpKernel\Bundle\Bundle; |
| 21 | 21 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
| 22 | 22 | |
| 23 | -final class FidryConsoleBundle extends Bundle |
|
| 24 | -{ |
|
| 23 | +final class FidryConsoleBundle extends Bundle { |
|
| 25 | 24 | public function getContainerExtension(): Extension |
| 26 | 25 | { |
| 27 | 26 | return new FidryConsoleExtension(); |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | |
| 16 | 16 | final class ExitCode |
| 17 | 17 | { |
| 18 | - // see https://tldp.org/LDP/abs/html/exitcodes.html |
|
| 19 | - public const SUCCESS = 0; |
|
| 20 | - public const FAILURE = 1; |
|
| 18 | + // see https://tldp.org/LDP/abs/html/exitcodes.html |
|
| 19 | + public const SUCCESS = 0; |
|
| 20 | + public const FAILURE = 1; |
|
| 21 | 21 | |
| 22 | - private function __construct() |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + private function __construct() |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | namespace Fidry\Console; |
| 15 | 15 | |
| 16 | -final class ExitCode |
|
| 17 | -{ |
|
| 16 | +final class ExitCode { |
|
| 18 | 17 | // see https://tldp.org/LDP/abs/html/exitcodes.html |
| 19 | 18 | public const SUCCESS = 0; |
| 20 | 19 | public const FAILURE = 1; |