Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 033e752

Browse files
committed
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
2 parents 29f86d4 + ca86e65 commit 033e752

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Console/Event/ConsoleErrorEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public function setExitCode(int $exitCode): void
5353

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

0 commit comments

Comments
 (0)