Skip to content

Commit

Permalink
bug #24951 [Console] Fixed exit code with non-integer throwable code …
Browse files Browse the repository at this point in the history
…(wouterj)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Console] Fixed exit code with non-integer throwable code

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

The exception/error code in PHP doesn't have to be an integer:

 > Returns the exception code as integer in Exception but possibly as other type in Exception descendants (for example as string in PDOException).
> http://php.net/manual/en/exception.getcode.php#refsect1-exception.getcode-returnvalues

This means that a "Return value of Symfony\Component\Console\Event\ConsoleErrorEvent::getExitCode() must be of the type integer, string returned" error is shown when e.g. an uncatched PDOException is handled by the console error event.

Commits
-------

ca86e65 Fixed exit code with non-integer throwable code
  • Loading branch information
fabpot committed Dec 11, 2017
2 parents 29f86d4 + ca86e65 commit 033e752
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Event/ConsoleErrorEvent.php
Expand Up @@ -53,6 +53,6 @@ public function setExitCode(int $exitCode): void

public function getExitCode(): int
{
return null !== $this->exitCode ? $this->exitCode : ($this->error->getCode() ?: 1);
return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) ? $this->error->getCode() : 1);
}
}

0 comments on commit 033e752

Please sign in to comment.