File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,7 @@ public static function jsonDecode(string $input)
355
355
public static function jsonEncode (array $ input ): string
356
356
{
357
357
if (PHP_VERSION_ID >= 50400 ) {
358
- $ json = \json_encode ($ input , \JSON_UNESCAPED_SLASHES );
358
+ $ json = \json_encode ($ input , \JSON_UNESCAPED_SLASHES |\ JSON_FORCE_OBJECT );
359
359
} else {
360
360
// PHP 5.3 only
361
361
$ json = \json_encode ($ input );
Original file line number Diff line number Diff line change @@ -321,6 +321,15 @@ public function testRSEncodeDecodeWithPassphrase()
321
321
$ this ->assertEquals ($ decoded , $ expected );
322
322
}
323
323
324
+ public function testDecodesEmptyArrayAsObject ()
325
+ {
326
+ $ key = 'yma6Hq4XQegCVND8ef23OYgxSrC3IKqk ' ;
327
+ $ payload = [];
328
+ $ jwt = JWT ::encode ($ payload , $ key , 'HS256 ' );
329
+ $ decoded = JWT ::decode ($ jwt , new Key ($ key , 'HS256 ' ));
330
+ $ this ->assertEquals ((object ) $ payload , $ decoded );
331
+ }
332
+
324
333
/**
325
334
* @runInSeparateProcess
326
335
* @dataProvider provideEncodeDecode
You can’t perform that action at this time.
0 commit comments