Skip to content

Commit

Permalink
Fix return type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 4, 2017
1 parent 3d6b3eb commit 1a0c868
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Console/Command.php
Expand Up @@ -174,7 +174,9 @@ public function run(array $argv, ConsoleIo $io)
$this->setOutputLevel($args, $io);

if ($args->getOption('help')) {
return $this->displayHelp($parser, $args, $io);
$this->displayHelp($parser, $args, $io);

return static::CODE_SUCCESS;
}

return $this->execute($args, $io);
Expand Down
3 changes: 2 additions & 1 deletion src/Console/CommandRunner.php
Expand Up @@ -136,6 +136,7 @@ public function run(array $argv, ConsoleIo $io = null)
$io = $io ?: new ConsoleIo();
$name = $this->resolveName($commands, $io, array_shift($argv));

$result = Shell::CODE_ERROR;
$shell = $this->getShell($io, $commands, $name);
if ($shell instanceof Shell) {
$result = $this->runShell($shell, $argv);
Expand Down Expand Up @@ -236,7 +237,7 @@ protected function runShell(Shell $shell, array $argv)
*
* @param string $className Shell class name.
* @param \Cake\Console\ConsoleIo $io The IO wrapper for the created shell class.
* @return \Cake\Console\Shell
* @return \Cake\Console\Shell|\Cake\Console\Command
*/
protected function createShell($className, ConsoleIo $io)
{
Expand Down
10 changes: 8 additions & 2 deletions tests/TestCase/Console/CommandTest.php
Expand Up @@ -134,7 +134,10 @@ public function testRunOutputHelp()
$command->setName('cake example');
$output = new ConsoleOutput();

$this->assertNull($command->run(['-h'], $this->getMockIo($output)));
$this->assertSame(
Command::CODE_SUCCESS,
$command->run(['-h'], $this->getMockIo($output))
);
$messages = implode("\n", $output->messages());
$this->assertNotContains('Example', $messages);
$this->assertContains('cake example [-h]', $messages);
Expand All @@ -151,7 +154,10 @@ public function testRunOutputHelpLongOption()
$command->setName('cake example');
$output = new ConsoleOutput();

$this->assertNull($command->run(['--help'], $this->getMockIo($output)));
$this->assertSame(
Command::CODE_SUCCESS,
$command->run(['--help'], $this->getMockIo($output))
);
$messages = implode("\n", $output->messages());
$this->assertNotContains('Example', $messages);
$this->assertContains('cake example [-h]', $messages);
Expand Down

0 comments on commit 1a0c868

Please sign in to comment.