@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | private function setRealFormat(string $format) |
| 442 | 442 | { |
| 443 | 443 | // try to use the _nomax variant if available |
| 444 | - if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { |
|
| 445 | - $this->format = self::getFormatDefinition($format.'_nomax'); |
|
| 444 | + if (!$this->max && null !== self::getFormatDefinition($format . '_nomax')) { |
|
| 445 | + $this->format = self::getFormatDefinition($format . '_nomax'); |
|
| 446 | 446 | } elseif (null !== self::getFormatDefinition($format)) { |
| 447 | 447 | $this->format = self::getFormatDefinition($format); |
| 448 | 448 | } else { |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | } elseif ($this->step > 0) { |
| 489 | - $message = \PHP_EOL.$message; |
|
| 489 | + $message = \PHP_EOL . $message; |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | $this->previousMessage = $originalMessage; |
@@ -514,43 +514,43 @@ discard block |
||
| 514 | 514 | private static function initPlaceholderFormatters(): array |
| 515 | 515 | { |
| 516 | 516 | return [ |
| 517 | - 'bar' => function (self $bar, OutputInterface $output) { |
|
| 517 | + 'bar' => function(self $bar, OutputInterface $output) { |
|
| 518 | 518 | $completeBars = $bar->getBarOffset(); |
| 519 | 519 | $display = str_repeat($bar->getBarCharacter(), $completeBars); |
| 520 | 520 | if ($completeBars < $bar->getBarWidth()) { |
| 521 | 521 | $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter())); |
| 522 | - $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
| 522 | + $display .= $bar->getProgressCharacter() . str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | return $display; |
| 526 | 526 | }, |
| 527 | - 'elapsed' => function (self $bar) { |
|
| 527 | + 'elapsed' => function(self $bar) { |
|
| 528 | 528 | return Helper::formatTime(time() - $bar->getStartTime()); |
| 529 | 529 | }, |
| 530 | - 'remaining' => function (self $bar) { |
|
| 530 | + 'remaining' => function(self $bar) { |
|
| 531 | 531 | if (!$bar->getMaxSteps()) { |
| 532 | 532 | throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | return Helper::formatTime($bar->getRemaining()); |
| 536 | 536 | }, |
| 537 | - 'estimated' => function (self $bar) { |
|
| 537 | + 'estimated' => function(self $bar) { |
|
| 538 | 538 | if (!$bar->getMaxSteps()) { |
| 539 | 539 | throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | return Helper::formatTime($bar->getEstimated()); |
| 543 | 543 | }, |
| 544 | - 'memory' => function (self $bar) { |
|
| 544 | + 'memory' => function(self $bar) { |
|
| 545 | 545 | return Helper::formatMemory(memory_get_usage(true)); |
| 546 | 546 | }, |
| 547 | - 'current' => function (self $bar) { |
|
| 547 | + 'current' => function(self $bar) { |
|
| 548 | 548 | return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT); |
| 549 | 549 | }, |
| 550 | - 'max' => function (self $bar) { |
|
| 550 | + 'max' => function(self $bar) { |
|
| 551 | 551 | return $bar->getMaxSteps(); |
| 552 | 552 | }, |
| 553 | - 'percent' => function (self $bar) { |
|
| 553 | + 'percent' => function(self $bar) { |
|
| 554 | 554 | return floor($bar->getProgressPercent() * 100); |
| 555 | 555 | }, |
| 556 | 556 | ]; |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | private function buildLine(): string |
| 577 | 577 | { |
| 578 | 578 | $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i"; |
| 579 | - $callback = function ($matches) { |
|
| 579 | + $callback = function($matches) { |
|
| 580 | 580 | if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) { |
| 581 | 581 | $text = $formatter($this, $this->output); |
| 582 | 582 | } elseif (isset($this->messages[$matches[1]])) { |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | if (isset($matches[2])) { |
| 589 | - $text = sprintf('%'.$matches[2], $text); |
|
| 589 | + $text = sprintf('%' . $matches[2], $text); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | return $text; |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | $line = preg_replace_callback($regex, $callback, $this->format); |
| 595 | 595 | |
| 596 | 596 | // gets string length for each sub line with multiline format |
| 597 | - $linesLength = array_map(function ($subLine) { |
|
| 597 | + $linesLength = array_map(function($subLine) { |
|
| 598 | 598 | return Helper::width(Helper::removeDecoration($this->output->getFormatter(), rtrim($subLine, "\r"))); |
| 599 | 599 | }, explode("\n", $line)); |
| 600 | 600 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | return; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) { |
|
| 189 | + $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function($matches) { |
|
| 190 | 190 | if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) { |
| 191 | 191 | return $formatter($this); |
| 192 | 192 | } |
@@ -230,16 +230,16 @@ discard block |
||
| 230 | 230 | private static function initPlaceholderFormatters(): array |
| 231 | 231 | { |
| 232 | 232 | return [ |
| 233 | - 'indicator' => function (self $indicator) { |
|
| 233 | + 'indicator' => function(self $indicator) { |
|
| 234 | 234 | return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)]; |
| 235 | 235 | }, |
| 236 | - 'message' => function (self $indicator) { |
|
| 236 | + 'message' => function(self $indicator) { |
|
| 237 | 237 | return $indicator->message; |
| 238 | 238 | }, |
| 239 | - 'elapsed' => function (self $indicator) { |
|
| 239 | + 'elapsed' => function(self $indicator) { |
|
| 240 | 240 | return Helper::formatTime(time() - $indicator->startTime); |
| 241 | 241 | }, |
| 242 | - 'memory' => function () { |
|
| 242 | + 'memory' => function() { |
|
| 243 | 243 | return Helper::formatMemory(memory_get_usage(true)); |
| 244 | 244 | }, |
| 245 | 245 | ]; |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | |
| 121 | 121 | $formatter = $this->getHelperSet()->get('debug_formatter'); |
| 122 | 122 | |
| 123 | - return function ($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
| 123 | + return function($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
| 124 | 124 | $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); |
| 125 | 125 | |
| 126 | 126 | if (null !== $callback) { |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $messages = $large ? [str_repeat(' ', $len)] : []; |
| 55 | 55 | for ($i = 0; isset($lines[$i]); ++$i) { |
| 56 | - $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i])); |
|
| 56 | + $messages[] = $lines[$i] . str_repeat(' ', $len - self::width($lines[$i])); |
|
| 57 | 57 | } |
| 58 | 58 | if ($large) { |
| 59 | 59 | $messages[] = str_repeat(' ', $len); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return $message; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - return self::substr($message, 0, $length).$suffix; |
|
| 82 | + return self::substr($message, 0, $length) . $suffix; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -130,7 +130,7 @@ |
||
| 130 | 130 | return $format[1]; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - return floor($secs / $format[2]).' '.$format[1]; |
|
| 133 | + return floor($secs / $format[2]) . ' ' . $format[1]; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -485,14 +485,14 @@ discard block |
||
| 485 | 485 | if ($titleLength > $limit = $markupLength - 4) { |
| 486 | 486 | $titleLength = $limit; |
| 487 | 487 | $formatLength = Helper::width(Helper::removeDecoration($formatter, sprintf($titleFormat, ''))); |
| 488 | - $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...'); |
|
| 488 | + $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3) . '...'); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | $titleStart = intdiv($markupLength - $titleLength, 2); |
| 492 | 492 | if (false === mb_detect_encoding($markup, null, true)) { |
| 493 | 493 | $markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength); |
| 494 | 494 | } else { |
| 495 | - $markup = mb_substr($markup, 0, $titleStart).$formattedTitle.mb_substr($markup, $titleStart + $titleLength); |
|
| 495 | + $markup = mb_substr($markup, 0, $titleStart) . $formattedTitle . mb_substr($markup, $titleStart + $titleLength); |
|
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | $cellFormat = $cell->getStyle()->getCellFormat(); |
| 568 | 568 | if (!\is_string($cellFormat)) { |
| 569 | 569 | $tag = http_build_query($cell->getStyle()->getTagOptions(), '', ';'); |
| 570 | - $cellFormat = '<'.$tag.'>%s</>'; |
|
| 570 | + $cellFormat = '<' . $tag . '>%s</>'; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | if (strstr($content, '</>')) { |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | $eol = str_contains($cell ?? '', "\r\n") ? "\r\n" : "\n"; |
| 625 | 625 | $escaped = implode($eol, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode($eol, $cell))); |
| 626 | 626 | $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped; |
| 627 | - $lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell)); |
|
| 627 | + $lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>' . $eol, $cell)); |
|
| 628 | 628 | foreach ($lines as $lineKey => $line) { |
| 629 | 629 | if ($colspan > 1) { |
| 630 | 630 | $line = new TableCell($line, ['colspan' => $colspan]); |
@@ -641,7 +641,7 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - return new TableRows(function () use ($rows, $unmergedRows): \Traversable { |
|
| 644 | + return new TableRows(function() use ($rows, $unmergedRows): \Traversable { |
|
| 645 | 645 | foreach ($rows as $rowKey => $row) { |
| 646 | 646 | $rowGroup = [$row instanceof TableSeparator ? $row : $this->fillCells($row)]; |
| 647 | 647 | |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | $lines = [$cell]; |
| 688 | 688 | if (strstr($cell, "\n")) { |
| 689 | 689 | $eol = str_contains($cell, "\r\n") ? "\r\n" : "\n"; |
| 690 | - $lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell)); |
|
| 690 | + $lines = explode($eol, str_replace($eol, '<fg=default;bg=default>' . $eol . '</>', $cell)); |
|
| 691 | 691 | $nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines; |
| 692 | 692 | |
| 693 | 693 | $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]); |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | { |
| 68 | 68 | return array_filter( |
| 69 | 69 | $this->getOptions(), |
| 70 | - function ($key) { |
|
| 70 | + function($key) { |
|
| 71 | 71 | return \in_array($key, self::TAG_OPTIONS) && isset($this->options[$key]); |
| 72 | 72 | }, |
| 73 | 73 | \ARRAY_FILTER_USE_KEY |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | $this->cloner = $cloner; |
| 34 | 34 | |
| 35 | 35 | if (class_exists(CliDumper::class)) { |
| 36 | - $this->handler = function ($var): string { |
|
| 36 | + $this->handler = function($var): string { |
|
| 37 | 37 | $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); |
| 38 | 38 | $dumper->setColors($this->output->isDecorated()); |
| 39 | 39 | |
| 40 | 40 | return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true)); |
| 41 | 41 | }; |
| 42 | 42 | } else { |
| 43 | - $this->handler = function ($var): string { |
|
| 43 | + $this->handler = function($var): string { |
|
| 44 | 44 | switch (true) { |
| 45 | 45 | case null === $var: |
| 46 | 46 | return 'null'; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | case false === $var: |
| 50 | 50 | return 'false'; |
| 51 | 51 | case \is_string($var): |
| 52 | - return '"'.$var.'"'; |
|
| 52 | + return '"' . $var . '"'; |
|
| 53 | 53 | default: |
| 54 | 54 | return rtrim(print_r($var, true)); |
| 55 | 55 | } |
@@ -111,10 +111,10 @@ |
||
| 111 | 111 | $glue = ('-' === $param[1]) ? '=' : ' '; |
| 112 | 112 | if (\is_array($val)) { |
| 113 | 113 | foreach ($val as $v) { |
| 114 | - $params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : ''); |
|
| 114 | + $params[] = $param . ('' != $v ? $glue . $this->escapeToken($v) : ''); |
|
| 115 | 115 | } |
| 116 | 116 | } else { |
| 117 | - $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : ''); |
|
| 117 | + $params[] = $param . ('' != $val ? $glue . $this->escapeToken($val) : ''); |
|
| 118 | 118 | } |
| 119 | 119 | } else { |
| 120 | 120 | $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val); |