minor #14179 [Debug] Made code in ErrorHandler easier to read (lyrixx)

This PR was merged into the 2.6 branch.

Discussion
----------

[Debug] Made code in ErrorHandler easier to read

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

Commits
-------

15ef182 [Debug] Made code in ErrorHandler easier to read
This commit is contained in:
Nicolas Grekas 2015-04-02 20:01:15 +02:00
commit dec2ac917e

View File

@ -356,7 +356,10 @@ class ErrorHandler
$throw = $this->thrownErrors & $type & $level; $throw = $this->thrownErrors & $type & $level;
$type &= $level | $this->screamedErrors; $type &= $level | $this->screamedErrors;
if ($type && ($log || $throw)) { if (!$type || (!$log && !$throw)) {
return $type && $log;
}
if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && ($this->scopedErrors & $type)) { if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && ($this->scopedErrors & $type)) {
$e = $context; // Whatever the signature of the method, $e = $context; // Whatever the signature of the method,
unset($e['GLOBALS'], $context); // $context is always a reference in 5.3 unset($e['GLOBALS'], $context); // $context is always a reference in 5.3
@ -420,7 +423,6 @@ class ErrorHandler
throw $e; throw $e;
} }
} }
}
return $type && $log; return $type && $log;
} }
@ -487,10 +489,15 @@ class ErrorHandler
public static function handleFatalError(array $error = null) public static function handleFatalError(array $error = null)
{ {
self::$reservedMemory = ''; self::$reservedMemory = '';
$handler = set_error_handler('var_dump', 0); $handler = set_error_handler('var_dump', 0);
$handler = is_array($handler) ? $handler[0] : null; $handler = is_array($handler) ? $handler[0] : null;
restore_error_handler(); restore_error_handler();
if ($handler instanceof self) {
if (!$handler instanceof self) {
return;
}
if (null === $error) { if (null === $error) {
$error = error_get_last(); $error = error_get_last();
} }
@ -522,7 +529,6 @@ class ErrorHandler
// Ignore this re-throw // Ignore this re-throw
} }
} }
}
/** /**
* Configures the error handler for delayed handling. * Configures the error handler for delayed handling.