@@ -141,6 +141,9 @@ discard block |
||
| 141 | 141 | return isset(self::$formats[$name]) ? self::$formats[$name] : null; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | + /** |
|
| 145 | + * @param string $message |
|
| 146 | + */ |
|
| 144 | 147 | public function setMessage($message, $name = 'message') |
| 145 | 148 | { |
| 146 | 149 | $this->messages[$name] = $message; |
@@ -299,7 +302,7 @@ discard block |
||
| 299 | 302 | /** |
| 300 | 303 | * Sets the redraw frequency. |
| 301 | 304 | * |
| 302 | - * @param int|float $freq The frequency in steps |
|
| 305 | + * @param integer $freq The frequency in steps |
|
| 303 | 306 | */ |
| 304 | 307 | public function setRedrawFrequency($freq) |
| 305 | 308 | { |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat()); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) { |
|
| 406 | + $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function($matches) { |
|
| 407 | 407 | if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) { |
| 408 | 408 | $text = call_user_func($formatter, $this, $this->output); |
| 409 | 409 | } elseif (isset($this->messages[$matches[1]])) { |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | private static function initPlaceholderFormatters() |
| 529 | 529 | { |
| 530 | 530 | return array( |
| 531 | - 'bar' => function (ProgressBar $bar, OutputInterface $output) { |
|
| 531 | + 'bar' => function(ProgressBar $bar, OutputInterface $output) { |
|
| 532 | 532 | $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth()); |
| 533 | 533 | $display = str_repeat($bar->getBarCharacter(), $completeBars); |
| 534 | 534 | if ($completeBars < $bar->getBarWidth()) { |
@@ -538,10 +538,10 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | return $display; |
| 540 | 540 | }, |
| 541 | - 'elapsed' => function (ProgressBar $bar) { |
|
| 541 | + 'elapsed' => function(ProgressBar $bar) { |
|
| 542 | 542 | return Helper::formatTime(time() - $bar->getStartTime()); |
| 543 | 543 | }, |
| 544 | - 'remaining' => function (ProgressBar $bar) { |
|
| 544 | + 'remaining' => function(ProgressBar $bar) { |
|
| 545 | 545 | if (!$bar->getMaxSteps()) { |
| 546 | 546 | throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.'); |
| 547 | 547 | } |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | return Helper::formatTime($remaining); |
| 556 | 556 | }, |
| 557 | - 'estimated' => function (ProgressBar $bar) { |
|
| 557 | + 'estimated' => function(ProgressBar $bar) { |
|
| 558 | 558 | if (!$bar->getMaxSteps()) { |
| 559 | 559 | throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.'); |
| 560 | 560 | } |
@@ -567,16 +567,16 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | return Helper::formatTime($estimated); |
| 569 | 569 | }, |
| 570 | - 'memory' => function (ProgressBar $bar) { |
|
| 570 | + 'memory' => function(ProgressBar $bar) { |
|
| 571 | 571 | return Helper::formatMemory(memory_get_usage(true)); |
| 572 | 572 | }, |
| 573 | - 'current' => function (ProgressBar $bar) { |
|
| 573 | + 'current' => function(ProgressBar $bar) { |
|
| 574 | 574 | return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT); |
| 575 | 575 | }, |
| 576 | - 'max' => function (ProgressBar $bar) { |
|
| 576 | + 'max' => function(ProgressBar $bar) { |
|
| 577 | 577 | return $bar->getMaxSteps(); |
| 578 | 578 | }, |
| 579 | - 'percent' => function (ProgressBar $bar) { |
|
| 579 | + 'percent' => function(ProgressBar $bar) { |
|
| 580 | 580 | return floor($bar->getProgressPercent() * 100); |
| 581 | 581 | }, |
| 582 | 582 | ); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param OutputInterface $output |
| 37 | 37 | * @param string|null $format Indicator format |
| 38 | 38 | * @param int $indicatorChangeInterval Change interval in milliseconds |
| 39 | - * @param array|null $indicatorValues Animated indicator characters |
|
| 39 | + * @param string[] $indicatorValues Animated indicator characters |
|
| 40 | 40 | */ |
| 41 | 41 | public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null) |
| 42 | 42 | { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | /** |
| 114 | 114 | * Starts the indicator output. |
| 115 | 115 | * |
| 116 | - * @param $message |
|
| 116 | + * @param string $message |
|
| 117 | 117 | */ |
| 118 | 118 | public function start($message) |
| 119 | 119 | { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | /** |
| 160 | 160 | * Finish the indicator with message. |
| 161 | 161 | * |
| 162 | - * @param $message |
|
| 162 | + * @param string $message |
|
| 163 | 163 | */ |
| 164 | 164 | public function finish($message) |
| 165 | 165 | { |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $self = $this; |
| 232 | 232 | |
| 233 | - $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) { |
|
| 233 | + $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function($matches) use ($self) { |
|
| 234 | 234 | if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) { |
| 235 | 235 | return call_user_func($formatter, $self); |
| 236 | 236 | } |
@@ -291,16 +291,16 @@ discard block |
||
| 291 | 291 | private static function initPlaceholderFormatters() |
| 292 | 292 | { |
| 293 | 293 | return array( |
| 294 | - 'indicator' => function (ProgressIndicator $indicator) { |
|
| 294 | + 'indicator' => function(ProgressIndicator $indicator) { |
|
| 295 | 295 | return $indicator->getCurrentValue(); |
| 296 | 296 | }, |
| 297 | - 'message' => function (ProgressIndicator $indicator) { |
|
| 297 | + 'message' => function(ProgressIndicator $indicator) { |
|
| 298 | 298 | return $indicator->getMessage(); |
| 299 | 299 | }, |
| 300 | - 'elapsed' => function (ProgressIndicator $indicator) { |
|
| 300 | + 'elapsed' => function(ProgressIndicator $indicator) { |
|
| 301 | 301 | return Helper::formatTime(time() - $indicator->getStartTime()); |
| 302 | 302 | }, |
| 303 | - 'memory' => function () { |
|
| 303 | + 'memory' => function() { |
|
| 304 | 304 | return Helper::formatMemory(memory_get_usage(true)); |
| 305 | 305 | }, |
| 306 | 306 | ); |
@@ -149,7 +149,7 @@ |
||
| 149 | 149 | * Sets table column style. |
| 150 | 150 | * |
| 151 | 151 | * @param int $columnIndex Column index |
| 152 | - * @param TableStyle|string $name The style name or a TableStyle instance |
|
| 152 | + * @param TableStyle $name The style name or a TableStyle instance |
|
| 153 | 153 | * |
| 154 | 154 | * @return Table |
| 155 | 155 | */ |
@@ -19,7 +19,6 @@ |
||
| 19 | 19 | class TableSeparator extends TableCell |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * @param string $value |
|
| 23 | 22 | * @param array $options |
| 24 | 23 | */ |
| 25 | 24 | public function __construct(array $options = array()) |
@@ -49,6 +49,11 @@ |
||
| 49 | 49 | require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | + /** |
|
| 53 | + * @param string $text |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 52 | 57 | protected function normalizeLineBreaks($text) |
| 53 | 58 | { |
| 54 | 59 | return str_replace(PHP_EOL, "\n", $text); |
@@ -687,8 +687,8 @@ discard block |
||
| 687 | 687 | $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); |
| 688 | 688 | $application->setAutoExit(false); |
| 689 | 689 | $application->expects($this->once()) |
| 690 | - ->method('doRun') |
|
| 691 | - ->will($this->throwException($exception)); |
|
| 690 | + ->method('doRun') |
|
| 691 | + ->will($this->throwException($exception)); |
|
| 692 | 692 | |
| 693 | 693 | $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); |
| 694 | 694 | |
@@ -702,8 +702,8 @@ discard block |
||
| 702 | 702 | $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); |
| 703 | 703 | $application->setAutoExit(false); |
| 704 | 704 | $application->expects($this->once()) |
| 705 | - ->method('doRun') |
|
| 706 | - ->will($this->throwException($exception)); |
|
| 705 | + ->method('doRun') |
|
| 706 | + ->will($this->throwException($exception)); |
|
| 707 | 707 | |
| 708 | 708 | $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); |
| 709 | 709 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | $application->expects($this->any()) |
| 542 | 542 | ->method('getTerminalWidth') |
| 543 | 543 | ->will($this->returnValue(120)); |
| 544 | - $application->register('foo')->setCode(function () { |
|
| 544 | + $application->register('foo')->setCode(function() { |
|
| 545 | 545 | throw new \Exception('エラーメッセージ'); |
| 546 | 546 | }); |
| 547 | 547 | $tester = new ApplicationTester($application); |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $application->expects($this->any()) |
| 558 | 558 | ->method('getTerminalWidth') |
| 559 | 559 | ->will($this->returnValue(32)); |
| 560 | - $application->register('foo')->setCode(function () { |
|
| 560 | + $application->register('foo')->setCode(function() { |
|
| 561 | 561 | throw new \Exception('コマンドの実行中にエラーが発生しました。'); |
| 562 | 562 | }); |
| 563 | 563 | $tester = new ApplicationTester($application); |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | $application |
| 723 | 723 | ->register('foo') |
| 724 | 724 | ->setDefinition(array($def)) |
| 725 | - ->setCode(function (InputInterface $input, OutputInterface $output) {}) |
|
| 725 | + ->setCode(function(InputInterface $input, OutputInterface $output) {}) |
|
| 726 | 726 | ; |
| 727 | 727 | |
| 728 | 728 | $input = new ArrayInput(array('command' => 'foo')); |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | $application->setAutoExit(false); |
| 856 | 856 | $application->setDispatcher($this->getDispatcher()); |
| 857 | 857 | |
| 858 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
| 858 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
| 859 | 859 | $output->write('foo.'); |
| 860 | 860 | }); |
| 861 | 861 | |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | $application->setAutoExit(false); |
| 876 | 876 | $application->setCatchExceptions(false); |
| 877 | 877 | |
| 878 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
| 878 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
| 879 | 879 | throw new \RuntimeException('foo'); |
| 880 | 880 | }); |
| 881 | 881 | |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | $application->setDispatcher($this->getDispatcher()); |
| 890 | 890 | $application->setAutoExit(false); |
| 891 | 891 | |
| 892 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
| 892 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
| 893 | 893 | $output->write('foo.'); |
| 894 | 894 | |
| 895 | 895 | throw new \RuntimeException('foo'); |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | $application->setDispatcher($this->getDispatcher(true)); |
| 907 | 907 | $application->setAutoExit(false); |
| 908 | 908 | |
| 909 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
| 909 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
| 910 | 910 | $output->write('foo.'); |
| 911 | 911 | }); |
| 912 | 912 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | $quietValue = null; |
| 923 | 923 | |
| 924 | 924 | $dispatcher = $this->getDispatcher(); |
| 925 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { |
|
| 925 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { |
|
| 926 | 926 | $input = $event->getInput(); |
| 927 | 927 | |
| 928 | 928 | $noInteractionValue = $input->getOption('no-interaction'); |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | $application->setDispatcher($dispatcher); |
| 934 | 934 | $application->setAutoExit(false); |
| 935 | 935 | |
| 936 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
| 936 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
| 937 | 937 | $output->write('foo.'); |
| 938 | 938 | }); |
| 939 | 939 | |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | $extraValue = null; |
| 950 | 950 | |
| 951 | 951 | $dispatcher = $this->getDispatcher(); |
| 952 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { |
|
| 952 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use (&$extraValue) { |
|
| 953 | 953 | $definition = $event->getCommand()->getDefinition(); |
| 954 | 954 | $input = $event->getInput(); |
| 955 | 955 | |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | $application->setDispatcher($dispatcher); |
| 964 | 964 | $application->setAutoExit(false); |
| 965 | 965 | |
| 966 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
| 966 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output) { |
|
| 967 | 967 | $output->write('foo.'); |
| 968 | 968 | }); |
| 969 | 969 | |
@@ -991,21 +991,21 @@ discard block |
||
| 991 | 991 | protected function getDispatcher($skipCommand = false) |
| 992 | 992 | { |
| 993 | 993 | $dispatcher = new EventDispatcher(); |
| 994 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { |
|
| 994 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use ($skipCommand) { |
|
| 995 | 995 | $event->getOutput()->write('before.'); |
| 996 | 996 | |
| 997 | 997 | if ($skipCommand) { |
| 998 | 998 | $event->disableCommand(); |
| 999 | 999 | } |
| 1000 | 1000 | }); |
| 1001 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { |
|
| 1001 | + $dispatcher->addListener('console.terminate', function(ConsoleTerminateEvent $event) use ($skipCommand) { |
|
| 1002 | 1002 | $event->getOutput()->writeln('after.'); |
| 1003 | 1003 | |
| 1004 | 1004 | if (!$skipCommand) { |
| 1005 | 1005 | $event->setExitCode(113); |
| 1006 | 1006 | } |
| 1007 | 1007 | }); |
| 1008 | - $dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) { |
|
| 1008 | + $dispatcher->addListener('console.exception', function(ConsoleExceptionEvent $event) { |
|
| 1009 | 1009 | $event->getOutput()->write('caught.'); |
| 1010 | 1010 | |
| 1011 | 1011 | $event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException())); |
@@ -655,6 +655,9 @@ |
||
| 655 | 655 | return new StreamOutput(fopen('php://memory', 'r+', false), $verbosity, $decorated); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | + /** |
|
| 659 | + * @param string $expected |
|
| 660 | + */ |
|
| 658 | 661 | protected function generateOutput($expected) |
| 659 | 662 | { |
| 660 | 663 | $count = substr_count($expected, "\n"); |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | |
| 520 | 520 | public function testAddingPlaceholderFormatter() |
| 521 | 521 | { |
| 522 | - ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) { |
|
| 522 | + ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function(ProgressBar $bar) { |
|
| 523 | 523 | return $bar->getMaxSteps() - $bar->getProgress(); |
| 524 | 524 | }); |
| 525 | 525 | $bar = new ProgressBar($output = $this->getOutputStream(), 3); |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | public function testAnsiColorsAndEmojis() |
| 562 | 562 | { |
| 563 | 563 | $bar = new ProgressBar($output = $this->getOutputStream(), 15); |
| 564 | - ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) { |
|
| 564 | + ProgressBar::setPlaceholderFormatterDefinition('memory', function(ProgressBar $bar) { |
|
| 565 | 565 | static $i = 0; |
| 566 | 566 | $mem = 100000 * $i; |
| 567 | 567 | $colors = $i++ ? '41;37' : '44;37'; |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | * |
| 61 | 61 | * @throws SyntaxErrorException |
| 62 | 62 | * |
| 63 | - * @return array |
|
| 63 | + * @return integer[] |
|
| 64 | 64 | */ |
| 65 | 65 | public static function parseSeries(array $tokens) |
| 66 | 66 | { |
@@ -70,11 +70,11 @@ |
||
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $joined = trim(implode('', array_map(function (Token $token) { |
|
| 73 | + $joined = trim(implode('', array_map(function(Token $token) { |
|
| 74 | 74 | return $token->getValue(); |
| 75 | 75 | }, $tokens))); |
| 76 | 76 | |
| 77 | - $int = function ($string) { |
|
| 77 | + $int = function($string) { |
|
| 78 | 78 | if (!is_numeric($string)) { |
| 79 | 79 | throw SyntaxErrorException::stringAsFunctionArgument(); |
| 80 | 80 | } |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * @param array $values |
|
| 94 | + * @param string[] $values |
|
| 95 | 95 | * |
| 96 | 96 | * @return bool |
| 97 | 97 | */ |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | /** |
| 69 | 69 | * @param int $flag |
| 70 | 70 | * |
| 71 | - * @return bool |
|
| 71 | + * @return integer |
|
| 72 | 72 | */ |
| 73 | 73 | public function hasFlag($flag) |
| 74 | 74 | { |