File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 22
33namespace Microwin7 \PHPUtils \Response ;
44
5+ use stdClass ;
6+
57class Response
68{
79 private static array $ data = [];
@@ -44,11 +46,11 @@ private static function header(): void
4446 }
4547 public static function json_encode (mixed $ data = null ): string
4648 {
47- return json_encode (( object ) null === $ data ?: self ::$ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION );
49+ return json_encode (null !== $ data ? $ data : (! empty ( self ::$ data) ? self :: $ data : new stdClass ) , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION );
4850 }
4951 public static function response (mixed $ data = null )
5052 {
5153 self ::header ();
52- die (self ::json_encode (( object ) null === $ data ?: self ::$ data ));
54+ die (self ::json_encode (null !== $ data ? $ data : (! empty ( self ::$ data) ? self :: $ data : new stdClass ) ));
5355 }
5456}
You can’t perform that action at this time.
0 commit comments