Browse Source

Notices, Warnings, etc. now won't be thrown unless forking is possible

2.1.0
Dustin Wilson 1 year ago
parent
commit
cec5faf46a
  1. 13
      lib/Catcher.php

13
lib/Catcher.php

@ -166,15 +166,12 @@ class Catcher {
// that if the error wouldn't normally stop execution the newly-created Error // that if the error wouldn't normally stop execution the newly-created Error
// throwable is thrown in a fork instead, allowing execution to resume in the // throwable is thrown in a fork instead, allowing execution to resume in the
// parent process. // parent process.
if ( if (in_array($code, [ \E_ERROR, \E_PARSE, \E_CORE_ERROR, \E_COMPILE_ERROR, \E_USER_ERROR ])) {
$this->forking && throw $error;
\PHP_SAPI === 'cli' && } elseif ($this->forking && \PHP_SAPI === 'cli' && function_exists('pcntl_fork')) {
function_exists('pcntl_fork') &&
!in_array($code, [ \E_ERROR, \E_PARSE, \E_CORE_ERROR, \E_COMPILE_ERROR, \E_USER_ERROR ])
) {
$pid = pcntl_fork(); $pid = pcntl_fork();
if ($pid === -1) { if ($pid === -1) {
// This can't be covered unless I can somehow fake a misconfigured system // This can't be covered unless it is possible to fake a misconfigured system
throw new \Exception(message: 'Could not create fork to throw Error', previous: $error); // @codeCoverageIgnore throw new \Exception(message: 'Could not create fork to throw Error', previous: $error); // @codeCoverageIgnore
} elseif (!$pid) { } elseif (!$pid) {
// This can't be covered because it happens in the fork // This can't be covered because it happens in the fork
@ -183,8 +180,6 @@ class Catcher {
pcntl_wait($status); pcntl_wait($status);
return true; return true;
} else {
throw $error;
} }
} }

Loading…
Cancel
Save