From b983559980159ad9fe3eb481b4b98d36a75543da Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 1 Apr 2021 20:55:25 +0200 Subject: [PATCH] Fix Object parsing for Logging --- src/Util/Logger/AbstractLogger.php | 2 +- tests/src/Util/Logger/AbstractLoggerTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Util/Logger/AbstractLogger.php b/src/Util/Logger/AbstractLogger.php index bbd50d619e..a8aba34d34 100644 --- a/src/Util/Logger/AbstractLogger.php +++ b/src/Util/Logger/AbstractLogger.php @@ -115,7 +115,7 @@ abstract class AbstractLogger implements LoggerInterface $output = []; foreach ($input as $key => $value) { - if (method_exists($value, '__toString')) { + if (is_object($value) && method_exists($value, '__toString')) { $output[$key] = $value->__toString(); } else { $output[$key] = $value; diff --git a/tests/src/Util/Logger/AbstractLoggerTest.php b/tests/src/Util/Logger/AbstractLoggerTest.php index 3962333062..5c87d1cf41 100644 --- a/tests/src/Util/Logger/AbstractLoggerTest.php +++ b/tests/src/Util/Logger/AbstractLoggerTest.php @@ -178,4 +178,15 @@ abstract class AbstractLoggerTest extends MockedTest self::assertContains(@json_encode($assertion), $this->getContent()); } + + public function testNoObjectHandling() + { + $logger = $this->getInstance(); + $logger->alert('test', ['e' => ['test' => 'test']]); + $text = $this->getContent(); + + self::assertLogline($text); + + self::assertContains('test', $this->getContent()); + } }