update to PHP-8.1
[m6w6/seekat] / lib / API / ContentType / Handler / Json.php
index d5b6a5847754246bf6591fd156e1df6f95f4630d..008e7e6ad3ee40c3b47bb749eece83f91d43720c 100644 (file)
@@ -9,11 +9,6 @@ use seekat\Exception\UnexpectedValueException;
 use function seekat\typeof;
 
 final class Json implements Handler {
 use function seekat\typeof;
 
 final class Json implements Handler {
-       /**
-        * @var int
-        */
-       private $flags;
-
        /**
         * @inheritdoc
         */
        /**
         * @inheritdoc
         */
@@ -24,14 +19,13 @@ final class Json implements Handler {
        /**
         * @param int $flags json_encode() flags
         */
        /**
         * @param int $flags json_encode() flags
         */
-       function __construct(int $flags = 0) {
-               $this->flags = $flags;
+       function __construct(private readonly int $flags = 0) {
        }
 
        /**
         * @inheritdoc
         */
        }
 
        /**
         * @inheritdoc
         */
-       function encode($data): Body {
+       function encode(mixed $data): Body {
                if (is_scalar($data)) {
                        $json = $data;
                } else {
                if (is_scalar($data)) {
                        $json = $data;
                } else {
@@ -49,7 +43,7 @@ final class Json implements Handler {
        /**
         * @inheritdoc
         */
        /**
         * @inheritdoc
         */
-       function decode(Body $body) {
+       function decode(Body $body) : mixed {
                $data = json_decode($body);
                if (!isset($data) && json_last_error()) {
                        throw new UnexpectedValueException("Could not decode JSON: ".
                $data = json_decode($body);
                if (!isset($data) && json_last_error()) {
                        throw new UnexpectedValueException("Could not decode JSON: ".