@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param callable|null $callback A PHP callback to run whenever there is some |
33 | 33 | * output available on STDOUT or STDERR |
34 | 34 | */ |
35 | - public function run(OutputInterface $output, array|Process $cmd, ?string $error = null, ?callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process |
|
35 | + public function run(OutputInterface $output, array | Process $cmd, ?string $error = null, ?callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process |
|
36 | 36 | { |
37 | 37 | if (!class_exists(Process::class)) { |
38 | 38 | throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".'); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @see run() |
96 | 96 | */ |
97 | - public function mustRun(OutputInterface $output, array|Process $cmd, ?string $error = null, ?callable $callback = null): Process |
|
97 | + public function mustRun(OutputInterface $output, array | Process $cmd, ?string $error = null, ?callable $callback = null): Process |
|
98 | 98 | { |
99 | 99 | $process = $this->run($output, $cmd, $error, $callback); |
100 | 100 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | $formatter = $this->getHelperSet()->get('debug_formatter'); |
118 | 118 | |
119 | - return function ($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
119 | + return function($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
120 | 120 | $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); |
121 | 121 | |
122 | 122 | if (null !== $callback) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return $this |
89 | 89 | */ |
90 | - public function setStyle(TableStyle|string $name): static |
|
90 | + public function setStyle(TableStyle | string $name): static |
|
91 | 91 | { |
92 | 92 | $this->style = $this->resolveStyle($name); |
93 | 93 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return $this |
111 | 111 | */ |
112 | - public function setColumnStyle(int $columnIndex, TableStyle|string $name): static |
|
112 | + public function setColumnStyle(int $columnIndex, TableStyle | string $name): static |
|
113 | 113 | { |
114 | 114 | $this->columnStyles[$columnIndex] = $this->resolveStyle($name); |
115 | 115 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | /** |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - public function addRow(TableSeparator|array $row): static |
|
215 | + public function addRow(TableSeparator | array $row): static |
|
216 | 216 | { |
217 | 217 | if ($row instanceof TableSeparator) { |
218 | 218 | $this->rows[] = $row; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return $this |
232 | 232 | */ |
233 | - public function appendRow(TableSeparator|array $row): static |
|
233 | + public function appendRow(TableSeparator | array $row): static |
|
234 | 234 | { |
235 | 235 | if (!$this->output instanceof ConsoleSectionOutput) { |
236 | 236 | throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__)); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | /** |
250 | 250 | * @return $this |
251 | 251 | */ |
252 | - public function setRow(int|string $column, array $row): static |
|
252 | + public function setRow(int | string $column, array $row): static |
|
253 | 253 | { |
254 | 254 | $this->rows[$column] = $row; |
255 | 255 | |
@@ -496,14 +496,14 @@ discard block |
||
496 | 496 | if ($titleLength > $limit = $markupLength - 4) { |
497 | 497 | $titleLength = $limit; |
498 | 498 | $formatLength = Helper::width(Helper::removeDecoration($formatter, sprintf($titleFormat, ''))); |
499 | - $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...'); |
|
499 | + $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3) . '...'); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | $titleStart = intdiv($markupLength - $titleLength, 2); |
503 | 503 | if (false === mb_detect_encoding($markup, null, true)) { |
504 | 504 | $markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength); |
505 | 505 | } else { |
506 | - $markup = mb_substr($markup, 0, $titleStart).$formattedTitle.mb_substr($markup, $titleStart + $titleLength); |
|
506 | + $markup = mb_substr($markup, 0, $titleStart) . $formattedTitle . mb_substr($markup, $titleStart + $titleLength); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | $cellFormat = $cell->getStyle()->getCellFormat(); |
579 | 579 | if (!\is_string($cellFormat)) { |
580 | 580 | $tag = http_build_query($cell->getStyle()->getTagOptions(), '', ';'); |
581 | - $cellFormat = '<'.$tag.'>%s</>'; |
|
581 | + $cellFormat = '<' . $tag . '>%s</>'; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | if (str_contains($content, '</>')) { |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $eol = str_contains($cell ?? '', "\r\n") ? "\r\n" : "\n"; |
636 | 636 | $escaped = implode($eol, array_map(OutputFormatter::escapeTrailingBackslash(...), explode($eol, $cell))); |
637 | 637 | $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped; |
638 | - $lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell)); |
|
638 | + $lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>' . $eol, $cell)); |
|
639 | 639 | foreach ($lines as $lineKey => $line) { |
640 | 640 | if ($colspan > 1) { |
641 | 641 | $line = new TableCell($line, ['colspan' => $colspan]); |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | } |
653 | 653 | } |
654 | 654 | |
655 | - return new TableRows(function () use ($rows, $unmergedRows): \Traversable { |
|
655 | + return new TableRows(function() use ($rows, $unmergedRows): \Traversable { |
|
656 | 656 | foreach ($rows as $rowKey => $row) { |
657 | 657 | $rowGroup = [$row instanceof TableSeparator ? $row : $this->fillCells($row)]; |
658 | 658 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $lines = [$cell]; |
699 | 699 | if (str_contains($cell, "\n")) { |
700 | 700 | $eol = str_contains($cell, "\r\n") ? "\r\n" : "\n"; |
701 | - $lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell)); |
|
701 | + $lines = explode($eol, str_replace($eol, '<fg=default;bg=default>' . $eol . '</>', $cell)); |
|
702 | 702 | $nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines; |
703 | 703 | |
704 | 704 | $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | ]; |
914 | 914 | } |
915 | 915 | |
916 | - private function resolveStyle(TableStyle|string $name): TableStyle |
|
916 | + private function resolveStyle(TableStyle | string $name): TableStyle |
|
917 | 917 | { |
918 | 918 | if ($name instanceof TableStyle) { |
919 | 919 | return $name; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) { |
226 | 226 | $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'); |
227 | 227 | } else { |
228 | - $message = '<error>'.$error->getMessage().'</error>'; |
|
228 | + $message = '<error>' . $error->getMessage() . '</error>'; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $output->writeln($message); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | // as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false. |
271 | 271 | if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) { |
272 | - shell_exec('stty '.$sttyMode); |
|
272 | + shell_exec('stty ' . $sttyMode); |
|
273 | 273 | throw new MissingInputException('Aborted.'); |
274 | 274 | } elseif ("\177" === $c) { // Backspace Character |
275 | 275 | if (0 === $numMatches && 0 !== $i) { |
@@ -366,13 +366,13 @@ discard block |
||
366 | 366 | $cursor->savePosition(); |
367 | 367 | // Write highlighted text, complete the partially entered response |
368 | 368 | $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice))); |
369 | - $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $charactersEntered)).'</hl>'); |
|
369 | + $output->write('<hl>' . OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $charactersEntered)) . '</hl>'); |
|
370 | 370 | $cursor->restorePosition(); |
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
374 | 374 | // Reset stty so it behaves normally again |
375 | - shell_exec('stty '.$sttyMode); |
|
375 | + shell_exec('stty ' . $sttyMode); |
|
376 | 376 | |
377 | 377 | return $fullChoice; |
378 | 378 | } |
@@ -403,16 +403,16 @@ discard block |
||
403 | 403 | private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = true): string |
404 | 404 | { |
405 | 405 | if ('\\' === \DIRECTORY_SEPARATOR) { |
406 | - $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; |
|
406 | + $exe = __DIR__ . '/../Resources/bin/hiddeninput.exe'; |
|
407 | 407 | |
408 | 408 | // handle code running from a phar |
409 | 409 | if (str_starts_with(__FILE__, 'phar:')) { |
410 | - $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; |
|
410 | + $tmpExe = sys_get_temp_dir() . '/hiddeninput.exe'; |
|
411 | 411 | copy($exe, $tmpExe); |
412 | 412 | $exe = $tmpExe; |
413 | 413 | } |
414 | 414 | |
415 | - $sExec = shell_exec('"'.$exe.'"'); |
|
415 | + $sExec = shell_exec('"' . $exe . '"'); |
|
416 | 416 | $value = $trimmable ? rtrim($sExec) : $sExec; |
417 | 417 | $output->writeln(''); |
418 | 418 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | if (self::$stty && Terminal::hasSttyAvailable()) { |
441 | - shell_exec('stty '.$sttyMode); |
|
441 | + shell_exec('stty ' . $sttyMode); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | if (false === $value) { |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | * @param resource $inputStream The handler resource |
500 | 500 | * @param Question $question The question being asked |
501 | 501 | */ |
502 | - private function readInput($inputStream, Question $question): string|false |
|
502 | + private function readInput($inputStream, Question $question): string | false |
|
503 | 503 | { |
504 | 504 | if (!$question->isMultiline()) { |
505 | 505 | $cp = $this->setIOCodepage(); |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | /** |
541 | 541 | * Sets console I/O to the specified code page and converts the user input. |
542 | 542 | */ |
543 | - private function resetIOCodepage(int $cp, string|false $input): string|false |
|
543 | + private function resetIOCodepage(int $cp, string | false $input): string | false |
|
544 | 544 | { |
545 | 545 | if (0 !== $cp) { |
546 | 546 | sapi_windows_cp_set($cp); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return mb_substr($string, $from, $length, $encoding); |
86 | 86 | } |
87 | 87 | |
88 | - public static function formatTime(int|float $secs, int $precision = 1): string |
|
88 | + public static function formatTime(int | float $secs, int $precision = 1): string |
|
89 | 89 | { |
90 | 90 | $secs = (int) floor($secs); |
91 | 91 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | $unitCount = ($seconds / $format[0]); |
116 | - $times[$index] = 1 === $unitCount ? $format[1] : $unitCount.' '.$format[2]; |
|
116 | + $times[$index] = 1 === $unitCount ? $format[1] : $unitCount . ' ' . $format[2]; |
|
117 | 117 | |
118 | 118 | if ($secs === $seconds) { |
119 | 119 | break; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | private ?ClonerInterface $cloner = null, |
30 | 30 | ) { |
31 | 31 | if (class_exists(CliDumper::class)) { |
32 | - $this->handler = function ($var): string { |
|
32 | + $this->handler = function($var): string { |
|
33 | 33 | $dumper = $this->dumper ??= new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); |
34 | 34 | $dumper->setColors($this->output->isDecorated()); |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | null === $var => 'null', |
41 | 41 | true === $var => 'true', |
42 | 42 | false === $var => 'false', |
43 | - \is_string($var) => '"'.$var.'"', |
|
43 | + \is_string($var) => '"' . $var . '"', |
|
44 | 44 | default => rtrim(print_r($var, true)), |
45 | 45 | }; |
46 | 46 | } |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | private function setRealFormat(string $format): void |
489 | 489 | { |
490 | 490 | // try to use the _nomax variant if available |
491 | - if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { |
|
492 | - $this->format = self::getFormatDefinition($format.'_nomax'); |
|
491 | + if (!$this->max && null !== self::getFormatDefinition($format . '_nomax')) { |
|
492 | + $this->format = self::getFormatDefinition($format . '_nomax'); |
|
493 | 493 | } elseif (null !== self::getFormatDefinition($format)) { |
494 | 494 | $this->format = self::getFormatDefinition($format); |
495 | 495 | } else { |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | } |
534 | 534 | } |
535 | 535 | } elseif ($this->step > 0) { |
536 | - $message = \PHP_EOL.$message; |
|
536 | + $message = \PHP_EOL . $message; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | $this->previousMessage = $originalMessage; |
@@ -557,25 +557,25 @@ discard block |
||
557 | 557 | private static function initPlaceholderFormatters(): array |
558 | 558 | { |
559 | 559 | return [ |
560 | - 'bar' => function (self $bar, OutputInterface $output) { |
|
560 | + 'bar' => function(self $bar, OutputInterface $output) { |
|
561 | 561 | $completeBars = $bar->getBarOffset(); |
562 | 562 | $display = str_repeat($bar->getBarCharacter(), $completeBars); |
563 | 563 | if ($completeBars < $bar->getBarWidth()) { |
564 | 564 | $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter())); |
565 | - $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
565 | + $display .= $bar->getProgressCharacter() . str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | return $display; |
569 | 569 | }, |
570 | 570 | 'elapsed' => fn (self $bar) => Helper::formatTime(time() - $bar->getStartTime(), 2), |
571 | - 'remaining' => function (self $bar) { |
|
571 | + 'remaining' => function(self $bar) { |
|
572 | 572 | if (null === $bar->getMaxSteps()) { |
573 | 573 | throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); |
574 | 574 | } |
575 | 575 | |
576 | 576 | return Helper::formatTime($bar->getRemaining(), 2); |
577 | 577 | }, |
578 | - 'estimated' => function (self $bar) { |
|
578 | + 'estimated' => function(self $bar) { |
|
579 | 579 | if (null === $bar->getMaxSteps()) { |
580 | 580 | throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); |
581 | 581 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | \assert(null !== $this->format); |
612 | 612 | |
613 | 613 | $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i"; |
614 | - $callback = function ($matches) { |
|
614 | + $callback = function($matches) { |
|
615 | 615 | if ($formatter = $this->getPlaceholderFormatter($matches[1])) { |
616 | 616 | $text = $formatter($this, $this->output); |
617 | 617 | } elseif (isset($this->messages[$matches[1]])) { |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | } |
622 | 622 | |
623 | 623 | if (isset($matches[2])) { |
624 | - $text = sprintf('%'.$matches[2], $text); |
|
624 | + $text = sprintf('%' . $matches[2], $text); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | return $text; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * Formats a message as a block of text. |
33 | 33 | */ |
34 | - public function formatBlock(string|array $messages, string $style, bool $large = false): string |
|
34 | + public function formatBlock(string | array $messages, string $style, bool $large = false): string |
|
35 | 35 | { |
36 | 36 | if (!\is_array($messages)) { |
37 | 37 | $messages = [$messages]; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $messages = $large ? [str_repeat(' ', $len)] : []; |
49 | 49 | for ($i = 0; isset($lines[$i]); ++$i) { |
50 | - $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i])); |
|
50 | + $messages[] = $lines[$i] . str_repeat(' ', $len - self::width($lines[$i])); |
|
51 | 51 | } |
52 | 52 | if ($large) { |
53 | 53 | $messages[] = str_repeat(' ', $len); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return $message; |
72 | 72 | } |
73 | 73 | |
74 | - return self::substr($message, 0, $length).$suffix; |
|
74 | + return self::substr($message, 0, $length) . $suffix; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function getName(): string |
@@ -69,8 +69,8 @@ |
||
69 | 69 | $blocks = implode('|', $patternBlocks); |
70 | 70 | $rowPattern = "(?:$blocks)$limitPattern"; |
71 | 71 | $pattern = sprintf('#(?:((?>(%1$s)((?<=[^\S\r\n])[^\S\r\n]?|(?=\r?\n)|$|[^\S\r\n]))|(%1$s))(?:\r?\n)?|(?:\r?\n|$))#imux', $rowPattern); |
72 | - $output = rtrim(preg_replace($pattern, '\\1'.$break, $text), $break); |
|
72 | + $output = rtrim(preg_replace($pattern, '\\1' . $break, $text), $break); |
|
73 | 73 | |
74 | - return str_replace(' '.$break, $break, $output); |
|
74 | + return str_replace(' ' . $break, $break, $output); |
|
75 | 75 | } |
76 | 76 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | InputInterface $input, |
26 | 26 | OutputInterface $output, |
27 | 27 | private int $handlingSignal, |
28 | - private int|false $exitCode = 0, |
|
28 | + private int | false $exitCode = 0, |
|
29 | 29 | ) { |
30 | 30 | parent::__construct($command, $input, $output); |
31 | 31 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->exitCode = false; |
50 | 50 | } |
51 | 51 | |
52 | - public function getExitCode(): int|false |
|
52 | + public function getExitCode(): int | false |
|
53 | 53 | { |
54 | 54 | return $this->exitCode; |
55 | 55 | } |