From 02dcd321f5d055bf1cf0f795baebb09ba38a8a7c Mon Sep 17 00:00:00 2001 From: Mariano Custiel Date: Wed, 2 Jun 2021 10:09:57 +0200 Subject: [PATCH] Fix: Avoid array to string conversion for non-string body matchers --- src/Domain/Request.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Domain/Request.php b/src/Domain/Request.php index 36eaf7c..a02ba16 100644 --- a/src/Domain/Request.php +++ b/src/Domain/Request.php @@ -54,11 +54,18 @@ class Request implements \JsonSerializable public function __toString() { + if (isset($this->body)) { + $bodyValue = $this->body->getValue(); + if (!is_string($bodyValue)) { + $bodyValue = print_r($bodyValue, true); + } + } + return print_r( [ 'method' => $this->method, 'url' => isset($this->url) ? $this->url->__toString() : 'null', - 'body' => isset($this->body) ? $this->body->getMatcher() . ' => ' . (isset($this->body->getValue()[5000]) ? '--VERY LONG CONTENTS--' : $this->body->getValue()) : 'null', + 'body' => isset($this->body) ? $this->body->getMatcher() . ' => ' . (isset($bodyValue[5000]) ? '--VERY LONG CONTENTS--' : $bodyValue) : 'null', 'headers' => print_r($this->headers, true), ], true