Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[2.1][Console] Fixed return value for Command::run #5585

Merged
merged 1 commit into from

2 participants

@hason

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

API says that Command::run returns integer. This is also necessary if I want to run nested commands.

@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch hason/command (PR #5585)
Commits
-------

c869a65 [Console] Fixed return value for Command::run

Discussion
----------

[2.1][Console] Fixed return value for Command::run

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

API says that Command::run returns integer. This is also necessary if I want to run nested commands.
21d16e6
@fabpot fabpot merged commit c869a65 into symfony:2.1
@fabpot fabpot referenced this pull request from a commit
@fabpot fabpot merged branch hason/return_code (PR #5586)
This PR was squashed before being merged into the 2.1 branch (closes #5586).

Commits
-------

6b66bc3 [2.1] Added missing error return codes in commands

Discussion
----------

[2.1] Added missing error return codes in commands

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
See: #5585

---------------------------------------------------------------------------

by fabpot at 2012-09-24T12:10:47Z

Exit code values are standardized and some values have some well-defined meaning. Have a look here for more info: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Process/Process.php#L67
98070d5
@vicb vicb referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch hason/command (PR #5585)
Commits
-------

c869a65 [Console] Fixed return value for Command::run

Discussion
----------

[2.1][Console] Fixed return value for Command::run

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

API says that Command::run returns integer. This is also necessary if I want to run nested commands.
7543c66
@mmucklo mmucklo referenced this pull request from a commit
@fabpot fabpot merged branch hason/return_code (PR #5586)
This PR was squashed before being merged into the 2.1 branch (closes #5586).

Commits
-------

6b66bc3 [2.1] Added missing error return codes in commands

Discussion
----------

[2.1] Added missing error return codes in commands

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
See: #5585

---------------------------------------------------------------------------

by fabpot at 2012-09-24T12:10:47Z

Exit code values are standardized and some values have some well-defined meaning. Have a look here for more info: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Process/Process.php#L67
5640f2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 24, 2012
  1. @hason
This page is out of date. Refresh to see the latest.
View
8 src/Symfony/Component/Console/Command/Command.php
@@ -157,7 +157,7 @@ protected function configure()
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return integer 0 if everything went fine, or an error code
+ * @return null|integer null or 0 if everything went fine, or an error code
*
* @throws \LogicException When this abstract method is not implemented
* @see setCode()
@@ -233,10 +233,12 @@ public function run(InputInterface $input, OutputInterface $output)
$input->validate();
if ($this->code) {
- return call_user_func($this->code, $input, $output);
+ $statusCode = call_user_func($this->code, $input, $output);
+ } else {
+ $statusCode = $this->execute($input, $output);
}
- return $this->execute($input, $output);
+ return is_numeric($statusCode) ? $statusCode : 0;
}
/**
View
7 src/Symfony/Component/Console/Tests/Command/CommandTest.php
@@ -221,6 +221,13 @@ public function testRun()
}
}
+ public function testRunReturnsAlwaysInteger()
+ {
+ $command = new \TestCommand();
+
+ $this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
+ }
+
public function testSetCode()
{
$command = new \TestCommand();
Something went wrong with that request. Please try again.