@@ -283,17 +283,21 @@ private function testAndGetActualValue(array $value, string $json): string {
283283 );
284284 if (!is_string ($ actual )) {
285285 $ actual = json_encode ($ actual );
286+ Assert::assertIsString ($ actual );
286287 }
287288 return $ actual ;
288289 }
290+ $ responseAsJsonString = json_encode ($ realResponseArray );
291+ Assert::assertIsString ($ responseAsJsonString );
289292 Assert::assertArrayHasKey (
290293 $ value ['key ' ],
291294 $ realResponseArray ,
292- 'Not found: " ' . $ value ['key ' ] . '" at array: ' . json_encode ( $ realResponseArray )
295+ 'Not found: " ' . $ value ['key ' ] . '" at array: ' . $ responseAsJsonString
293296 );
294297 $ actual = $ realResponseArray [$ value ['key ' ]];
295298 if (!is_string ($ actual )) {
296299 $ actual = json_encode ($ actual );
300+ Assert::assertIsString ($ actual );
297301 }
298302 return $ actual ;
299303 }
@@ -327,7 +331,9 @@ public function fetchFieldFromPreviousJsonResponse(string $path): void {
327331 $ keys = explode ('. ' , $ path );
328332 $ value = $ responseArray ;
329333 foreach ($ keys as $ key ) {
330- Assert::assertArrayHasKey ($ key , $ value , 'Key [ ' . $ key . '] of path [ ' . $ path . '] not found at body: ' . json_encode ($ responseArray ));
334+ $ body = json_encode ($ responseArray );
335+ Assert::assertIsString ($ body );
336+ Assert::assertArrayHasKey ($ key , $ value , 'Key [ ' . $ key . '] of path [ ' . $ path . '] not found at body: ' . $ body );
331337 $ value = $ value [$ key ];
332338 }
333339 if (isset ($ alias )) {
@@ -419,7 +425,9 @@ private function parseTextRcursive(array &$array): array {
419425 $ value = $ this ->parseText ($ value );
420426 } elseif ($ value instanceof \stdClass) {
421427 $ value = (array ) $ value ;
422- $ value = json_decode (json_encode ($ this ->parseTextRcursive ($ value )));
428+ $ buffer = json_encode ($ this ->parseTextRcursive ($ value ));
429+ Assert::assertIsString ($ buffer );
430+ $ value = json_decode ($ buffer );
423431 }
424432 });
425433 return $ array ;
@@ -433,6 +441,7 @@ protected function parseText(string $text): string {
433441 $ replacements [] = $ value ;
434442 }
435443 $ text = preg_replace ($ patterns , $ replacements , $ text );
444+ Assert::assertIsString ($ text );
436445 return $ text ;
437446 }
438447
0 commit comments