From 88343a348a762643b5f57c21f7bd65f421ebb229 Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Sat, 13 Jan 2024 11:43:31 -0600 Subject: [PATCH] Improved check for output throwable time in PlainTextHandler --- lib/Catcher/PlainTextHandler.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Catcher/PlainTextHandler.php b/lib/Catcher/PlainTextHandler.php index a9bbaa5..d081963 100644 --- a/lib/Catcher/PlainTextHandler.php +++ b/lib/Catcher/PlainTextHandler.php @@ -67,8 +67,12 @@ class PlainTextHandler extends Handler { if (isset($frame['errorType'])) { $method = "{$frame['errorType']} ({$frame['class']})"; } elseif (isset($frame['function'])) { - $ref = new \ReflectionMethod($frame['class'], $frame['function']); - $method .= (($ref->isStatic()) ? '::' : '->') . $frame['function'] . '()'; + if (str_contains($frame['function'], '{closure}')) { + $method = "{$frame['function']}()"; + } else { + $ref = new \ReflectionMethod($frame['class'], $frame['function']); + $method .= (($ref->isStatic()) ? '::' : '->') . $frame['function'] . '()'; + } } } @@ -92,7 +96,7 @@ class PlainTextHandler extends Handler { $this->log($outputThrowable['controller']->getThrowable(), $output); } - if (!empty($outputThrowable['time'])) { + if (isset($outputThrowable['time']) && $outputThrowable['time'] instanceof \DateTimeInterface) { $timestamp = $outputThrowable['time']->format($this->_timeFormat) . ' '; $output = ltrim(preg_replace('/^(?=\h*\S)/m', str_repeat(' ', strlen($timestamp)), "$timestamp$output")); }