@@ -195,7 +195,7 @@ |
||
195 | 195 | * |
196 | 196 | * @param string $string |
197 | 197 | * |
198 | - * @return OutputFormatterStyle|bool false if string is not format string |
|
198 | + * @return OutputFormatterStyleInterface|null false if string is not format string |
|
199 | 199 | */ |
200 | 200 | private function createStyleFromString($string) |
201 | 201 | { |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * |
58 | 58 | * @param string|null $foreground The style foreground color name |
59 | 59 | * @param string|null $background The style background color name |
60 | - * @param array $options The style options |
|
60 | + * @param string[] $options The style options |
|
61 | 61 | * |
62 | 62 | * @api |
63 | 63 | */ |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * Asks the user to select a value. |
33 | 33 | * |
34 | 34 | * @param OutputInterface $output An Output instance |
35 | - * @param string|array $question The question to ask |
|
36 | - * @param array $choices List of choices to pick from |
|
35 | + * @param string $question The question to ask |
|
36 | + * @param string[] $choices List of choices to pick from |
|
37 | 37 | * @param bool|string $default The default answer if the user enters nothing |
38 | 38 | * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) |
39 | 39 | * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked |
40 | 40 | * @param bool $multiselect Select more than one value separated by comma |
41 | 41 | * |
42 | - * @return int|string|array The selected value or values (the key of the choices array) |
|
42 | + * @return string The selected value or values (the key of the choices array) |
|
43 | 43 | * |
44 | 44 | * @throws \InvalidArgumentException |
45 | 45 | */ |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * The question will be asked until the user answers by nothing, yes, or no. |
231 | 231 | * |
232 | 232 | * @param OutputInterface $output An Output instance |
233 | - * @param string|array $question The question to ask |
|
233 | + * @param string $question The question to ask |
|
234 | 234 | * @param bool $default The default answer if the user enters nothing |
235 | 235 | * |
236 | 236 | * @return bool true if the user has confirmed, false otherwise |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | * otherwise. |
328 | 328 | * |
329 | 329 | * @param OutputInterface $output An Output instance |
330 | - * @param string|array $question The question to ask |
|
330 | + * @param string $question The question to ask |
|
331 | 331 | * @param callable $validator A PHP callback |
332 | 332 | * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite) |
333 | 333 | * @param string $default The default answer if none is given by the user |
334 | 334 | * @param array $autocomplete List of values to autocomplete |
335 | 335 | * |
336 | - * @return mixed |
|
336 | + * @return string |
|
337 | 337 | * |
338 | 338 | * @throws \Exception When any of the validators return an error |
339 | 339 | */ |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * Returns the helper's input stream. |
394 | 394 | * |
395 | - * @return string |
|
395 | + * @return resource |
|
396 | 396 | */ |
397 | 397 | public function getInputStream() |
398 | 398 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | $output->writeln($messages); |
56 | 56 | |
57 | - $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) { |
|
57 | + $result = $this->askAndValidate($output, '> ', function($picked) use ($choices, $errorMessage, $multiselect) { |
|
58 | 58 | // Collapse all spaces. |
59 | 59 | $selectedChoices = str_replace(' ', '', $picked); |
60 | 60 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | // Save cursor position |
212 | 212 | $output->write("\0337"); |
213 | 213 | // Write highlighted text |
214 | - $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>'); |
|
214 | + $output->write('<hl>' . substr($matches[$ofs], $i) . '</hl>'); |
|
215 | 215 | // Restore cursor position |
216 | 216 | $output->write("\0338"); |
217 | 217 | } |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | public function askHiddenResponse(OutputInterface $output, $question, $fallback = true) |
264 | 264 | { |
265 | 265 | if ('\\' === DIRECTORY_SEPARATOR) { |
266 | - $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; |
|
266 | + $exe = __DIR__ . '/../Resources/bin/hiddeninput.exe'; |
|
267 | 267 | |
268 | 268 | // handle code running from a phar |
269 | 269 | if ('phar:' === substr(__FILE__, 0, 5)) { |
270 | - $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; |
|
270 | + $tmpExe = sys_get_temp_dir() . '/hiddeninput.exe'; |
|
271 | 271 | copy($exe, $tmpExe); |
272 | 272 | $exe = $tmpExe; |
273 | 273 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | { |
342 | 342 | $that = $this; |
343 | 343 | |
344 | - $interviewer = function () use ($output, $question, $default, $autocomplete, $that) { |
|
344 | + $interviewer = function() use ($output, $question, $default, $autocomplete, $that) { |
|
345 | 345 | return $that->ask($output, $question, $default, $autocomplete); |
346 | 346 | }; |
347 | 347 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | { |
371 | 371 | $that = $this; |
372 | 372 | |
373 | - $interviewer = function () use ($output, $question, $fallback, $that) { |
|
373 | + $interviewer = function() use ($output, $question, $fallback, $that) { |
|
374 | 374 | return $that->askHiddenResponse($output, $question, $fallback); |
375 | 375 | }; |
376 | 376 |
@@ -105,7 +105,7 @@ |
||
105 | 105 | * @param Process $process The Process |
106 | 106 | * @param callable|null $callback A PHP callable |
107 | 107 | * |
108 | - * @return callable |
|
108 | + * @return \Closure |
|
109 | 109 | */ |
110 | 110 | public function wrapCallback(OutputInterface $output, Process $process, $callback = null) |
111 | 111 | { |
@@ -113,7 +113,7 @@ |
||
113 | 113 | |
114 | 114 | $that = $this; |
115 | 115 | |
116 | - return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) { |
|
116 | + return function($type, $buffer) use ($output, $process, $callback, $formatter, $that) { |
|
117 | 117 | $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type)); |
118 | 118 | |
119 | 119 | if (null !== $callback) { |
@@ -138,6 +138,9 @@ discard block |
||
138 | 138 | return isset(self::$formats[$name]) ? self::$formats[$name] : null; |
139 | 139 | } |
140 | 140 | |
141 | + /** |
|
142 | + * @param string $message |
|
143 | + */ |
|
141 | 144 | public function setMessage($message, $name = 'message') |
142 | 145 | { |
143 | 146 | $this->messages[$name] = $message; |
@@ -473,6 +476,7 @@ discard block |
||
473 | 476 | * Sets the progress bar maximal steps. |
474 | 477 | * |
475 | 478 | * @param int The progress bar max steps |
479 | + * @param integer $max |
|
476 | 480 | */ |
477 | 481 | private function setMaxSteps($max) |
478 | 482 | { |
@@ -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 | ); |
@@ -49,6 +49,9 @@ |
||
49 | 49 | require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; |
50 | 50 | } |
51 | 51 | |
52 | + /** |
|
53 | + * @param string $text |
|
54 | + */ |
|
52 | 55 | protected function normalizeLineBreaks($text) |
53 | 56 | { |
54 | 57 | return str_replace(PHP_EOL, "\n", $text); |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); |
709 | 709 | $application->setAutoExit(false); |
710 | 710 | $application->expects($this->once()) |
711 | - ->method('doRun') |
|
712 | - ->will($this->throwException($exception)); |
|
711 | + ->method('doRun') |
|
712 | + ->will($this->throwException($exception)); |
|
713 | 713 | |
714 | 714 | $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); |
715 | 715 | |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); |
724 | 724 | $application->setAutoExit(false); |
725 | 725 | $application->expects($this->once()) |
726 | - ->method('doRun') |
|
727 | - ->will($this->throwException($exception)); |
|
726 | + ->method('doRun') |
|
727 | + ->will($this->throwException($exception)); |
|
728 | 728 | |
729 | 729 | $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); |
730 | 730 |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | |
37 | 37 | public static function setUpBeforeClass() |
38 | 38 | { |
39 | - self::$fixturesPath = realpath(__DIR__.'/Fixtures/'); |
|
40 | - require_once self::$fixturesPath.'/FooCommand.php'; |
|
41 | - require_once self::$fixturesPath.'/Foo1Command.php'; |
|
42 | - require_once self::$fixturesPath.'/Foo2Command.php'; |
|
43 | - require_once self::$fixturesPath.'/Foo3Command.php'; |
|
44 | - require_once self::$fixturesPath.'/Foo4Command.php'; |
|
45 | - require_once self::$fixturesPath.'/Foo5Command.php'; |
|
46 | - require_once self::$fixturesPath.'/FoobarCommand.php'; |
|
47 | - require_once self::$fixturesPath.'/BarBucCommand.php'; |
|
48 | - require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; |
|
49 | - require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; |
|
39 | + self::$fixturesPath = realpath(__DIR__ . '/Fixtures/'); |
|
40 | + require_once self::$fixturesPath . '/FooCommand.php'; |
|
41 | + require_once self::$fixturesPath . '/Foo1Command.php'; |
|
42 | + require_once self::$fixturesPath . '/Foo2Command.php'; |
|
43 | + require_once self::$fixturesPath . '/Foo3Command.php'; |
|
44 | + require_once self::$fixturesPath . '/Foo4Command.php'; |
|
45 | + require_once self::$fixturesPath . '/Foo5Command.php'; |
|
46 | + require_once self::$fixturesPath . '/FoobarCommand.php'; |
|
47 | + require_once self::$fixturesPath . '/BarBucCommand.php'; |
|
48 | + require_once self::$fixturesPath . '/FooSubnamespaced1Command.php'; |
|
49 | + require_once self::$fixturesPath . '/FooSubnamespaced2Command.php'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | protected function normalizeLineBreaks($text) |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public function testHelp() |
98 | 98 | { |
99 | 99 | $application = new Application(); |
100 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->getHelp() returns a help message'); |
|
100 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->getHelp() returns a help message'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function testAll() |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | |
479 | 479 | $application->setCatchExceptions(true); |
480 | 480 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
481 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); |
|
481 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); |
|
482 | 482 | |
483 | 483 | $application->setCatchExceptions(false); |
484 | 484 | try { |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | $application = new Application(); |
501 | 501 | $application->add(new \FooCommand()); |
502 | 502 | $this->ensureStaticCommandHelp($application); |
503 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application'); |
|
504 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application'); |
|
503 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application'); |
|
504 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application'); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | $application = new Application(); |
515 | 515 | $application->add(new \FooCommand()); |
516 | 516 | $this->ensureStaticCommandHelp($application); |
517 | - $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application'); |
|
518 | - $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application'); |
|
517 | + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application'); |
|
518 | + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath . '/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | public function testRenderException() |
@@ -528,21 +528,21 @@ discard block |
||
528 | 528 | $tester = new ApplicationTester($application); |
529 | 529 | |
530 | 530 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
531 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exception'); |
|
531 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exception'); |
|
532 | 532 | |
533 | 533 | $tester->run(array('command' => 'foo'), array('decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); |
534 | 534 | $this->assertContains('Exception trace', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); |
535 | 535 | |
536 | 536 | $tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false)); |
537 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); |
|
537 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); |
|
538 | 538 | |
539 | 539 | $application->add(new \Foo3Command()); |
540 | 540 | $tester = new ApplicationTester($application); |
541 | 541 | $tester->run(array('command' => 'foo3:bar'), array('decorated' => false)); |
542 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
542 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
543 | 543 | |
544 | 544 | $tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); |
545 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
545 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
546 | 546 | |
547 | 547 | $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); |
548 | 548 | $application->setAutoExit(false); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | $tester = new ApplicationTester($application); |
553 | 553 | |
554 | 554 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
555 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
555 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | public function testRenderExceptionWithDoubleWidthCharacters() |
@@ -562,28 +562,28 @@ discard block |
||
562 | 562 | $application->expects($this->any()) |
563 | 563 | ->method('getTerminalWidth') |
564 | 564 | ->will($this->returnValue(120)); |
565 | - $application->register('foo')->setCode(function () { |
|
565 | + $application->register('foo')->setCode(function() { |
|
566 | 566 | throw new \Exception('エラーメッセージ'); |
567 | 567 | }); |
568 | 568 | $tester = new ApplicationTester($application); |
569 | 569 | |
570 | 570 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
571 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
571 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception_doublewidth1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
572 | 572 | |
573 | 573 | $tester->run(array('command' => 'foo'), array('decorated' => true)); |
574 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
574 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); |
|
575 | 575 | |
576 | 576 | $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); |
577 | 577 | $application->setAutoExit(false); |
578 | 578 | $application->expects($this->any()) |
579 | 579 | ->method('getTerminalWidth') |
580 | 580 | ->will($this->returnValue(32)); |
581 | - $application->register('foo')->setCode(function () { |
|
581 | + $application->register('foo')->setCode(function() { |
|
582 | 582 | throw new \Exception('コマンドの実行中にエラーが発生しました。'); |
583 | 583 | }); |
584 | 584 | $tester = new ApplicationTester($application); |
585 | 585 | $tester->run(array('command' => 'foo'), array('decorated' => false)); |
586 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
586 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | public function testRun() |
@@ -609,19 +609,19 @@ discard block |
||
609 | 609 | $tester = new ApplicationTester($application); |
610 | 610 | |
611 | 611 | $tester->run(array(), array('decorated' => false)); |
612 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); |
|
612 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); |
|
613 | 613 | |
614 | 614 | $tester->run(array('--help' => true), array('decorated' => false)); |
615 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); |
|
615 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); |
|
616 | 616 | |
617 | 617 | $tester->run(array('-h' => true), array('decorated' => false)); |
618 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); |
|
618 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); |
|
619 | 619 | |
620 | 620 | $tester->run(array('command' => 'list', '--help' => true), array('decorated' => false)); |
621 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); |
|
621 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); |
|
622 | 622 | |
623 | 623 | $tester->run(array('command' => 'list', '-h' => true), array('decorated' => false)); |
624 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); |
|
624 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); |
|
625 | 625 | |
626 | 626 | $tester->run(array('--ansi' => true)); |
627 | 627 | $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed'); |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed'); |
631 | 631 | |
632 | 632 | $tester->run(array('--version' => true), array('decorated' => false)); |
633 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); |
|
633 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); |
|
634 | 634 | |
635 | 635 | $tester->run(array('-V' => true), array('decorated' => false)); |
636 | - $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); |
|
636 | + $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); |
|
637 | 637 | |
638 | 638 | $tester->run(array('command' => 'list', '--quiet' => true)); |
639 | 639 | $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | $tester = new ApplicationTester($application); |
673 | 673 | |
674 | 674 | $tester->run(array('command' => 'foo:bar', '--no-interaction' => true), array('decorated' => false)); |
675 | - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); |
|
675 | + $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); |
|
676 | 676 | |
677 | 677 | $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false)); |
678 | - $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); |
|
678 | + $this->assertSame('called' . PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | $application |
744 | 744 | ->register('foo') |
745 | 745 | ->setDefinition(array($def)) |
746 | - ->setCode(function (InputInterface $input, OutputInterface $output) {}) |
|
746 | + ->setCode(function(InputInterface $input, OutputInterface $output) {}) |
|
747 | 747 | ; |
748 | 748 | |
749 | 749 | $input = new ArrayInput(array('command' => 'foo')); |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | $application->setAutoExit(false); |
879 | 879 | $application->setDispatcher($this->getDispatcher()); |
880 | 880 | |
881 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
881 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
882 | 882 | $output->write('foo.'); |
883 | 883 | }); |
884 | 884 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $application->setAutoExit(false); |
899 | 899 | $application->setCatchExceptions(false); |
900 | 900 | |
901 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
901 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
902 | 902 | throw new \RuntimeException('foo'); |
903 | 903 | }); |
904 | 904 | |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | $application->setDispatcher($this->getDispatcher()); |
913 | 913 | $application->setAutoExit(false); |
914 | 914 | |
915 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
915 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
916 | 916 | $output->write('foo.'); |
917 | 917 | |
918 | 918 | throw new \RuntimeException('foo'); |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | $application->setDispatcher($this->getDispatcher(true)); |
930 | 930 | $application->setAutoExit(false); |
931 | 931 | |
932 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
932 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
933 | 933 | $output->write('foo.'); |
934 | 934 | }); |
935 | 935 | |
@@ -957,21 +957,21 @@ discard block |
||
957 | 957 | protected function getDispatcher($skipCommand = false) |
958 | 958 | { |
959 | 959 | $dispatcher = new EventDispatcher(); |
960 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { |
|
960 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use ($skipCommand) { |
|
961 | 961 | $event->getOutput()->write('before.'); |
962 | 962 | |
963 | 963 | if ($skipCommand) { |
964 | 964 | $event->disableCommand(); |
965 | 965 | } |
966 | 966 | }); |
967 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { |
|
967 | + $dispatcher->addListener('console.terminate', function(ConsoleTerminateEvent $event) use ($skipCommand) { |
|
968 | 968 | $event->getOutput()->write('after.'); |
969 | 969 | |
970 | 970 | if (!$skipCommand) { |
971 | 971 | $event->setExitCode(113); |
972 | 972 | } |
973 | 973 | }); |
974 | - $dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) { |
|
974 | + $dispatcher->addListener('console.exception', function(ConsoleExceptionEvent $event) { |
|
975 | 975 | $event->getOutput()->writeln('caught.'); |
976 | 976 | |
977 | 977 | $event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException())); |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | |
992 | 992 | $tester = new ApplicationTester($application); |
993 | 993 | $tester->run(array()); |
994 | - $this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
994 | + $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
995 | 995 | |
996 | 996 | $application = new CustomDefaultCommandApplication(); |
997 | 997 | $application->setAutoExit(false); |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | $tester = new ApplicationTester($application); |
1000 | 1000 | $tester->run(array()); |
1001 | 1001 | |
1002 | - $this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
1002 | + $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command'); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | public function testCanCheckIfTerminalIsInteractive() |
@@ -177,6 +177,9 @@ |
||
177 | 177 | $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet')); |
178 | 178 | } |
179 | 179 | |
180 | + /** |
|
181 | + * @param string $input |
|
182 | + */ |
|
180 | 183 | protected function getInputStream($input) |
181 | 184 | { |
182 | 185 | $stream = fopen('php://memory', 'r+', false); |
@@ -173,7 +173,7 @@ |
||
173 | 173 | $dialog->setHelperSet($helperSet); |
174 | 174 | |
175 | 175 | $error = 'This is not a color!'; |
176 | - $validator = function ($color) use ($error) { |
|
176 | + $validator = function($color) use ($error) { |
|
177 | 177 | if (!in_array($color, array('white', 'black'))) { |
178 | 178 | throw new \InvalidArgumentException($error); |
179 | 179 | } |
@@ -589,6 +589,9 @@ |
||
589 | 589 | return new StreamOutput(fopen('php://memory', 'r+', false), $verbosity, $decorated); |
590 | 590 | } |
591 | 591 | |
592 | + /** |
|
593 | + * @param string $expected |
|
594 | + */ |
|
592 | 595 | protected function generateOutput($expected) |
593 | 596 | { |
594 | 597 | $count = substr_count($expected, "\n"); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | rewind($output->getStream()); |
28 | 28 | $this->assertEquals( |
29 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
30 | - $this->generateOutput(' 1 [->--------------------------]'). |
|
29 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
30 | + $this->generateOutput(' 1 [->--------------------------]') . |
|
31 | 31 | $this->generateOutput(' 0 [>---------------------------]'), |
32 | 32 | stream_get_contents($output->getStream()) |
33 | 33 | ); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | rewind($output->getStream()); |
43 | 43 | $this->assertEquals( |
44 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
44 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
45 | 45 | $this->generateOutput(' 1 [->--------------------------]'), |
46 | 46 | stream_get_contents($output->getStream()) |
47 | 47 | ); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | rewind($output->getStream()); |
57 | 57 | $this->assertEquals( |
58 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
58 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
59 | 59 | $this->generateOutput(' 5 [----->----------------------]'), |
60 | 60 | stream_get_contents($output->getStream()) |
61 | 61 | ); |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | |
71 | 71 | rewind($output->getStream()); |
72 | 72 | $this->assertEquals( |
73 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
74 | - $this->generateOutput(' 3 [--->------------------------]'). |
|
73 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
74 | + $this->generateOutput(' 3 [--->------------------------]') . |
|
75 | 75 | $this->generateOutput(' 5 [----->----------------------]'), |
76 | 76 | stream_get_contents($output->getStream()) |
77 | 77 | ); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | rewind($output->getStream()); |
88 | 88 | $this->assertEquals( |
89 | - $this->generateOutput(' 9/10 [=========================>--] 90%'). |
|
90 | - $this->generateOutput(' 10/10 [============================] 100%'). |
|
89 | + $this->generateOutput(' 9/10 [=========================>--] 90%') . |
|
90 | + $this->generateOutput(' 10/10 [============================] 100%') . |
|
91 | 91 | $this->generateOutput(' 11/11 [============================] 100%'), |
92 | 92 | stream_get_contents($output->getStream()) |
93 | 93 | ); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | rewind($output->getStream()); |
108 | 108 | $this->assertEquals( |
109 | - $this->generateOutput(' 0/10 [/ ] 0%'). |
|
109 | + $this->generateOutput(' 0/10 [/ ] 0%') . |
|
110 | 110 | $this->generateOutput(' 1/10 [_/ ] 10%'), |
111 | 111 | stream_get_contents($output->getStream()) |
112 | 112 | ); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | |
159 | 159 | rewind($output->getStream()); |
160 | 160 | $this->assertEquals( |
161 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
162 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
163 | - $this->generateOutput(' 1/50 [>---------------------------] 2%'). |
|
161 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
162 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
163 | + $this->generateOutput(' 1/50 [>---------------------------] 2%') . |
|
164 | 164 | $this->generateOutput(' 2/50 [=>--------------------------] 4%'), |
165 | 165 | stream_get_contents($output->getStream()) |
166 | 166 | ); |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | |
181 | 181 | rewind($output->getStream()); |
182 | 182 | $this->assertEquals( |
183 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
184 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
185 | - $this->generateOutput(' 1/50 [>---------------------------] 2%'). |
|
183 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
184 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
185 | + $this->generateOutput(' 1/50 [>---------------------------] 2%') . |
|
186 | 186 | $this->generateOutput(' 2/50 [=>--------------------------] '), |
187 | 187 | stream_get_contents($output->getStream()) |
188 | 188 | ); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | rewind($output->getStream()); |
199 | 199 | $this->assertEquals( |
200 | - $this->generateOutput(' 0/50 [>---------------------------]'). |
|
200 | + $this->generateOutput(' 0/50 [>---------------------------]') . |
|
201 | 201 | $this->generateOutput(' 1/50 [>---------------------------]'), |
202 | 202 | stream_get_contents($output->getStream()) |
203 | 203 | ); |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | |
215 | 215 | rewind($output->getStream()); |
216 | 216 | $this->assertEquals( |
217 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
218 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
219 | - $this->generateOutput(' 1/50 [>---------------------------] 2%'). |
|
220 | - $this->generateOutput(' 15/50 [========>-------------------] 30%'). |
|
217 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
218 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
219 | + $this->generateOutput(' 1/50 [>---------------------------] 2%') . |
|
220 | + $this->generateOutput(' 15/50 [========>-------------------] 30%') . |
|
221 | 221 | $this->generateOutput(' 25/50 [==============>-------------] 50%'), |
222 | 222 | stream_get_contents($output->getStream()) |
223 | 223 | ); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | rewind($output->getStream()); |
272 | 272 | $this->assertEquals( |
273 | - $this->generateOutput(' 0 [>---------------------------]'). |
|
273 | + $this->generateOutput(' 0 [>---------------------------]') . |
|
274 | 274 | $this->generateOutput(' 3 [■■■>------------------------]'), |
275 | 275 | stream_get_contents($output->getStream()) |
276 | 276 | ); |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | |
286 | 286 | rewind($output->getStream()); |
287 | 287 | $this->assertEquals( |
288 | - $this->generateOutput(' 0/50 [>---------------------------] 0%'). |
|
289 | - $this->generateOutput(' 25/50 [==============>-------------] 50%'). |
|
288 | + $this->generateOutput(' 0/50 [>---------------------------] 0%') . |
|
289 | + $this->generateOutput(' 25/50 [==============>-------------] 50%') . |
|
290 | 290 | $this->generateOutput(' '), |
291 | 291 | stream_get_contents($output->getStream()) |
292 | 292 | ); |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | |
303 | 303 | rewind($output->getStream()); |
304 | 304 | $this->assertEquals( |
305 | - $this->generateOutput(' 0/200 [>---------------------------] 0%'). |
|
306 | - $this->generateOutput(' 0/200 [>---------------------------] 0%'). |
|
307 | - $this->generateOutput(' 199/200 [===========================>] 99%'). |
|
305 | + $this->generateOutput(' 0/200 [>---------------------------] 0%') . |
|
306 | + $this->generateOutput(' 0/200 [>---------------------------] 0%') . |
|
307 | + $this->generateOutput(' 199/200 [===========================>] 99%') . |
|
308 | 308 | $this->generateOutput(' 200/200 [============================] 100%'), |
309 | 309 | stream_get_contents($output->getStream()) |
310 | 310 | ); |
@@ -323,16 +323,16 @@ discard block |
||
323 | 323 | |
324 | 324 | rewind($output->getStream()); |
325 | 325 | $this->assertEquals( |
326 | - " 0/200 [>---------------------------] 0%\n". |
|
327 | - " 20/200 [==>-------------------------] 10%\n". |
|
328 | - " 40/200 [=====>----------------------] 20%\n". |
|
329 | - " 60/200 [========>-------------------] 30%\n". |
|
330 | - " 80/200 [===========>----------------] 40%\n". |
|
331 | - " 100/200 [==============>-------------] 50%\n". |
|
332 | - " 120/200 [================>-----------] 60%\n". |
|
333 | - " 140/200 [===================>--------] 70%\n". |
|
334 | - " 160/200 [======================>-----] 80%\n". |
|
335 | - " 180/200 [=========================>--] 90%\n". |
|
326 | + " 0/200 [>---------------------------] 0%\n" . |
|
327 | + " 20/200 [==>-------------------------] 10%\n" . |
|
328 | + " 40/200 [=====>----------------------] 20%\n" . |
|
329 | + " 60/200 [========>-------------------] 30%\n" . |
|
330 | + " 80/200 [===========>----------------] 40%\n" . |
|
331 | + " 100/200 [==============>-------------] 50%\n" . |
|
332 | + " 120/200 [================>-----------] 60%\n" . |
|
333 | + " 140/200 [===================>--------] 70%\n" . |
|
334 | + " 160/200 [======================>-----] 80%\n" . |
|
335 | + " 180/200 [=========================>--] 90%\n" . |
|
336 | 336 | " 200/200 [============================] 100%", |
337 | 337 | stream_get_contents($output->getStream()) |
338 | 338 | ); |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | |
350 | 350 | rewind($output->getStream()); |
351 | 351 | $this->assertEquals( |
352 | - " 0/50 [>---------------------------] 0%\n". |
|
353 | - " 25/50 [==============>-------------] 50%\n". |
|
352 | + " 0/50 [>---------------------------] 0%\n" . |
|
353 | + " 25/50 [==============>-------------] 50%\n" . |
|
354 | 354 | " 50/50 [============================] 100%", |
355 | 355 | stream_get_contents($output->getStream()) |
356 | 356 | ); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | |
365 | 365 | rewind($output->getStream()); |
366 | 366 | $this->assertEquals( |
367 | - " 0 [>---------------------------]\n". |
|
367 | + " 0 [>---------------------------]\n" . |
|
368 | 368 | " 1 [->--------------------------]", |
369 | 369 | stream_get_contents($output->getStream()) |
370 | 370 | ); |
@@ -402,28 +402,28 @@ discard block |
||
402 | 402 | |
403 | 403 | rewind($output->getStream()); |
404 | 404 | $this->assertEquals( |
405 | - $this->generateOutput(' 0/2 [>---------------------------] 0%')."\n". |
|
406 | - $this->generateOutput(' 0/3 [#---------------------------] 0%')."\n". |
|
407 | - rtrim($this->generateOutput(' 0 [>---------------------------]')). |
|
408 | - |
|
409 | - "\033[2A". |
|
410 | - $this->generateOutput(' 1/2 [==============>-------------] 50%')."\n". |
|
411 | - $this->generateOutput(' 1/3 [=========#------------------] 33%')."\n". |
|
412 | - rtrim($this->generateOutput(' 1 [->--------------------------]')). |
|
413 | - |
|
414 | - "\033[2A". |
|
415 | - $this->generateOutput(' 2/2 [============================] 100%')."\n". |
|
416 | - $this->generateOutput(' 2/3 [==================#---------] 66%')."\n". |
|
417 | - rtrim($this->generateOutput(' 2 [-->-------------------------]')). |
|
418 | - |
|
419 | - "\033[2A". |
|
420 | - "\n". |
|
421 | - $this->generateOutput(' 3/3 [============================] 100%')."\n". |
|
422 | - rtrim($this->generateOutput(' 3 [--->------------------------]')). |
|
423 | - |
|
424 | - "\033[2A". |
|
425 | - "\n". |
|
426 | - "\n". |
|
405 | + $this->generateOutput(' 0/2 [>---------------------------] 0%') . "\n" . |
|
406 | + $this->generateOutput(' 0/3 [#---------------------------] 0%') . "\n" . |
|
407 | + rtrim($this->generateOutput(' 0 [>---------------------------]')) . |
|
408 | + |
|
409 | + "\033[2A" . |
|
410 | + $this->generateOutput(' 1/2 [==============>-------------] 50%') . "\n" . |
|
411 | + $this->generateOutput(' 1/3 [=========#------------------] 33%') . "\n" . |
|
412 | + rtrim($this->generateOutput(' 1 [->--------------------------]')) . |
|
413 | + |
|
414 | + "\033[2A" . |
|
415 | + $this->generateOutput(' 2/2 [============================] 100%') . "\n" . |
|
416 | + $this->generateOutput(' 2/3 [==================#---------] 66%') . "\n" . |
|
417 | + rtrim($this->generateOutput(' 2 [-->-------------------------]')) . |
|
418 | + |
|
419 | + "\033[2A" . |
|
420 | + "\n" . |
|
421 | + $this->generateOutput(' 3/3 [============================] 100%') . "\n" . |
|
422 | + rtrim($this->generateOutput(' 3 [--->------------------------]')) . |
|
423 | + |
|
424 | + "\033[2A" . |
|
425 | + "\n" . |
|
426 | + "\n" . |
|
427 | 427 | rtrim($this->generateOutput(' 3 [============================]')), |
428 | 428 | stream_get_contents($output->getStream()) |
429 | 429 | ); |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | |
443 | 443 | rewind($output->getStream()); |
444 | 444 | $this->assertEquals( |
445 | - rtrim($this->generateOutput(' 0 [>---------------------------]')). |
|
446 | - rtrim($this->generateOutput(' 1 [->--------------------------]')). |
|
447 | - rtrim($this->generateOutput(' 2 [-->-------------------------]')). |
|
448 | - rtrim($this->generateOutput(' 3 [--->------------------------]')). |
|
445 | + rtrim($this->generateOutput(' 0 [>---------------------------]')) . |
|
446 | + rtrim($this->generateOutput(' 1 [->--------------------------]')) . |
|
447 | + rtrim($this->generateOutput(' 2 [-->-------------------------]')) . |
|
448 | + rtrim($this->generateOutput(' 3 [--->------------------------]')) . |
|
449 | 449 | rtrim($this->generateOutput(' 3 [============================]')), |
450 | 450 | stream_get_contents($output->getStream()) |
451 | 451 | ); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | public function testAddingPlaceholderFormatter() |
455 | 455 | { |
456 | - ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) { |
|
456 | + ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function(ProgressBar $bar) { |
|
457 | 457 | return $bar->getMaxSteps() - $bar->getProgress(); |
458 | 458 | }); |
459 | 459 | $bar = new ProgressBar($output = $this->getOutputStream(), 3); |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | |
466 | 466 | rewind($output->getStream()); |
467 | 467 | $this->assertEquals( |
468 | - $this->generateOutput(' 3 [>---------------------------]'). |
|
469 | - $this->generateOutput(' 2 [=========>------------------]'). |
|
468 | + $this->generateOutput(' 3 [>---------------------------]') . |
|
469 | + $this->generateOutput(' 2 [=========>------------------]') . |
|
470 | 470 | $this->generateOutput(' 0 [============================]'), |
471 | 471 | stream_get_contents($output->getStream()) |
472 | 472 | ); |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | |
485 | 485 | rewind($output->getStream()); |
486 | 486 | $this->assertEquals( |
487 | - $this->generateOutput(">---------------------------\nfoobar"). |
|
488 | - $this->generateOutput("=========>------------------\nfoobar "). |
|
489 | - $this->generateOutput(" \n "). |
|
487 | + $this->generateOutput(">---------------------------\nfoobar") . |
|
488 | + $this->generateOutput("=========>------------------\nfoobar ") . |
|
489 | + $this->generateOutput(" \n ") . |
|
490 | 490 | $this->generateOutput("============================\nfoobar "), |
491 | 491 | stream_get_contents($output->getStream()) |
492 | 492 | ); |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | public function testAnsiColorsAndEmojis() |
496 | 496 | { |
497 | 497 | $bar = new ProgressBar($output = $this->getOutputStream(), 15); |
498 | - ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) { |
|
498 | + ProgressBar::setPlaceholderFormatterDefinition('memory', function(ProgressBar $bar) { |
|
499 | 499 | static $i = 0; |
500 | 500 | $mem = 100000 * $i; |
501 | 501 | $colors = $i++ ? '41;37' : '44;37'; |
502 | 502 | |
503 | - return "\033[".$colors."m ".Helper::formatMemory($mem)." \033[0m"; |
|
503 | + return "\033[" . $colors . "m " . Helper::formatMemory($mem) . " \033[0m"; |
|
504 | 504 | }); |
505 | 505 | $bar->setFormat(" \033[44;37m %title:-37s% \033[0m\n %current%/%max% %bar% %percent:3s%%\n |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | |
32 | 32 | function menu_ul($sel = 'inicio') |
33 | - { |
|
33 | + { |
|
34 | 34 | $items = array( |
35 | 35 | 'inicio' => array( |
36 | 36 | 'id' => 'inicio', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | function menu_p($sel = 'inicio', $separador = '') |
68 | - { |
|
68 | + { |
|
69 | 69 | //$CI =& get_instance(); |
70 | 70 | $items = array( |
71 | 71 | 'inicio' => array( |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | ) |
54 | 54 | ); |
55 | 55 | |
56 | - $menu = '<ul class="inline" >'. PHP_EOL; |
|
57 | - foreach($items as $item) |
|
56 | + $menu = '<ul class="inline" >' . PHP_EOL; |
|
57 | + foreach ($items as $item) |
|
58 | 58 | { |
59 | 59 | $current = (in_array($sel, $item)) ? ' class="current"' : ''; |
60 | - $id = (!empty($item['id'])) ? ' id="'.$item['id'].'"' : ''; |
|
61 | - $menu .= '<li'.$current.'><a href="'.$item['link'].'"'.$id.'>'.$item['title'].'</a></li>'."\n"; |
|
60 | + $id = (!empty($item['id'])) ? ' id="' . $item['id'] . '"' : ''; |
|
61 | + $menu .= '<li' . $current . '><a href="' . $item['link'] . '"' . $id . '>' . $item['title'] . '</a></li>' . "\n"; |
|
62 | 62 | } |
63 | - $menu .= '</ul>'. PHP_EOL . PHP_EOL; |
|
63 | + $menu .= '</ul>' . PHP_EOL . PHP_EOL; |
|
64 | 64 | return $menu; |
65 | 65 | } |
66 | 66 | |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | |
92 | 92 | $count = count($items); |
93 | 93 | $i = 0; |
94 | - $menu = PHP_EOL .'<p class="bottom_nav">'; |
|
95 | - foreach($items as $item) |
|
94 | + $menu = PHP_EOL . '<p class="bottom_nav">'; |
|
95 | + foreach ($items as $item) |
|
96 | 96 | { |
97 | 97 | $current = (in_array($sel, $item)) ? ' class="current"' : ''; |
98 | - $id = (!empty($item['id'])) ? ' id="'.$item['id'].'"' : ''; |
|
99 | - $menu .= '<a'.$current.' href="'.$item['link'].'"'.$id.'>'.$item['title'].'</a>'; |
|
98 | + $id = (!empty($item['id'])) ? ' id="' . $item['id'] . '"' : ''; |
|
99 | + $menu .= '<a' . $current . ' href="' . $item['link'] . '"' . $id . '>' . $item['title'] . '</a>'; |
|
100 | 100 | $i++; |
101 | - if($count != $i) |
|
101 | + if ($count != $i) |
|
102 | 102 | { |
103 | - $menu .= ' '.$separador.' '; |
|
103 | + $menu .= ' ' . $separador . ' '; |
|
104 | 104 | } |
105 | 105 | } |
106 | - $menu .= '</p>'. PHP_EOL ; |
|
106 | + $menu .= '</p>' . PHP_EOL; |
|
107 | 107 | return $menu; |
108 | 108 | } |
109 | 109 |