@@ -22,13 +22,11 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @author Fabien Potencier <[email protected]> |
24 | 24 | */ |
25 | -class ListCommand extends Command |
|
26 | -{ |
|
25 | +class ListCommand extends Command { |
|
27 | 26 | /** |
28 | 27 | * {@inheritdoc} |
29 | 28 | */ |
30 | - protected function configure() |
|
31 | - { |
|
29 | + protected function configure() { |
|
32 | 30 | $this |
33 | 31 | ->setName('list') |
34 | 32 | ->setDefinition([ |
@@ -62,8 +60,7 @@ discard block |
||
62 | 60 | /** |
63 | 61 | * {@inheritdoc} |
64 | 62 | */ |
65 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
66 | - { |
|
63 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
67 | 64 | $helper = new DescriptorHelper(); |
68 | 65 | $helper->describe($output, $this->getApplication(), [ |
69 | 66 | 'format' => $input->getOption('format'), |
@@ -20,13 +20,11 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @author Nicolas Grekas <[email protected]> |
22 | 22 | */ |
23 | -final class LazyCommand extends Command |
|
24 | -{ |
|
23 | +final class LazyCommand extends Command { |
|
25 | 24 | private $command; |
26 | 25 | private $isEnabled; |
27 | 26 | |
28 | - public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true) |
|
29 | - { |
|
27 | + public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true) { |
|
30 | 28 | $this->setName($name) |
31 | 29 | ->setAliases($aliases) |
32 | 30 | ->setHidden($isHidden) |
@@ -180,8 +178,7 @@ discard block |
||
180 | 178 | /** |
181 | 179 | * @return mixed |
182 | 180 | */ |
183 | - public function getHelper(string $name) |
|
184 | - { |
|
181 | + public function getHelper(string $name) { |
|
185 | 182 | return $this->getCommand()->getHelper($name); |
186 | 183 | } |
187 | 184 |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @author Geoffrey Brier <[email protected]> |
24 | 24 | */ |
25 | -trait LockableTrait |
|
26 | -{ |
|
25 | +trait LockableTrait { |
|
27 | 26 | /** @var Lock */ |
28 | 27 | private $lock; |
29 | 28 | |
@@ -59,8 +58,7 @@ discard block |
||
59 | 58 | /** |
60 | 59 | * Releases the command lock if there is one. |
61 | 60 | */ |
62 | - private function release() |
|
63 | - { |
|
61 | + private function release() { |
|
64 | 62 | if ($this->lock) { |
65 | 63 | $this->lock->release(); |
66 | 64 | $this->lock = null; |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @author Fabien Potencier <[email protected]> |
30 | 30 | */ |
31 | -class Command |
|
32 | -{ |
|
31 | +class Command { |
|
33 | 32 | // see https://tldp.org/LDP/abs/html/exitcodes.html |
34 | 33 | public const SUCCESS = 0; |
35 | 34 | public const FAILURE = 1; |
@@ -63,8 +62,7 @@ discard block |
||
63 | 62 | /** |
64 | 63 | * @return string|null The default command name or null when no default name is set |
65 | 64 | */ |
66 | - public static function getDefaultName() |
|
67 | - { |
|
65 | + public static function getDefaultName() { |
|
68 | 66 | $class = static::class; |
69 | 67 | |
70 | 68 | if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) { |
@@ -97,8 +95,7 @@ discard block |
||
97 | 95 | * |
98 | 96 | * @throws LogicException When the command name is empty |
99 | 97 | */ |
100 | - public function __construct(string $name = null) |
|
101 | - { |
|
98 | + public function __construct(string $name = null) { |
|
102 | 99 | $this->definition = new InputDefinition(); |
103 | 100 | |
104 | 101 | if (null === $name && null !== $name = static::getDefaultName()) { |
@@ -128,13 +125,11 @@ discard block |
||
128 | 125 | * |
129 | 126 | * This is mainly useful for the help command. |
130 | 127 | */ |
131 | - public function ignoreValidationErrors() |
|
132 | - { |
|
128 | + public function ignoreValidationErrors() { |
|
133 | 129 | $this->ignoreValidationErrors = true; |
134 | 130 | } |
135 | 131 | |
136 | - public function setApplication(Application $application = null) |
|
137 | - { |
|
132 | + public function setApplication(Application $application = null) { |
|
138 | 133 | $this->application = $application; |
139 | 134 | if ($application) { |
140 | 135 | $this->setHelperSet($application->getHelperSet()); |
@@ -145,8 +140,7 @@ discard block |
||
145 | 140 | $this->fullDefinition = null; |
146 | 141 | } |
147 | 142 | |
148 | - public function setHelperSet(HelperSet $helperSet) |
|
149 | - { |
|
143 | + public function setHelperSet(HelperSet $helperSet) { |
|
150 | 144 | $this->helperSet = $helperSet; |
151 | 145 | } |
152 | 146 | |
@@ -155,8 +149,7 @@ discard block |
||
155 | 149 | * |
156 | 150 | * @return HelperSet|null A HelperSet instance |
157 | 151 | */ |
158 | - public function getHelperSet() |
|
159 | - { |
|
152 | + public function getHelperSet() { |
|
160 | 153 | return $this->helperSet; |
161 | 154 | } |
162 | 155 | |
@@ -165,8 +158,7 @@ discard block |
||
165 | 158 | * |
166 | 159 | * @return Application|null An Application instance |
167 | 160 | */ |
168 | - public function getApplication() |
|
169 | - { |
|
161 | + public function getApplication() { |
|
170 | 162 | return $this->application; |
171 | 163 | } |
172 | 164 | |
@@ -178,16 +170,14 @@ discard block |
||
178 | 170 | * |
179 | 171 | * @return bool |
180 | 172 | */ |
181 | - public function isEnabled() |
|
182 | - { |
|
173 | + public function isEnabled() { |
|
183 | 174 | return true; |
184 | 175 | } |
185 | 176 | |
186 | 177 | /** |
187 | 178 | * Configures the current command. |
188 | 179 | */ |
189 | - protected function configure() |
|
190 | - { |
|
180 | + protected function configure() { |
|
191 | 181 | } |
192 | 182 | |
193 | 183 | /** |
@@ -204,8 +194,7 @@ discard block |
||
204 | 194 | * |
205 | 195 | * @see setCode() |
206 | 196 | */ |
207 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
208 | - { |
|
197 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
209 | 198 | throw new LogicException('You must override the execute() method in the concrete command class.'); |
210 | 199 | } |
211 | 200 | |
@@ -216,8 +205,7 @@ discard block |
||
216 | 205 | * This means that this is the only place where the command can |
217 | 206 | * interactively ask for values of missing required arguments. |
218 | 207 | */ |
219 | - protected function interact(InputInterface $input, OutputInterface $output) |
|
220 | - { |
|
208 | + protected function interact(InputInterface $input, OutputInterface $output) { |
|
221 | 209 | } |
222 | 210 | |
223 | 211 | /** |
@@ -230,8 +218,7 @@ discard block |
||
230 | 218 | * @see InputInterface::bind() |
231 | 219 | * @see InputInterface::validate() |
232 | 220 | */ |
233 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
234 | - { |
|
221 | + protected function initialize(InputInterface $input, OutputInterface $output) { |
|
235 | 222 | } |
236 | 223 | |
237 | 224 | /** |
@@ -248,8 +235,7 @@ discard block |
||
248 | 235 | * @see setCode() |
249 | 236 | * @see execute() |
250 | 237 | */ |
251 | - public function run(InputInterface $input, OutputInterface $output) |
|
252 | - { |
|
238 | + public function run(InputInterface $input, OutputInterface $output) { |
|
253 | 239 | // add the application arguments and options |
254 | 240 | $this->mergeApplicationDefinition(); |
255 | 241 | |
@@ -320,8 +306,7 @@ discard block |
||
320 | 306 | * |
321 | 307 | * @see execute() |
322 | 308 | */ |
323 | - public function setCode(callable $code) |
|
324 | - { |
|
309 | + public function setCode(callable $code) { |
|
325 | 310 | if ($code instanceof \Closure) { |
326 | 311 | $r = new \ReflectionFunction($code); |
327 | 312 | if (null === $r->getClosureThis()) { |
@@ -350,8 +335,7 @@ discard block |
||
350 | 335 | * |
351 | 336 | * @internal |
352 | 337 | */ |
353 | - public function mergeApplicationDefinition(bool $mergeArgs = true) |
|
354 | - { |
|
338 | + public function mergeApplicationDefinition(bool $mergeArgs = true) { |
|
355 | 339 | if (null === $this->application) { |
356 | 340 | return; |
357 | 341 | } |
@@ -375,8 +359,7 @@ discard block |
||
375 | 359 | * |
376 | 360 | * @return $this |
377 | 361 | */ |
378 | - public function setDefinition($definition) |
|
379 | - { |
|
362 | + public function setDefinition($definition) { |
|
380 | 363 | if ($definition instanceof InputDefinition) { |
381 | 364 | $this->definition = $definition; |
382 | 365 | } else { |
@@ -393,8 +376,7 @@ discard block |
||
393 | 376 | * |
394 | 377 | * @return InputDefinition An InputDefinition instance |
395 | 378 | */ |
396 | - public function getDefinition() |
|
397 | - { |
|
379 | + public function getDefinition() { |
|
398 | 380 | return $this->fullDefinition ?? $this->getNativeDefinition(); |
399 | 381 | } |
400 | 382 | |
@@ -408,8 +390,7 @@ discard block |
||
408 | 390 | * |
409 | 391 | * @return InputDefinition An InputDefinition instance |
410 | 392 | */ |
411 | - public function getNativeDefinition() |
|
412 | - { |
|
393 | + public function getNativeDefinition() { |
|
413 | 394 | if (null === $this->definition) { |
414 | 395 | throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class)); |
415 | 396 | } |
@@ -427,8 +408,7 @@ discard block |
||
427 | 408 | * |
428 | 409 | * @return $this |
429 | 410 | */ |
430 | - public function addArgument(string $name, int $mode = null, string $description = '', $default = null) |
|
431 | - { |
|
411 | + public function addArgument(string $name, int $mode = null, string $description = '', $default = null) { |
|
432 | 412 | $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); |
433 | 413 | if (null !== $this->fullDefinition) { |
434 | 414 | $this->fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default)); |
@@ -448,8 +428,7 @@ discard block |
||
448 | 428 | * |
449 | 429 | * @return $this |
450 | 430 | */ |
451 | - public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) |
|
452 | - { |
|
431 | + public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) { |
|
453 | 432 | $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); |
454 | 433 | if (null !== $this->fullDefinition) { |
455 | 434 | $this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); |
@@ -470,8 +449,7 @@ discard block |
||
470 | 449 | * |
471 | 450 | * @throws InvalidArgumentException When the name is invalid |
472 | 451 | */ |
473 | - public function setName(string $name) |
|
474 | - { |
|
452 | + public function setName(string $name) { |
|
475 | 453 | $this->validateName($name); |
476 | 454 | |
477 | 455 | $this->name = $name; |
@@ -487,8 +465,7 @@ discard block |
||
487 | 465 | * |
488 | 466 | * @return $this |
489 | 467 | */ |
490 | - public function setProcessTitle(string $title) |
|
491 | - { |
|
468 | + public function setProcessTitle(string $title) { |
|
492 | 469 | $this->processTitle = $title; |
493 | 470 | |
494 | 471 | return $this; |
@@ -499,8 +476,7 @@ discard block |
||
499 | 476 | * |
500 | 477 | * @return string|null |
501 | 478 | */ |
502 | - public function getName() |
|
503 | - { |
|
479 | + public function getName() { |
|
504 | 480 | return $this->name; |
505 | 481 | } |
506 | 482 | |
@@ -512,8 +488,7 @@ discard block |
||
512 | 488 | * |
513 | 489 | * @final since Symfony 5.1 |
514 | 490 | */ |
515 | - public function setHidden(bool $hidden /*= true*/) |
|
516 | - { |
|
491 | + public function setHidden(bool $hidden /*= true*/) { |
|
517 | 492 | $this->hidden = $hidden; |
518 | 493 | |
519 | 494 | return $this; |
@@ -522,8 +497,7 @@ discard block |
||
522 | 497 | /** |
523 | 498 | * @return bool whether the command should be publicly shown or not |
524 | 499 | */ |
525 | - public function isHidden() |
|
526 | - { |
|
500 | + public function isHidden() { |
|
527 | 501 | return $this->hidden; |
528 | 502 | } |
529 | 503 | |
@@ -532,8 +506,7 @@ discard block |
||
532 | 506 | * |
533 | 507 | * @return $this |
534 | 508 | */ |
535 | - public function setDescription(string $description) |
|
536 | - { |
|
509 | + public function setDescription(string $description) { |
|
537 | 510 | $this->description = $description; |
538 | 511 | |
539 | 512 | return $this; |
@@ -544,8 +517,7 @@ discard block |
||
544 | 517 | * |
545 | 518 | * @return string The description for the command |
546 | 519 | */ |
547 | - public function getDescription() |
|
548 | - { |
|
520 | + public function getDescription() { |
|
549 | 521 | return $this->description; |
550 | 522 | } |
551 | 523 | |
@@ -554,8 +526,7 @@ discard block |
||
554 | 526 | * |
555 | 527 | * @return $this |
556 | 528 | */ |
557 | - public function setHelp(string $help) |
|
558 | - { |
|
529 | + public function setHelp(string $help) { |
|
559 | 530 | $this->help = $help; |
560 | 531 | |
561 | 532 | return $this; |
@@ -566,8 +537,7 @@ discard block |
||
566 | 537 | * |
567 | 538 | * @return string The help for the command |
568 | 539 | */ |
569 | - public function getHelp() |
|
570 | - { |
|
540 | + public function getHelp() { |
|
571 | 541 | return $this->help; |
572 | 542 | } |
573 | 543 | |
@@ -577,8 +547,7 @@ discard block |
||
577 | 547 | * |
578 | 548 | * @return string The processed help for the command |
579 | 549 | */ |
580 | - public function getProcessedHelp() |
|
581 | - { |
|
550 | + public function getProcessedHelp() { |
|
582 | 551 | $name = $this->name; |
583 | 552 | $isSingleCommand = $this->application && $this->application->isSingleCommand(); |
584 | 553 | |
@@ -603,8 +572,7 @@ discard block |
||
603 | 572 | * |
604 | 573 | * @throws InvalidArgumentException When an alias is invalid |
605 | 574 | */ |
606 | - public function setAliases(iterable $aliases) |
|
607 | - { |
|
575 | + public function setAliases(iterable $aliases) { |
|
608 | 576 | $list = []; |
609 | 577 | |
610 | 578 | foreach ($aliases as $alias) { |
@@ -622,8 +590,7 @@ discard block |
||
622 | 590 | * |
623 | 591 | * @return array An array of aliases for the command |
624 | 592 | */ |
625 | - public function getAliases() |
|
626 | - { |
|
593 | + public function getAliases() { |
|
627 | 594 | return $this->aliases; |
628 | 595 | } |
629 | 596 | |
@@ -634,8 +601,7 @@ discard block |
||
634 | 601 | * |
635 | 602 | * @return string The synopsis |
636 | 603 | */ |
637 | - public function getSynopsis(bool $short = false) |
|
638 | - { |
|
604 | + public function getSynopsis(bool $short = false) { |
|
639 | 605 | $key = $short ? 'short' : 'long'; |
640 | 606 | |
641 | 607 | if (!isset($this->synopsis[$key])) { |
@@ -650,8 +616,7 @@ discard block |
||
650 | 616 | * |
651 | 617 | * @return $this |
652 | 618 | */ |
653 | - public function addUsage(string $usage) |
|
654 | - { |
|
619 | + public function addUsage(string $usage) { |
|
655 | 620 | if (!str_starts_with($usage, $this->name)) { |
656 | 621 | $usage = sprintf('%s %s', $this->name, $usage); |
657 | 622 | } |
@@ -666,8 +631,7 @@ discard block |
||
666 | 631 | * |
667 | 632 | * @return array |
668 | 633 | */ |
669 | - public function getUsages() |
|
670 | - { |
|
634 | + public function getUsages() { |
|
671 | 635 | return $this->usages; |
672 | 636 | } |
673 | 637 | |
@@ -679,8 +643,7 @@ discard block |
||
679 | 643 | * @throws LogicException if no HelperSet is defined |
680 | 644 | * @throws InvalidArgumentException if the helper is not defined |
681 | 645 | */ |
682 | - public function getHelper(string $name) |
|
683 | - { |
|
646 | + public function getHelper(string $name) { |
|
684 | 647 | if (null === $this->helperSet) { |
685 | 648 | throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name)); |
686 | 649 | } |
@@ -695,8 +658,7 @@ discard block |
||
695 | 658 | * |
696 | 659 | * @throws InvalidArgumentException When the name is invalid |
697 | 660 | */ |
698 | - private function validateName(string $name) |
|
699 | - { |
|
661 | + private function validateName(string $name) { |
|
700 | 662 | if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { |
701 | 663 | throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); |
702 | 664 | } |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @author Jean-François Simon <[email protected]> |
16 | 16 | */ |
17 | -class BufferedOutput extends Output |
|
18 | -{ |
|
17 | +class BufferedOutput extends Output { |
|
19 | 18 | private $buffer = ''; |
20 | 19 | |
21 | 20 | /** |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | * |
24 | 23 | * @return string |
25 | 24 | */ |
26 | - public function fetch() |
|
27 | - { |
|
25 | + public function fetch() { |
|
28 | 26 | $content = $this->buffer; |
29 | 27 | $this->buffer = ''; |
30 | 28 | |
@@ -34,8 +32,7 @@ discard block |
||
34 | 32 | /** |
35 | 33 | * {@inheritdoc} |
36 | 34 | */ |
37 | - protected function doWrite(string $message, bool $newline) |
|
38 | - { |
|
35 | + protected function doWrite(string $message, bool $newline) { |
|
39 | 36 | $this->buffer .= $message; |
40 | 37 | |
41 | 38 | if ($newline) { |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @author Fabien Potencier <[email protected]> |
29 | 29 | */ |
30 | -abstract class Output implements OutputInterface |
|
31 | -{ |
|
30 | +abstract class Output implements OutputInterface { |
|
32 | 31 | private $verbosity; |
33 | 32 | private $formatter; |
34 | 33 | |
@@ -37,8 +36,7 @@ discard block |
||
37 | 36 | * @param bool $decorated Whether to decorate messages |
38 | 37 | * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) |
39 | 38 | */ |
40 | - public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) |
|
41 | - { |
|
39 | + public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) { |
|
42 | 40 | $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; |
43 | 41 | $this->formatter = $formatter ?? new OutputFormatter(); |
44 | 42 | $this->formatter->setDecorated($decorated); |
@@ -47,96 +45,84 @@ discard block |
||
47 | 45 | /** |
48 | 46 | * {@inheritdoc} |
49 | 47 | */ |
50 | - public function setFormatter(OutputFormatterInterface $formatter) |
|
51 | - { |
|
48 | + public function setFormatter(OutputFormatterInterface $formatter) { |
|
52 | 49 | $this->formatter = $formatter; |
53 | 50 | } |
54 | 51 | |
55 | 52 | /** |
56 | 53 | * {@inheritdoc} |
57 | 54 | */ |
58 | - public function getFormatter() |
|
59 | - { |
|
55 | + public function getFormatter() { |
|
60 | 56 | return $this->formatter; |
61 | 57 | } |
62 | 58 | |
63 | 59 | /** |
64 | 60 | * {@inheritdoc} |
65 | 61 | */ |
66 | - public function setDecorated(bool $decorated) |
|
67 | - { |
|
62 | + public function setDecorated(bool $decorated) { |
|
68 | 63 | $this->formatter->setDecorated($decorated); |
69 | 64 | } |
70 | 65 | |
71 | 66 | /** |
72 | 67 | * {@inheritdoc} |
73 | 68 | */ |
74 | - public function isDecorated() |
|
75 | - { |
|
69 | + public function isDecorated() { |
|
76 | 70 | return $this->formatter->isDecorated(); |
77 | 71 | } |
78 | 72 | |
79 | 73 | /** |
80 | 74 | * {@inheritdoc} |
81 | 75 | */ |
82 | - public function setVerbosity(int $level) |
|
83 | - { |
|
76 | + public function setVerbosity(int $level) { |
|
84 | 77 | $this->verbosity = $level; |
85 | 78 | } |
86 | 79 | |
87 | 80 | /** |
88 | 81 | * {@inheritdoc} |
89 | 82 | */ |
90 | - public function getVerbosity() |
|
91 | - { |
|
83 | + public function getVerbosity() { |
|
92 | 84 | return $this->verbosity; |
93 | 85 | } |
94 | 86 | |
95 | 87 | /** |
96 | 88 | * {@inheritdoc} |
97 | 89 | */ |
98 | - public function isQuiet() |
|
99 | - { |
|
90 | + public function isQuiet() { |
|
100 | 91 | return self::VERBOSITY_QUIET === $this->verbosity; |
101 | 92 | } |
102 | 93 | |
103 | 94 | /** |
104 | 95 | * {@inheritdoc} |
105 | 96 | */ |
106 | - public function isVerbose() |
|
107 | - { |
|
97 | + public function isVerbose() { |
|
108 | 98 | return self::VERBOSITY_VERBOSE <= $this->verbosity; |
109 | 99 | } |
110 | 100 | |
111 | 101 | /** |
112 | 102 | * {@inheritdoc} |
113 | 103 | */ |
114 | - public function isVeryVerbose() |
|
115 | - { |
|
104 | + public function isVeryVerbose() { |
|
116 | 105 | return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity; |
117 | 106 | } |
118 | 107 | |
119 | 108 | /** |
120 | 109 | * {@inheritdoc} |
121 | 110 | */ |
122 | - public function isDebug() |
|
123 | - { |
|
111 | + public function isDebug() { |
|
124 | 112 | return self::VERBOSITY_DEBUG <= $this->verbosity; |
125 | 113 | } |
126 | 114 | |
127 | 115 | /** |
128 | 116 | * {@inheritdoc} |
129 | 117 | */ |
130 | - public function writeln($messages, int $options = self::OUTPUT_NORMAL) |
|
131 | - { |
|
118 | + public function writeln($messages, int $options = self::OUTPUT_NORMAL) { |
|
132 | 119 | $this->write($messages, true, $options); |
133 | 120 | } |
134 | 121 | |
135 | 122 | /** |
136 | 123 | * {@inheritdoc} |
137 | 124 | */ |
138 | - public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL) |
|
139 | - { |
|
125 | + public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL) { |
|
140 | 126 | if (!is_iterable($messages)) { |
141 | 127 | $messages = [$messages]; |
142 | 128 | } |
@@ -17,8 +17,7 @@ |
||
17 | 17 | * |
18 | 18 | * @author Dariusz Górecki <[email protected]> |
19 | 19 | */ |
20 | -interface ConsoleOutputInterface extends OutputInterface |
|
21 | -{ |
|
20 | +interface ConsoleOutputInterface extends OutputInterface { |
|
22 | 21 | /** |
23 | 22 | * Gets the OutputInterface for errors. |
24 | 23 | * |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @author Fabien Potencier <[email protected]> |
29 | 29 | */ |
30 | -class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface |
|
31 | -{ |
|
30 | +class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface { |
|
32 | 31 | private $stderr; |
33 | 32 | private $consoleSectionOutputs = []; |
34 | 33 | |
@@ -37,8 +36,7 @@ discard block |
||
37 | 36 | * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) |
38 | 37 | * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) |
39 | 38 | */ |
40 | - public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) |
|
41 | - { |
|
39 | + public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) { |
|
42 | 40 | parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); |
43 | 41 | |
44 | 42 | if (null === $formatter) { |
@@ -67,8 +65,7 @@ discard block |
||
67 | 65 | /** |
68 | 66 | * {@inheritdoc} |
69 | 67 | */ |
70 | - public function setDecorated(bool $decorated) |
|
71 | - { |
|
68 | + public function setDecorated(bool $decorated) { |
|
72 | 69 | parent::setDecorated($decorated); |
73 | 70 | $this->stderr->setDecorated($decorated); |
74 | 71 | } |
@@ -76,8 +73,7 @@ discard block |
||
76 | 73 | /** |
77 | 74 | * {@inheritdoc} |
78 | 75 | */ |
79 | - public function setFormatter(OutputFormatterInterface $formatter) |
|
80 | - { |
|
76 | + public function setFormatter(OutputFormatterInterface $formatter) { |
|
81 | 77 | parent::setFormatter($formatter); |
82 | 78 | $this->stderr->setFormatter($formatter); |
83 | 79 | } |
@@ -85,8 +81,7 @@ discard block |
||
85 | 81 | /** |
86 | 82 | * {@inheritdoc} |
87 | 83 | */ |
88 | - public function setVerbosity(int $level) |
|
89 | - { |
|
84 | + public function setVerbosity(int $level) { |
|
90 | 85 | parent::setVerbosity($level); |
91 | 86 | $this->stderr->setVerbosity($level); |
92 | 87 | } |
@@ -94,16 +89,14 @@ discard block |
||
94 | 89 | /** |
95 | 90 | * {@inheritdoc} |
96 | 91 | */ |
97 | - public function getErrorOutput() |
|
98 | - { |
|
92 | + public function getErrorOutput() { |
|
99 | 93 | return $this->stderr; |
100 | 94 | } |
101 | 95 | |
102 | 96 | /** |
103 | 97 | * {@inheritdoc} |
104 | 98 | */ |
105 | - public function setErrorOutput(OutputInterface $error) |
|
106 | - { |
|
99 | + public function setErrorOutput(OutputInterface $error) { |
|
107 | 100 | $this->stderr = $error; |
108 | 101 | } |
109 | 102 | |
@@ -113,8 +106,7 @@ discard block |
||
113 | 106 | * |
114 | 107 | * @return bool |
115 | 108 | */ |
116 | - protected function hasStdoutSupport() |
|
117 | - { |
|
109 | + protected function hasStdoutSupport() { |
|
118 | 110 | return false === $this->isRunningOS400(); |
119 | 111 | } |
120 | 112 | |
@@ -124,8 +116,7 @@ discard block |
||
124 | 116 | * |
125 | 117 | * @return bool |
126 | 118 | */ |
127 | - protected function hasStderrSupport() |
|
128 | - { |
|
119 | + protected function hasStderrSupport() { |
|
129 | 120 | return false === $this->isRunningOS400(); |
130 | 121 | } |
131 | 122 | |
@@ -147,8 +138,7 @@ discard block |
||
147 | 138 | /** |
148 | 139 | * @return resource |
149 | 140 | */ |
150 | - private function openOutputStream() |
|
151 | - { |
|
141 | + private function openOutputStream() { |
|
152 | 142 | if (!$this->hasStdoutSupport()) { |
153 | 143 | return fopen('php://output', 'w'); |
154 | 144 | } |
@@ -159,8 +149,7 @@ discard block |
||
159 | 149 | /** |
160 | 150 | * @return resource |
161 | 151 | */ |
162 | - private function openErrorStream() |
|
163 | - { |
|
152 | + private function openErrorStream() { |
|
164 | 153 | return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w'); |
165 | 154 | } |
166 | 155 | } |
@@ -18,8 +18,7 @@ |
||
18 | 18 | * |
19 | 19 | * @author Fabien Potencier <[email protected]> |
20 | 20 | */ |
21 | -interface OutputInterface |
|
22 | -{ |
|
21 | +interface OutputInterface { |
|
23 | 22 | public const VERBOSITY_QUIET = 16; |
24 | 23 | public const VERBOSITY_NORMAL = 32; |
25 | 24 | public const VERBOSITY_VERBOSE = 64; |