@@ -62,6 +62,9 @@ |
||
62 | 62 | require_once self::$fixturesPath.'/TestToto.php'; |
63 | 63 | } |
64 | 64 | |
65 | + /** |
|
66 | + * @param string $text |
|
67 | + */ |
|
65 | 68 | protected function normalizeLineBreaks($text) |
66 | 69 | { |
67 | 70 | return str_replace(PHP_EOL, "\n", $text); |
@@ -13,8 +13,8 @@ |
||
13 | 13 | |
14 | 14 | use PHPUnit\Framework\TestCase; |
15 | 15 | use Symfony\Component\Console\Application; |
16 | -use Symfony\Component\Console\Command\Command; |
|
17 | 16 | use Symfony\Component\Console\CommandLoader\FactoryCommandLoader; |
17 | +use Symfony\Component\Console\Command\Command; |
|
18 | 18 | use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; |
19 | 19 | use Symfony\Component\Console\Event\ConsoleCommandEvent; |
20 | 20 | use Symfony\Component\Console\Event\ConsoleErrorEvent; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); |
136 | 136 | |
137 | 137 | $application->setCommandLoader(new FactoryCommandLoader(array( |
138 | - 'foo:bar1' => function () { return new \Foo1Command(); }, |
|
138 | + 'foo:bar1' => function(){ return new \Foo1Command(); }, |
|
139 | 139 | ))); |
140 | 140 | $commands = $application->all('foo'); |
141 | 141 | $this->assertCount(2, $commands, '->all() takes a namespace as its first argument'); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); |
208 | 208 | |
209 | 209 | $application->setCommandLoader(new FactoryCommandLoader(array( |
210 | - 'foo:bar1' => function () { return new \Foo1Command(); }, |
|
210 | + 'foo:bar1' => function(){ return new \Foo1Command(); }, |
|
211 | 211 | ))); |
212 | 212 | |
213 | 213 | $this->assertTrue($application->has('afoobar'), '->has() returns true if an instance is registered for an alias even with command loader'); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | { |
370 | 370 | $application = new Application(); |
371 | 371 | $application->setCommandLoader(new FactoryCommandLoader(array( |
372 | - 'foo:bar' => $f = function () { return new \FooCommand(); }, |
|
372 | + 'foo:bar' => $f = function(){ return new \FooCommand(); }, |
|
373 | 373 | ))); |
374 | 374 | |
375 | 375 | $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | putenv('COLUMNS=32'); |
761 | 761 | $tester = new ApplicationTester($application); |
762 | 762 | |
763 | - $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); |
|
763 | + $tester->run(array('command' => 'foo'), array('decorated' => false, 'capture_stderr_separately' => true)); |
|
764 | 764 | $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getErrorOutput(true), '->renderException() wraps messages when they are bigger than the terminal'); |
765 | 765 | putenv('COLUMNS=120'); |
766 | 766 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | $application = new Application(); |
771 | 771 | $application->setAutoExit(false); |
772 | 772 | putenv('COLUMNS=120'); |
773 | - $application->register('foo')->setCode(function () { |
|
773 | + $application->register('foo')->setCode(function(){ |
|
774 | 774 | throw new \Exception('エラーメッセージ'); |
775 | 775 | }); |
776 | 776 | $tester = new ApplicationTester($application); |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | $application = new Application(); |
785 | 785 | $application->setAutoExit(false); |
786 | 786 | putenv('COLUMNS=32'); |
787 | - $application->register('foo')->setCode(function () { |
|
787 | + $application->register('foo')->setCode(function(){ |
|
788 | 788 | throw new \Exception('コマンドの実行中にエラーが発生しました。'); |
789 | 789 | }); |
790 | 790 | $tester = new ApplicationTester($application); |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | $application = new Application(); |
799 | 799 | $application->setAutoExit(false); |
800 | 800 | putenv('COLUMNS=22'); |
801 | - $application->register('foo')->setCode(function () { |
|
801 | + $application->register('foo')->setCode(function(){ |
|
802 | 802 | throw new \Exception('dont break here <info>!</info>'); |
803 | 803 | }); |
804 | 804 | $tester = new ApplicationTester($application); |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $application->expects($this->any()) |
816 | 816 | ->method('getTerminalWidth') |
817 | 817 | ->will($this->returnValue(120)); |
818 | - $application->register('foo')->setCode(function () { |
|
818 | + $application->register('foo')->setCode(function(){ |
|
819 | 819 | throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); |
820 | 820 | }); |
821 | 821 | $tester = new ApplicationTester($application); |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | // We can assume here that some other test asserts that the event is dispatched at all |
968 | 968 | $dispatcher = new EventDispatcher(); |
969 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { |
|
969 | + $dispatcher->addListener('console.terminate', function(ConsoleTerminateEvent $event) use (&$passedRightValue) { |
|
970 | 970 | $passedRightValue = (4 === $event->getExitCode()); |
971 | 971 | }); |
972 | 972 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | $application->setDispatcher($dispatcher); |
975 | 975 | $application->setAutoExit(false); |
976 | 976 | |
977 | - $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
977 | + $application->register('test')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
978 | 978 | throw new \Exception('', 4); |
979 | 979 | }); |
980 | 980 | |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | // We can assume here that some other test asserts that the event is dispatched at all |
1007 | 1007 | $dispatcher = new EventDispatcher(); |
1008 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { |
|
1008 | + $dispatcher->addListener('console.terminate', function(ConsoleTerminateEvent $event) use (&$passedRightValue) { |
|
1009 | 1009 | $passedRightValue = (1 === $event->getExitCode()); |
1010 | 1010 | }); |
1011 | 1011 | |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | $application->setDispatcher($dispatcher); |
1014 | 1014 | $application->setAutoExit(false); |
1015 | 1015 | |
1016 | - $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1016 | + $application->register('test')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1017 | 1017 | throw new \Exception(); |
1018 | 1018 | }); |
1019 | 1019 | |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | ->register('foo') |
1042 | 1042 | ->setAliases(array('f')) |
1043 | 1043 | ->setDefinition(array(new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.'))) |
1044 | - ->setCode(function (InputInterface $input, OutputInterface $output) {}) |
|
1044 | + ->setCode(function(InputInterface $input, OutputInterface $output){}) |
|
1045 | 1045 | ; |
1046 | 1046 | |
1047 | 1047 | $input = new ArrayInput(array('command' => 'foo')); |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | $application |
1063 | 1063 | ->register('foo') |
1064 | 1064 | ->setDefinition(array($def)) |
1065 | - ->setCode(function (InputInterface $input, OutputInterface $output) {}) |
|
1065 | + ->setCode(function(InputInterface $input, OutputInterface $output){}) |
|
1066 | 1066 | ; |
1067 | 1067 | |
1068 | 1068 | $input = new ArrayInput(array('command' => 'foo')); |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | $application->setAutoExit(false); |
1196 | 1196 | $application->setDispatcher($this->getDispatcher()); |
1197 | 1197 | |
1198 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1198 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1199 | 1199 | $output->write('foo.'); |
1200 | 1200 | }); |
1201 | 1201 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | $application->setAutoExit(false); |
1216 | 1216 | $application->setCatchExceptions(false); |
1217 | 1217 | |
1218 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1218 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1219 | 1219 | throw new \RuntimeException('foo'); |
1220 | 1220 | }); |
1221 | 1221 | |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | $application->setDispatcher($this->getDispatcher()); |
1230 | 1230 | $application->setAutoExit(false); |
1231 | 1231 | |
1232 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1232 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1233 | 1233 | $output->write('foo.'); |
1234 | 1234 | |
1235 | 1235 | throw new \RuntimeException('foo'); |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | public function testRunDispatchesAllEventsWithExceptionInListener() |
1244 | 1244 | { |
1245 | 1245 | $dispatcher = $this->getDispatcher(); |
1246 | - $dispatcher->addListener('console.command', function () { |
|
1246 | + $dispatcher->addListener('console.command', function(){ |
|
1247 | 1247 | throw new \RuntimeException('foo'); |
1248 | 1248 | }); |
1249 | 1249 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | $application->setDispatcher($dispatcher); |
1252 | 1252 | $application->setAutoExit(false); |
1253 | 1253 | |
1254 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1254 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1255 | 1255 | $output->write('foo.'); |
1256 | 1256 | }); |
1257 | 1257 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | $application->setAutoExit(false); |
1267 | 1267 | $application->setCatchExceptions(false); |
1268 | 1268 | |
1269 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1269 | + $application->register('dym')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1270 | 1270 | $output->write('dym.'); |
1271 | 1271 | |
1272 | 1272 | throw new \Error('dymerr'); |
@@ -1285,13 +1285,13 @@ discard block |
||
1285 | 1285 | public function testRunAllowsErrorListenersToSilenceTheException() |
1286 | 1286 | { |
1287 | 1287 | $dispatcher = $this->getDispatcher(); |
1288 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1288 | + $dispatcher->addListener('console.error', function(ConsoleErrorEvent $event){ |
|
1289 | 1289 | $event->getOutput()->write('silenced.'); |
1290 | 1290 | |
1291 | 1291 | $event->setExitCode(0); |
1292 | 1292 | }); |
1293 | 1293 | |
1294 | - $dispatcher->addListener('console.command', function () { |
|
1294 | + $dispatcher->addListener('console.command', function(){ |
|
1295 | 1295 | throw new \RuntimeException('foo'); |
1296 | 1296 | }); |
1297 | 1297 | |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | $application->setDispatcher($dispatcher); |
1300 | 1300 | $application->setAutoExit(false); |
1301 | 1301 | |
1302 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1302 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1303 | 1303 | $output->write('foo.'); |
1304 | 1304 | }); |
1305 | 1305 | |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | public function testConsoleErrorEventIsTriggeredOnCommandNotFound() |
1313 | 1313 | { |
1314 | 1314 | $dispatcher = new EventDispatcher(); |
1315 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1315 | + $dispatcher->addListener('console.error', function(ConsoleErrorEvent $event){ |
|
1316 | 1316 | $this->assertNull($event->getCommand()); |
1317 | 1317 | $this->assertInstanceOf(CommandNotFoundException::class, $event->getError()); |
1318 | 1318 | $event->getOutput()->write('silenced command not found'); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | $application->setCatchExceptions(false); |
1336 | 1336 | $application->setDispatcher(new EventDispatcher()); |
1337 | 1337 | |
1338 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1338 | + $application->register('dym')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1339 | 1339 | new \UnknownClass(); |
1340 | 1340 | }); |
1341 | 1341 | |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | $application->setAutoExit(false); |
1361 | 1361 | $application->setCatchExceptions(false); |
1362 | 1362 | |
1363 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1363 | + $application->register('dym')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1364 | 1364 | $output->write('dym.'); |
1365 | 1365 | |
1366 | 1366 | throw new \Error('dymerr'); |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | $application->setDispatcher($this->getDispatcher()); |
1378 | 1378 | $application->setAutoExit(false); |
1379 | 1379 | |
1380 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1380 | + $application->register('dym')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1381 | 1381 | $output->write('dym.'); |
1382 | 1382 | |
1383 | 1383 | throw new \Error('dymerr'); |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | $application->setDispatcher($this->getDispatcher()); |
1395 | 1395 | $application->setAutoExit(false); |
1396 | 1396 | |
1397 | - $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1397 | + $application->register('dus')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1398 | 1398 | $output->write('dus.'); |
1399 | 1399 | |
1400 | 1400 | throw new \Error('duserr'); |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | $application->setDispatcher($this->getDispatcher(true)); |
1412 | 1412 | $application->setAutoExit(false); |
1413 | 1413 | |
1414 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1414 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1415 | 1415 | $output->write('foo.'); |
1416 | 1416 | }); |
1417 | 1417 | |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | $quietValue = null; |
1428 | 1428 | |
1429 | 1429 | $dispatcher = $this->getDispatcher(); |
1430 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { |
|
1430 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { |
|
1431 | 1431 | $input = $event->getInput(); |
1432 | 1432 | |
1433 | 1433 | $noInteractionValue = $input->getOption('no-interaction'); |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | $application->setDispatcher($dispatcher); |
1439 | 1439 | $application->setAutoExit(false); |
1440 | 1440 | |
1441 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1441 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1442 | 1442 | $output->write('foo.'); |
1443 | 1443 | }); |
1444 | 1444 | |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | $extraValue = null; |
1455 | 1455 | |
1456 | 1456 | $dispatcher = $this->getDispatcher(); |
1457 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { |
|
1457 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use (&$extraValue) { |
|
1458 | 1458 | $definition = $event->getCommand()->getDefinition(); |
1459 | 1459 | $input = $event->getInput(); |
1460 | 1460 | |
@@ -1468,7 +1468,7 @@ discard block |
||
1468 | 1468 | $application->setDispatcher($dispatcher); |
1469 | 1469 | $application->setAutoExit(false); |
1470 | 1470 | |
1471 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1471 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1472 | 1472 | $output->write('foo.'); |
1473 | 1473 | }); |
1474 | 1474 | |
@@ -1586,42 +1586,42 @@ discard block |
||
1586 | 1586 | public function testGetDisabledLazyCommand() |
1587 | 1587 | { |
1588 | 1588 | $application = new Application(); |
1589 | - $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function () { return new DisabledCommand(); }))); |
|
1589 | + $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function(){ return new DisabledCommand(); }))); |
|
1590 | 1590 | $application->get('disabled'); |
1591 | 1591 | } |
1592 | 1592 | |
1593 | 1593 | public function testHasReturnsFalseForDisabledLazyCommand() |
1594 | 1594 | { |
1595 | 1595 | $application = new Application(); |
1596 | - $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function () { return new DisabledCommand(); }))); |
|
1596 | + $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function(){ return new DisabledCommand(); }))); |
|
1597 | 1597 | $this->assertFalse($application->has('disabled')); |
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | public function testAllExcludesDisabledLazyCommand() |
1601 | 1601 | { |
1602 | 1602 | $application = new Application(); |
1603 | - $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function () { return new DisabledCommand(); }))); |
|
1603 | + $application->setCommandLoader(new FactoryCommandLoader(array('disabled' => function(){ return new DisabledCommand(); }))); |
|
1604 | 1604 | $this->assertArrayNotHasKey('disabled', $application->all()); |
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | protected function getDispatcher($skipCommand = false) |
1608 | 1608 | { |
1609 | 1609 | $dispatcher = new EventDispatcher(); |
1610 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { |
|
1610 | + $dispatcher->addListener('console.command', function(ConsoleCommandEvent $event) use ($skipCommand) { |
|
1611 | 1611 | $event->getOutput()->write('before.'); |
1612 | 1612 | |
1613 | 1613 | if ($skipCommand) { |
1614 | 1614 | $event->disableCommand(); |
1615 | 1615 | } |
1616 | 1616 | }); |
1617 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { |
|
1617 | + $dispatcher->addListener('console.terminate', function(ConsoleTerminateEvent $event) use ($skipCommand) { |
|
1618 | 1618 | $event->getOutput()->writeln('after.'); |
1619 | 1619 | |
1620 | 1620 | if (!$skipCommand) { |
1621 | 1621 | $event->setExitCode(ConsoleCommandEvent::RETURN_CODE_DISABLED); |
1622 | 1622 | } |
1623 | 1623 | }); |
1624 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1624 | + $dispatcher->addListener('console.error', function(ConsoleErrorEvent $event){ |
|
1625 | 1625 | $event->getOutput()->write('error.'); |
1626 | 1626 | |
1627 | 1627 | $event->setError(new \LogicException('error.', $event->getExitCode(), $event->getError())); |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | $application->setAutoExit(false); |
1637 | 1637 | $application->setDispatcher(new EventDispatcher()); |
1638 | 1638 | |
1639 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1639 | + $application->register('dym')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1640 | 1640 | new \UnknownClass(); |
1641 | 1641 | }); |
1642 | 1642 | |
@@ -1657,11 +1657,11 @@ discard block |
||
1657 | 1657 | public function testThrowingErrorListener() |
1658 | 1658 | { |
1659 | 1659 | $dispatcher = $this->getDispatcher(); |
1660 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1660 | + $dispatcher->addListener('console.error', function(ConsoleErrorEvent $event){ |
|
1661 | 1661 | throw new \RuntimeException('foo'); |
1662 | 1662 | }); |
1663 | 1663 | |
1664 | - $dispatcher->addListener('console.command', function () { |
|
1664 | + $dispatcher->addListener('console.command', function(){ |
|
1665 | 1665 | throw new \RuntimeException('bar'); |
1666 | 1666 | }); |
1667 | 1667 | |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | $application->setAutoExit(false); |
1671 | 1671 | $application->setCatchExceptions(false); |
1672 | 1672 | |
1673 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1673 | + $application->register('foo')->setCode(function(InputInterface $input, OutputInterface $output){ |
|
1674 | 1674 | $output->write('foo.'); |
1675 | 1675 | }); |
1676 | 1676 |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | $application = new Application(); |
771 | 771 | $application->setAutoExit(false); |
772 | 772 | putenv('COLUMNS=120'); |
773 | - $application->register('foo')->setCode(function () { |
|
773 | + $application->register('foo')->setCode(function (){ |
|
774 | 774 | throw new \Exception('エラーメッセージ'); |
775 | 775 | }); |
776 | 776 | $tester = new ApplicationTester($application); |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | $application = new Application(); |
785 | 785 | $application->setAutoExit(false); |
786 | 786 | putenv('COLUMNS=32'); |
787 | - $application->register('foo')->setCode(function () { |
|
787 | + $application->register('foo')->setCode(function (){ |
|
788 | 788 | throw new \Exception('コマンドの実行中にエラーが発生しました。'); |
789 | 789 | }); |
790 | 790 | $tester = new ApplicationTester($application); |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | $application = new Application(); |
799 | 799 | $application->setAutoExit(false); |
800 | 800 | putenv('COLUMNS=22'); |
801 | - $application->register('foo')->setCode(function () { |
|
801 | + $application->register('foo')->setCode(function (){ |
|
802 | 802 | throw new \Exception('dont break here <info>!</info>'); |
803 | 803 | }); |
804 | 804 | $tester = new ApplicationTester($application); |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $application->expects($this->any()) |
816 | 816 | ->method('getTerminalWidth') |
817 | 817 | ->will($this->returnValue(120)); |
818 | - $application->register('foo')->setCode(function () { |
|
818 | + $application->register('foo')->setCode(function (){ |
|
819 | 819 | throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n"); |
820 | 820 | }); |
821 | 821 | $tester = new ApplicationTester($application); |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | // We can assume here that some other test asserts that the event is dispatched at all |
968 | 968 | $dispatcher = new EventDispatcher(); |
969 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { |
|
969 | + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue){ |
|
970 | 970 | $passedRightValue = (4 === $event->getExitCode()); |
971 | 971 | }); |
972 | 972 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | $application->setDispatcher($dispatcher); |
975 | 975 | $application->setAutoExit(false); |
976 | 976 | |
977 | - $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
977 | + $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
978 | 978 | throw new \Exception('', 4); |
979 | 979 | }); |
980 | 980 | |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | // We can assume here that some other test asserts that the event is dispatched at all |
1007 | 1007 | $dispatcher = new EventDispatcher(); |
1008 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) { |
|
1008 | + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue){ |
|
1009 | 1009 | $passedRightValue = (1 === $event->getExitCode()); |
1010 | 1010 | }); |
1011 | 1011 | |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | $application->setDispatcher($dispatcher); |
1014 | 1014 | $application->setAutoExit(false); |
1015 | 1015 | |
1016 | - $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1016 | + $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1017 | 1017 | throw new \Exception(); |
1018 | 1018 | }); |
1019 | 1019 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | $application->setAutoExit(false); |
1196 | 1196 | $application->setDispatcher($this->getDispatcher()); |
1197 | 1197 | |
1198 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1198 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1199 | 1199 | $output->write('foo.'); |
1200 | 1200 | }); |
1201 | 1201 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | $application->setAutoExit(false); |
1216 | 1216 | $application->setCatchExceptions(false); |
1217 | 1217 | |
1218 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1218 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1219 | 1219 | throw new \RuntimeException('foo'); |
1220 | 1220 | }); |
1221 | 1221 | |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | $application->setDispatcher($this->getDispatcher()); |
1230 | 1230 | $application->setAutoExit(false); |
1231 | 1231 | |
1232 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1232 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1233 | 1233 | $output->write('foo.'); |
1234 | 1234 | |
1235 | 1235 | throw new \RuntimeException('foo'); |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | public function testRunDispatchesAllEventsWithExceptionInListener() |
1244 | 1244 | { |
1245 | 1245 | $dispatcher = $this->getDispatcher(); |
1246 | - $dispatcher->addListener('console.command', function () { |
|
1246 | + $dispatcher->addListener('console.command', function (){ |
|
1247 | 1247 | throw new \RuntimeException('foo'); |
1248 | 1248 | }); |
1249 | 1249 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | $application->setDispatcher($dispatcher); |
1252 | 1252 | $application->setAutoExit(false); |
1253 | 1253 | |
1254 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1254 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1255 | 1255 | $output->write('foo.'); |
1256 | 1256 | }); |
1257 | 1257 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | $application->setAutoExit(false); |
1267 | 1267 | $application->setCatchExceptions(false); |
1268 | 1268 | |
1269 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1269 | + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1270 | 1270 | $output->write('dym.'); |
1271 | 1271 | |
1272 | 1272 | throw new \Error('dymerr'); |
@@ -1285,13 +1285,13 @@ discard block |
||
1285 | 1285 | public function testRunAllowsErrorListenersToSilenceTheException() |
1286 | 1286 | { |
1287 | 1287 | $dispatcher = $this->getDispatcher(); |
1288 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1288 | + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event){ |
|
1289 | 1289 | $event->getOutput()->write('silenced.'); |
1290 | 1290 | |
1291 | 1291 | $event->setExitCode(0); |
1292 | 1292 | }); |
1293 | 1293 | |
1294 | - $dispatcher->addListener('console.command', function () { |
|
1294 | + $dispatcher->addListener('console.command', function (){ |
|
1295 | 1295 | throw new \RuntimeException('foo'); |
1296 | 1296 | }); |
1297 | 1297 | |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | $application->setDispatcher($dispatcher); |
1300 | 1300 | $application->setAutoExit(false); |
1301 | 1301 | |
1302 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1302 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1303 | 1303 | $output->write('foo.'); |
1304 | 1304 | }); |
1305 | 1305 | |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | public function testConsoleErrorEventIsTriggeredOnCommandNotFound() |
1313 | 1313 | { |
1314 | 1314 | $dispatcher = new EventDispatcher(); |
1315 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1315 | + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event){ |
|
1316 | 1316 | $this->assertNull($event->getCommand()); |
1317 | 1317 | $this->assertInstanceOf(CommandNotFoundException::class, $event->getError()); |
1318 | 1318 | $event->getOutput()->write('silenced command not found'); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | $application->setCatchExceptions(false); |
1336 | 1336 | $application->setDispatcher(new EventDispatcher()); |
1337 | 1337 | |
1338 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1338 | + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1339 | 1339 | new \UnknownClass(); |
1340 | 1340 | }); |
1341 | 1341 | |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | $application->setAutoExit(false); |
1361 | 1361 | $application->setCatchExceptions(false); |
1362 | 1362 | |
1363 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1363 | + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1364 | 1364 | $output->write('dym.'); |
1365 | 1365 | |
1366 | 1366 | throw new \Error('dymerr'); |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | $application->setDispatcher($this->getDispatcher()); |
1378 | 1378 | $application->setAutoExit(false); |
1379 | 1379 | |
1380 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1380 | + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1381 | 1381 | $output->write('dym.'); |
1382 | 1382 | |
1383 | 1383 | throw new \Error('dymerr'); |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | $application->setDispatcher($this->getDispatcher()); |
1395 | 1395 | $application->setAutoExit(false); |
1396 | 1396 | |
1397 | - $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1397 | + $application->register('dus')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1398 | 1398 | $output->write('dus.'); |
1399 | 1399 | |
1400 | 1400 | throw new \Error('duserr'); |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | $application->setDispatcher($this->getDispatcher(true)); |
1412 | 1412 | $application->setAutoExit(false); |
1413 | 1413 | |
1414 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1414 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1415 | 1415 | $output->write('foo.'); |
1416 | 1416 | }); |
1417 | 1417 | |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | $quietValue = null; |
1428 | 1428 | |
1429 | 1429 | $dispatcher = $this->getDispatcher(); |
1430 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue) { |
|
1430 | + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$noInteractionValue, &$quietValue){ |
|
1431 | 1431 | $input = $event->getInput(); |
1432 | 1432 | |
1433 | 1433 | $noInteractionValue = $input->getOption('no-interaction'); |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | $application->setDispatcher($dispatcher); |
1439 | 1439 | $application->setAutoExit(false); |
1440 | 1440 | |
1441 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1441 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1442 | 1442 | $output->write('foo.'); |
1443 | 1443 | }); |
1444 | 1444 | |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | $extraValue = null; |
1455 | 1455 | |
1456 | 1456 | $dispatcher = $this->getDispatcher(); |
1457 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue) { |
|
1457 | + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use (&$extraValue){ |
|
1458 | 1458 | $definition = $event->getCommand()->getDefinition(); |
1459 | 1459 | $input = $event->getInput(); |
1460 | 1460 | |
@@ -1468,7 +1468,7 @@ discard block |
||
1468 | 1468 | $application->setDispatcher($dispatcher); |
1469 | 1469 | $application->setAutoExit(false); |
1470 | 1470 | |
1471 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1471 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1472 | 1472 | $output->write('foo.'); |
1473 | 1473 | }); |
1474 | 1474 | |
@@ -1607,21 +1607,21 @@ discard block |
||
1607 | 1607 | protected function getDispatcher($skipCommand = false) |
1608 | 1608 | { |
1609 | 1609 | $dispatcher = new EventDispatcher(); |
1610 | - $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) { |
|
1610 | + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand){ |
|
1611 | 1611 | $event->getOutput()->write('before.'); |
1612 | 1612 | |
1613 | 1613 | if ($skipCommand) { |
1614 | 1614 | $event->disableCommand(); |
1615 | 1615 | } |
1616 | 1616 | }); |
1617 | - $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) { |
|
1617 | + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand){ |
|
1618 | 1618 | $event->getOutput()->writeln('after.'); |
1619 | 1619 | |
1620 | 1620 | if (!$skipCommand) { |
1621 | 1621 | $event->setExitCode(ConsoleCommandEvent::RETURN_CODE_DISABLED); |
1622 | 1622 | } |
1623 | 1623 | }); |
1624 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1624 | + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event){ |
|
1625 | 1625 | $event->getOutput()->write('error.'); |
1626 | 1626 | |
1627 | 1627 | $event->setError(new \LogicException('error.', $event->getExitCode(), $event->getError())); |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | $application->setAutoExit(false); |
1637 | 1637 | $application->setDispatcher(new EventDispatcher()); |
1638 | 1638 | |
1639 | - $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1639 | + $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1640 | 1640 | new \UnknownClass(); |
1641 | 1641 | }); |
1642 | 1642 | |
@@ -1657,11 +1657,11 @@ discard block |
||
1657 | 1657 | public function testThrowingErrorListener() |
1658 | 1658 | { |
1659 | 1659 | $dispatcher = $this->getDispatcher(); |
1660 | - $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event) { |
|
1660 | + $dispatcher->addListener('console.error', function (ConsoleErrorEvent $event){ |
|
1661 | 1661 | throw new \RuntimeException('foo'); |
1662 | 1662 | }); |
1663 | 1663 | |
1664 | - $dispatcher->addListener('console.command', function () { |
|
1664 | + $dispatcher->addListener('console.command', function (){ |
|
1665 | 1665 | throw new \RuntimeException('bar'); |
1666 | 1666 | }); |
1667 | 1667 | |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | $application->setAutoExit(false); |
1671 | 1671 | $application->setCatchExceptions(false); |
1672 | 1672 | |
1673 | - $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { |
|
1673 | + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output){ |
|
1674 | 1674 | $output->write('foo.'); |
1675 | 1675 | }); |
1676 | 1676 |
@@ -120,16 +120,25 @@ |
||
120 | 120 | $listener->onConsoleTerminate($this->getConsoleTerminateEvent($this->getMockBuilder(InputInterface::class)->getMock(), 255)); |
121 | 121 | } |
122 | 122 | |
123 | + /** |
|
124 | + * @return null|LoggerInterface |
|
125 | + */ |
|
123 | 126 | private function getLogger() |
124 | 127 | { |
125 | 128 | return $this->getMockForAbstractClass(LoggerInterface::class); |
126 | 129 | } |
127 | 130 | |
131 | + /** |
|
132 | + * @param integer $exitCode |
|
133 | + */ |
|
128 | 134 | private function getConsoleTerminateEvent(InputInterface $input, $exitCode) |
129 | 135 | { |
130 | 136 | return new ConsoleTerminateEvent(new Command('test:run'), $input, $this->getOutput(), $exitCode); |
131 | 137 | } |
132 | 138 | |
139 | + /** |
|
140 | + * @return OutputInterface |
|
141 | + */ |
|
133 | 142 | private function getOutput() |
134 | 143 | { |
135 | 144 | return $this->getMockBuilder(OutputInterface::class)->getMock(); |
@@ -14,9 +14,9 @@ |
||
14 | 14 | use PHPUnit\Framework\TestCase; |
15 | 15 | use Psr\Log\LoggerInterface; |
16 | 16 | use Symfony\Component\Console\Command\Command; |
17 | +use Symfony\Component\Console\EventListener\ErrorListener; |
|
17 | 18 | use Symfony\Component\Console\Event\ConsoleErrorEvent; |
18 | 19 | use Symfony\Component\Console\Event\ConsoleTerminateEvent; |
19 | -use Symfony\Component\Console\EventListener\ErrorListener; |
|
20 | 20 | use Symfony\Component\Console\Input\ArgvInput; |
21 | 21 | use Symfony\Component\Console\Input\ArrayInput; |
22 | 22 | use Symfony\Component\Console\Input\Input; |
@@ -16,6 +16,9 @@ |
||
16 | 16 | |
17 | 17 | abstract class AbstractQuestionHelperTest extends TestCase |
18 | 18 | { |
19 | + /** |
|
20 | + * @param resource $stream |
|
21 | + */ |
|
19 | 22 | protected function createStreamableInputInterfaceMock($stream = null, $interactive = true) |
20 | 23 | { |
21 | 24 | $mock = $this->getMockBuilder(StreamableInputInterface::class)->getMock(); |
@@ -109,6 +109,11 @@ |
||
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | + /** |
|
113 | + * @param string $name |
|
114 | + * |
|
115 | + * @return \Symfony\Component\Console\Helper\HelperInterface |
|
116 | + */ |
|
112 | 117 | private function getGenericMockHelper($name, HelperSet $helperset = null) |
113 | 118 | { |
114 | 119 | $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock(); |
@@ -872,6 +872,9 @@ |
||
872 | 872 | return new StreamOutput(fopen('php://memory', 'r+', false), $verbosity, $decorated); |
873 | 873 | } |
874 | 874 | |
875 | + /** |
|
876 | + * @param string $expected |
|
877 | + */ |
|
875 | 878 | protected function generateOutput($expected) |
876 | 879 | { |
877 | 880 | $count = substr_count($expected, "\n"); |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | |
720 | 720 | public function testAddingPlaceholderFormatter() |
721 | 721 | { |
722 | - ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) { |
|
722 | + ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function(ProgressBar $bar){ |
|
723 | 723 | return $bar->getMaxSteps() - $bar->getProgress(); |
724 | 724 | }); |
725 | 725 | $bar = new ProgressBar($output = $this->getOutputStream(), 3); |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | putenv('COLUMNS=156'); |
764 | 764 | |
765 | 765 | $bar = new ProgressBar($output = $this->getOutputStream(), 15); |
766 | - ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) { |
|
766 | + ProgressBar::setPlaceholderFormatterDefinition('memory', function(ProgressBar $bar){ |
|
767 | 767 | static $i = 0; |
768 | 768 | $mem = 100000 * $i; |
769 | 769 | $colors = $i++ ? '41;37' : '44;37'; |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | |
720 | 720 | public function testAddingPlaceholderFormatter() |
721 | 721 | { |
722 | - ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar) { |
|
722 | + ProgressBar::setPlaceholderFormatterDefinition('remaining_steps', function (ProgressBar $bar){ |
|
723 | 723 | return $bar->getMaxSteps() - $bar->getProgress(); |
724 | 724 | }); |
725 | 725 | $bar = new ProgressBar($output = $this->getOutputStream(), 3); |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | putenv('COLUMNS=156'); |
764 | 764 | |
765 | 765 | $bar = new ProgressBar($output = $this->getOutputStream(), 15); |
766 | - ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar) { |
|
766 | + ProgressBar::setPlaceholderFormatterDefinition('memory', function (ProgressBar $bar){ |
|
767 | 767 | static $i = 0; |
768 | 768 | $mem = 100000 * $i; |
769 | 769 | $colors = $i++ ? '41;37' : '44;37'; |
@@ -174,6 +174,9 @@ |
||
174 | 174 | return new StreamOutput(fopen('php://memory', 'r+', false), $verbosity, $decorated); |
175 | 175 | } |
176 | 176 | |
177 | + /** |
|
178 | + * @param string $expected |
|
179 | + */ |
|
177 | 180 | protected function generateOutput($expected) |
178 | 181 | { |
179 | 182 | $count = substr_count($expected, "\n"); |
@@ -617,6 +617,9 @@ |
||
617 | 617 | $this->assertEquals('FooBundle', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question)); |
618 | 618 | } |
619 | 619 | |
620 | + /** |
|
621 | + * @param string $input |
|
622 | + */ |
|
620 | 623 | protected function getInputStream($input) |
621 | 624 | { |
622 | 625 | $stream = fopen('php://memory', 'r+', false); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $dialog->setHelperSet($helperSet); |
333 | 333 | |
334 | 334 | $error = 'This is not a color!'; |
335 | - $validator = function ($color) use ($error) { |
|
335 | + $validator = function($color) use ($error) { |
|
336 | 336 | if (!\in_array($color, array('white', 'black'))) { |
337 | 337 | throw new \InvalidArgumentException($error); |
338 | 338 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | $dialog = new QuestionHelper(); |
567 | 567 | |
568 | 568 | $question = new Question('What\'s your name?'); |
569 | - $question->setValidator(function () { |
|
569 | + $question->setValidator(function(){ |
|
570 | 570 | if (!$value) { |
571 | 571 | throw new \Exception('A value is required.'); |
572 | 572 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $dialog->setHelperSet($helperSet); |
333 | 333 | |
334 | 334 | $error = 'This is not a color!'; |
335 | - $validator = function ($color) use ($error) { |
|
335 | + $validator = function ($color) use ($error){ |
|
336 | 336 | if (!\in_array($color, array('white', 'black'))) { |
337 | 337 | throw new \InvalidArgumentException($error); |
338 | 338 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | $dialog = new QuestionHelper(); |
567 | 567 | |
568 | 568 | $question = new Question('What\'s your name?'); |
569 | - $question->setValidator(function () { |
|
569 | + $question->setValidator(function (){ |
|
570 | 570 | if (!$value) { |
571 | 571 | throw new \Exception('A value is required.'); |
572 | 572 | } |
@@ -132,6 +132,9 @@ discard block |
||
132 | 132 | $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new Question('What\'s your name?')); |
133 | 133 | } |
134 | 134 | |
135 | + /** |
|
136 | + * @param string $input |
|
137 | + */ |
|
135 | 138 | protected function getInputStream($input) |
136 | 139 | { |
137 | 140 | $stream = fopen('php://memory', 'r+', false); |
@@ -159,6 +162,9 @@ discard block |
||
159 | 162 | return $mock; |
160 | 163 | } |
161 | 164 | |
165 | + /** |
|
166 | + * @param string $expected |
|
167 | + */ |
|
162 | 168 | private function assertOutputContains($expected, StreamOutput $output) |
163 | 169 | { |
164 | 170 | rewind($output->getStream()); |
@@ -90,7 +90,7 @@ |
||
90 | 90 | { |
91 | 91 | $questionHelper = new SymfonyQuestionHelper(); |
92 | 92 | $question = new Question('What is your favorite superhero?'); |
93 | - $question->setValidator(function ($value) { return $value; }); |
|
93 | + $question->setValidator(function($value){ return $value; }); |
|
94 | 94 | $input = $this->createStreamableInputInterfaceMock($this->getInputStream("\n")); |
95 | 95 | $this->assertNull($questionHelper->ask($input, $this->createOutputInterface(), $question)); |
96 | 96 | } |
@@ -205,6 +205,9 @@ discard block |
||
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | + /** |
|
209 | + * @param string $class |
|
210 | + */ |
|
208 | 211 | public function checkAnnotations(\ReflectionClass $refl, $class) |
209 | 212 | { |
210 | 213 | $deprecations = array(); |
@@ -340,6 +343,7 @@ discard block |
||
340 | 343 | |
341 | 344 | /** |
342 | 345 | * `realpath` on MacOSX doesn't normalize the case of characters. |
346 | + * @param string $real |
|
343 | 347 | */ |
344 | 348 | private function darwinRealpath($real) |
345 | 349 | { |