From 276a25de924a1338e9a429242ebe968de3644b6a Mon Sep 17 00:00:00 2001 From: robchett Date: Mon, 9 Oct 2023 22:11:00 +0100 Subject: [PATCH] Fix falsable issues with json_encode --- src/Psalm/Internal/LanguageServer/LanguageClient.php | 2 +- src/Psalm/Internal/LanguageServer/LanguageServer.php | 2 +- tests/Internal/Codebase/InternalCallMapHandlerTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/LanguageServer/LanguageClient.php b/src/Psalm/Internal/LanguageServer/LanguageClient.php index cd364ea36..8f403307e 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageClient.php +++ b/src/Psalm/Internal/LanguageServer/LanguageClient.php @@ -159,7 +159,7 @@ class LanguageClient } /** @var array */ - $array = json_decode(json_encode($config), true); + $array = json_decode((string) json_encode($config), true); if (isset($array['hideWarnings'])) { $this->clientConfiguration->hideWarnings = (bool) $array['hideWarnings']; diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php index fda64d762..50c70c3f5 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -843,7 +843,7 @@ class LanguageServer extends Dispatcher } if (!empty($context)) { - $message .= "\n" . json_encode($context, JSON_PRETTY_PRINT); + $message .= "\n" . (string) json_encode($context, JSON_PRETTY_PRINT); } try { $this->client->logMessage( diff --git a/tests/Internal/Codebase/InternalCallMapHandlerTest.php b/tests/Internal/Codebase/InternalCallMapHandlerTest.php index c92f79242..019c2484c 100644 --- a/tests/Internal/Codebase/InternalCallMapHandlerTest.php +++ b/tests/Internal/Codebase/InternalCallMapHandlerTest.php @@ -350,7 +350,7 @@ class InternalCallMapHandlerTest extends TestCase continue; } - yield "$function: " . json_encode($entry) => [$function, $entry]; + yield "$function: " . (string) json_encode($entry) => [$function, $entry]; } }