@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | public function setFormat($format) |
305 | 305 | { |
306 | 306 | // try to use the _nomax variant if available |
307 | - if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) { |
|
308 | - $this->format = self::getFormatDefinition($format.'_nomax'); |
|
307 | + if (!$this->max && null !== self::getFormatDefinition($format . '_nomax')) { |
|
308 | + $this->format = self::getFormatDefinition($format . '_nomax'); |
|
309 | 309 | } elseif (null !== self::getFormatDefinition($format)) { |
310 | 310 | $this->format = self::getFormatDefinition($format); |
311 | 311 | } else { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $self = $this; |
437 | 437 | $output = $this->output; |
438 | 438 | $messages = $this->messages; |
439 | - $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) { |
|
439 | + $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function($matches) use ($self, $output, $messages) { |
|
440 | 440 | if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) { |
441 | 441 | $text = call_user_func($formatter, $self, $output); |
442 | 442 | } elseif (isset($messages[$matches[1]])) { |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | } |
447 | 447 | |
448 | 448 | if (isset($matches[2])) { |
449 | - $text = sprintf('%'.$matches[2], $text); |
|
449 | + $text = sprintf('%' . $matches[2], $text); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return $text; |
@@ -538,20 +538,20 @@ discard block |
||
538 | 538 | private static function initPlaceholderFormatters() |
539 | 539 | { |
540 | 540 | return array( |
541 | - 'bar' => function (ProgressBar $bar, OutputInterface $output) { |
|
541 | + 'bar' => function(ProgressBar $bar, OutputInterface $output) { |
|
542 | 542 | $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth()); |
543 | 543 | $display = str_repeat($bar->getBarCharacter(), $completeBars); |
544 | 544 | if ($completeBars < $bar->getBarWidth()) { |
545 | 545 | $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter()); |
546 | - $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
546 | + $display .= $bar->getProgressCharacter() . str_repeat($bar->getEmptyBarCharacter(), $emptyBars); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $display; |
550 | 550 | }, |
551 | - 'elapsed' => function (ProgressBar $bar) { |
|
551 | + 'elapsed' => function(ProgressBar $bar) { |
|
552 | 552 | return Helper::formatTime(time() - $bar->getStartTime()); |
553 | 553 | }, |
554 | - 'remaining' => function (ProgressBar $bar) { |
|
554 | + 'remaining' => function(ProgressBar $bar) { |
|
555 | 555 | if (!$bar->getMaxSteps()) { |
556 | 556 | throw new \LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); |
557 | 557 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | |
565 | 565 | return Helper::formatTime($remaining); |
566 | 566 | }, |
567 | - 'estimated' => function (ProgressBar $bar) { |
|
567 | + 'estimated' => function(ProgressBar $bar) { |
|
568 | 568 | if (!$bar->getMaxSteps()) { |
569 | 569 | throw new \LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); |
570 | 570 | } |
@@ -577,16 +577,16 @@ discard block |
||
577 | 577 | |
578 | 578 | return Helper::formatTime($estimated); |
579 | 579 | }, |
580 | - 'memory' => function (ProgressBar $bar) { |
|
580 | + 'memory' => function(ProgressBar $bar) { |
|
581 | 581 | return Helper::formatMemory(memory_get_usage(true)); |
582 | 582 | }, |
583 | - 'current' => function (ProgressBar $bar) { |
|
583 | + 'current' => function(ProgressBar $bar) { |
|
584 | 584 | return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); |
585 | 585 | }, |
586 | - 'max' => function (ProgressBar $bar) { |
|
586 | + 'max' => function(ProgressBar $bar) { |
|
587 | 587 | return $bar->getMaxSteps(); |
588 | 588 | }, |
589 | - 'percent' => function (ProgressBar $bar) { |
|
589 | + 'percent' => function(ProgressBar $bar) { |
|
590 | 590 | return floor($bar->getProgressPercent() * 100); |
591 | 591 | }, |
592 | 592 | ); |
@@ -416,7 +416,7 @@ |
||
416 | 416 | $text = $format[1]; |
417 | 417 | break; |
418 | 418 | } else { |
419 | - $text = ceil($secs / $format[2]).' '.$format[1]; |
|
419 | + $text = ceil($secs / $format[2]) . ' ' . $format[1]; |
|
420 | 420 | break; |
421 | 421 | } |
422 | 422 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | $that = $this; |
53 | 53 | |
54 | - $interviewer = function () use ($output, $question, $that) { |
|
54 | + $interviewer = function() use ($output, $question, $that) { |
|
55 | 55 | return $that->doAsk($output, $question); |
56 | 56 | }; |
57 | 57 | |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | // Save cursor position |
267 | 267 | $output->write("\0337"); |
268 | 268 | // Write highlighted text |
269 | - $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>'); |
|
269 | + $output->write('<hl>' . substr($matches[$ofs], $i) . '</hl>'); |
|
270 | 270 | // Restore cursor position |
271 | 271 | $output->write("\0338"); |
272 | 272 | } |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | private function getHiddenResponse(OutputInterface $output, $inputStream) |
291 | 291 | { |
292 | 292 | if ('\\' === DIRECTORY_SEPARATOR) { |
293 | - $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; |
|
293 | + $exe = __DIR__ . '/../Resources/bin/hiddeninput.exe'; |
|
294 | 294 | |
295 | 295 | // handle code running from a phar |
296 | 296 | if ('phar:' === substr(__FILE__, 0, 5)) { |
297 | - $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; |
|
297 | + $tmpExe = sys_get_temp_dir() . '/hiddeninput.exe'; |
|
298 | 298 | copy($exe, $tmpExe); |
299 | 299 | $exe = $tmpExe; |
300 | 300 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) { |
359 | 359 | $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'); |
360 | 360 | } else { |
361 | - $message = '<error>'.$error->getMessage().'</error>'; |
|
361 | + $message = '<error>' . $error->getMessage() . '</error>'; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | $output->writeln($message); |
@@ -258,7 +258,7 @@ |
||
258 | 258 | |
259 | 259 | $markup = $this->style->getCrossingChar(); |
260 | 260 | for ($column = 0; $column < $count; $column++) { |
261 | - $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->getColumnWidth($column)).$this->style->getCrossingChar(); |
|
261 | + $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->getColumnWidth($column)) . $this->style->getCrossingChar(); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup)); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | foreach ($this->tokens as $token) { |
288 | 288 | foreach ($values as $value) { |
289 | - if ($token === $value || 0 === strpos($token, $value.'=')) { |
|
289 | + if ($token === $value || 0 === strpos($token, $value . '=')) { |
|
290 | 290 | return true; |
291 | 291 | } |
292 | 292 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $token = array_shift($tokens); |
316 | 316 | |
317 | 317 | foreach ($values as $value) { |
318 | - if ($token === $value || 0 === strpos($token, $value.'=')) { |
|
318 | + if ($token === $value || 0 === strpos($token, $value . '=')) { |
|
319 | 319 | if (false !== $pos = strpos($token, '=')) { |
320 | 320 | return substr($token, $pos + 1); |
321 | 321 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | public function __toString() |
337 | 337 | { |
338 | 338 | $self = $this; |
339 | - $tokens = array_map(function ($token) use ($self) { |
|
339 | + $tokens = array_map(function($token) use ($self) { |
|
340 | 340 | if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { |
341 | - return $match[1].$self->escapeToken($match[2]); |
|
341 | + return $match[1] . $self->escapeToken($match[2]); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if ($token && $token[0] !== '-') { |
@@ -122,7 +122,7 @@ |
||
122 | 122 | $params = array(); |
123 | 123 | foreach ($this->parameters as $param => $val) { |
124 | 124 | if ($param && '-' === $param[0]) { |
125 | - $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : ''); |
|
125 | + $params[] = $param . ('' != $val ? '=' . $this->escapeToken($val) : ''); |
|
126 | 126 | } else { |
127 | 127 | $params[] = $this->escapeToken($val); |
128 | 128 | } |
@@ -398,11 +398,11 @@ |
||
398 | 398 | $elements = array(); |
399 | 399 | foreach ($this->getOptions() as $option) { |
400 | 400 | $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; |
401 | - $elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName()); |
|
401 | + $elements[] = sprintf('[' . ($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')) . ']', $shortcut, $option->getName()); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | foreach ($this->getArguments() as $argument) { |
405 | - $elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : '')); |
|
405 | + $elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName() . ($argument->isArray() ? '1' : '')); |
|
406 | 406 | |
407 | 407 | if ($argument->isArray()) { |
408 | 408 | $elements[] = sprintf('... [%sN]', $argument->getName()); |
@@ -64,11 +64,11 @@ |
||
64 | 64 | $cursor = 0; |
65 | 65 | while ($cursor < $length) { |
66 | 66 | if (preg_match('/\s+/A', $input, $match, null, $cursor)) { |
67 | - } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { |
|
68 | - $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2))); |
|
69 | - } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { |
|
67 | + } elseif (preg_match('/([^="\'\s]+?)(=?)(' . self::REGEX_QUOTED_STRING . '+)/A', $input, $match, null, $cursor)) { |
|
68 | + $tokens[] = $match[1] . $match[2] . stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2))); |
|
69 | + } elseif (preg_match('/' . self::REGEX_QUOTED_STRING . '/A', $input, $match, null, $cursor)) { |
|
70 | 70 | $tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2)); |
71 | - } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { |
|
71 | + } elseif (preg_match('/' . self::REGEX_STRING . '/A', $input, $match, null, $cursor)) { |
|
72 | 72 | $tokens[] = stripcslashes($match[1]); |
73 | 73 | } else { |
74 | 74 | // should never happen |
@@ -74,7 +74,7 @@ |
||
74 | 74 | */ |
75 | 75 | protected function doWrite($message, $newline) |
76 | 76 | { |
77 | - if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) { |
|
77 | + if (false === @fwrite($this->stream, $message . ($newline ? PHP_EOL : ''))) { |
|
78 | 78 | // should never happen |
79 | 79 | throw new \RuntimeException('Unable to write output.'); |
80 | 80 | } |