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()); + } }