From 2abefb9618cef118254c49d93c437835b85115a5 Mon Sep 17 00:00:00 2001 From: fluffycondor <7ionmail@gmail.com> Date: Fri, 10 Mar 2023 11:30:59 +0600 Subject: [PATCH 1/2] Return a non-empty-string with JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE --- stubs/CoreGenericFunctions.phpstub | 6 +++++- tests/CoreStubsTest.php | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/stubs/CoreGenericFunctions.phpstub b/stubs/CoreGenericFunctions.phpstub index f9640b065..4ad32c517 100644 --- a/stubs/CoreGenericFunctions.phpstub +++ b/stubs/CoreGenericFunctions.phpstub @@ -1467,7 +1467,11 @@ function json_decode(string $json, ?bool $associative = null, int $depth = 512, /** * @psalm-pure * - * @return ($flags is 4194304 ? non-empty-string : non-empty-string|false) + * @return ( + * $flags is 4194304 + * ? non-empty-string + * : ($flags is 4194560 ? non-empty-string : non-empty-string|false) + * ) * * @psalm-flow ($value) -> return * @psalm-ignore-falsable-return diff --git a/tests/CoreStubsTest.php b/tests/CoreStubsTest.php index 2205eea13..babc1cb41 100644 --- a/tests/CoreStubsTest.php +++ b/tests/CoreStubsTest.php @@ -123,5 +123,13 @@ class CoreStubsTest extends TestCase '$a===' => 'string', ], ]; + yield 'json_encode returns a non-empty-string provided JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE' => [ + 'code' => ' Date: Fri, 10 Mar 2023 11:44:53 +0600 Subject: [PATCH 2/2] Fix test --- tests/CoreStubsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CoreStubsTest.php b/tests/CoreStubsTest.php index babc1cb41..2ef09a1d8 100644 --- a/tests/CoreStubsTest.php +++ b/tests/CoreStubsTest.php @@ -125,11 +125,11 @@ class CoreStubsTest extends TestCase ]; yield 'json_encode returns a non-empty-string provided JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE' => [ 'code' => ' [ + '$a===' => 'non-empty-string', + ], ]; } }