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

Skip to content

Commit 6b9180a

Browse files
committed
[Console] ensure exit code between 0-254
255 is reserved by PHP and should not be used also put this code inside the codeCoverageIgnore block because it cannot be tested with phpunit
1 parent 445b2e3 commit 6b9180a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,9 @@ public function run(InputInterface $input = null, OutputInterface $output = null
126126
}
127127

128128
if ($this->autoExit) {
129-
if ($statusCode > 255) {
130-
$statusCode = 255;
131-
}
129+
// ensure exit code is between 0-254 (255 is reserved by PHP and should not be used)
132130
// @codeCoverageIgnoreStart
133-
exit($statusCode);
131+
exit(max(0, min(254, $statusCode)));
134132
// @codeCoverageIgnoreEnd
135133
}
136134

0 commit comments

Comments
 (0)