From c2bb740be0f366fd8524dd09593e570ecc66c463 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 31 Mar 2017 11:10:11 +0200 Subject: [PATCH] Log deprecated (symfony) errors optionally --- src/LaravelDebugbar.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 5cf9e3dc..04b54404 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -124,6 +124,11 @@ public function boot() /** @var Application $app */ $app = $this->app; + + // Set custom error handler + if ($app['config']->get('debugbar.error_handler' , false)) { + set_error_handler([$this, 'handleError']); + } $this->selectStorage($debugbar); @@ -449,6 +454,25 @@ public function shouldCollect($name, $default = false) return $this->app['config']->get('debugbar.collectors.' . $name, $default); } + /** + * Handle silenced errors + * + * @param $level + * @param $message + * @param string $file + * @param int $line + * @param array $context + * @throws \ErrorException + */ + public function handleError($level, $message, $file = '', $line = 0, $context = []) + { + if (error_reporting() & $level) { + throw new \ErrorException($message, 0, $level, $file, $line); + } else { + $this->addMessage($message, 'deprecation'); + } + } + /** * Starts a measure *