Skip to content
Permalink
Browse files

bug #24951 [Console] Fixed exit code with non-integer throwable code …

…(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 033e7529ccbc8294d07664f1e0d503d0325ec645
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/Symfony/Component/Console/Event/ConsoleErrorEvent.php
@@ -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.
You can’t perform that action at this time.