@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | private readonly ConfiguratorInterface $config, |
33 | 33 | private readonly ContainerInterface $container, |
34 | 34 | private readonly FactoryInterface $factory |
35 | - ) { |
|
35 | + ){ |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function init(EnvironmentInterface $env): void |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'json' => new JsonSerializer(), |
59 | 59 | 'serializer' => new PhpSerializer(), |
60 | 60 | ]; |
61 | - if (\class_exists(Message::class)) { |
|
61 | + if (\class_exists(Message::class)){ |
|
62 | 62 | $serializers['proto'] = new ProtoSerializer(); |
63 | 63 | } |
64 | 64 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @throws \Psr\Container\ContainerExceptionInterface |
73 | 73 | * @throws \Psr\Container\NotFoundExceptionInterface |
74 | 74 | */ |
75 | - private function wire(string|Autowire|SerializerInterface $serializer): SerializerInterface |
|
75 | + private function wire(string | Autowire | SerializerInterface $serializer): SerializerInterface |
|
76 | 76 | { |
77 | 77 | return match (true) { |
78 | 78 | $serializer instanceof SerializerInterface => $serializer, |
@@ -58,7 +58,8 @@ |
||
58 | 58 | 'json' => new JsonSerializer(), |
59 | 59 | 'serializer' => new PhpSerializer(), |
60 | 60 | ]; |
61 | - if (\class_exists(Message::class)) { |
|
61 | + if (\class_exists(Message::class)) |
|
62 | + { |
|
62 | 63 | $serializers['proto'] = new ProtoSerializer(); |
63 | 64 | } |
64 | 65 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * @type string $url |
28 | 28 | * } |
29 | 29 | */ |
30 | - public function __construct($data = NULL) { |
|
30 | + public function __construct($data = NULL){ |
|
31 | 31 | \Spiral\Tests\Serializer\Fixture\GPBMetadata\Service::initOnce(); |
32 | 32 | parent::__construct($data); |
33 | 33 | } |
@@ -27,7 +27,8 @@ |
||
27 | 27 | * @type string $url |
28 | 28 | * } |
29 | 29 | */ |
30 | - public function __construct($data = NULL) { |
|
30 | + public function __construct($data = NULL) |
|
31 | + { |
|
31 | 32 | \Spiral\Tests\Serializer\Fixture\GPBMetadata\Service::initOnce(); |
32 | 33 | parent::__construct($data); |
33 | 34 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @type string $url |
28 | 28 | * } |
29 | 29 | */ |
30 | - public function __construct($data = NULL) { |
|
30 | + public function __construct($data = null) { |
|
31 | 31 | \Spiral\Tests\Serializer\Fixture\GPBMetadata\Service::initOnce(); |
32 | 32 | parent::__construct($data); |
33 | 33 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function setUrl($var) |
50 | 50 | { |
51 | - GPBUtil::checkString($var, True); |
|
51 | + GPBUtil::checkString($var, true); |
|
52 | 52 | $this->url = $var; |
53 | 53 | |
54 | 54 | return $this; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - if (!\class_exists(Message::class)) { |
|
17 | + if (!\class_exists(Message::class)){ |
|
18 | 18 | throw new SerializerException('Package `google/protobuf` is not installed.'); |
19 | 19 | } |
20 | 20 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @throws InvalidArgumentException |
24 | 24 | */ |
25 | - public function serialize(mixed $payload): string|\Stringable |
|
25 | + public function serialize(mixed $payload): string | \Stringable |
|
26 | 26 | { |
27 | - if (!$payload instanceof Message) { |
|
27 | + if (!$payload instanceof Message){ |
|
28 | 28 | throw new InvalidArgumentException(\sprintf( |
29 | 29 | 'Payload must be of type `%s`, received `%s`.', |
30 | 30 | Message::class, |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @throws UnserializeException |
40 | 40 | * @throws InvalidArgumentException |
41 | 41 | */ |
42 | - public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
|
42 | + public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed |
|
43 | 43 | { |
44 | - if (\is_object($type)) { |
|
44 | + if (\is_object($type)){ |
|
45 | 45 | $type = $type::class; |
46 | 46 | } |
47 | 47 | |
48 | - if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) { |
|
48 | + if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)){ |
|
49 | 49 | throw new InvalidArgumentException(\sprintf( |
50 | 50 | 'Parameter `$type` must be of type: `%s`, received `%s`.', |
51 | 51 | Message::class, |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | $object = new $type(); |
57 | 57 | |
58 | - try { |
|
59 | - $object->mergeFromString((string) $payload); |
|
60 | - } catch (\Throwable $e) { |
|
58 | + try{ |
|
59 | + $object->mergeFromString((string)$payload); |
|
60 | + }catch (\Throwable $e){ |
|
61 | 61 | throw new UnserializeException( |
62 | 62 | \sprintf('Failed to unserialize data: %s', $e->getMessage()), |
63 | 63 | $e->getCode(), |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - if (!\class_exists(Message::class)) { |
|
17 | + if (!\class_exists(Message::class)) |
|
18 | + { |
|
18 | 19 | throw new SerializerException('Package `google/protobuf` is not installed.'); |
19 | 20 | } |
20 | 21 | } |
@@ -24,7 +25,8 @@ discard block |
||
24 | 25 | */ |
25 | 26 | public function serialize(mixed $payload): string|\Stringable |
26 | 27 | { |
27 | - if (!$payload instanceof Message) { |
|
28 | + if (!$payload instanceof Message) |
|
29 | + { |
|
28 | 30 | throw new InvalidArgumentException(\sprintf( |
29 | 31 | 'Payload must be of type `%s`, received `%s`.', |
30 | 32 | Message::class, |
@@ -41,11 +43,13 @@ discard block |
||
41 | 43 | */ |
42 | 44 | public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
43 | 45 | { |
44 | - if (\is_object($type)) { |
|
46 | + if (\is_object($type)) |
|
47 | + { |
|
45 | 48 | $type = $type::class; |
46 | 49 | } |
47 | 50 | |
48 | - if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) { |
|
51 | + if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) |
|
52 | + { |
|
49 | 53 | throw new InvalidArgumentException(\sprintf( |
50 | 54 | 'Parameter `$type` must be of type: `%s`, received `%s`.', |
51 | 55 | Message::class, |
@@ -55,9 +59,12 @@ discard block |
||
55 | 59 | |
56 | 60 | $object = new $type(); |
57 | 61 | |
58 | - try { |
|
62 | + try |
|
63 | + { |
|
59 | 64 | $object->mergeFromString((string) $payload); |
60 | - } catch (\Throwable $e) { |
|
65 | + } |
|
66 | + catch (\Throwable $e) |
|
67 | + { |
|
61 | 68 | throw new UnserializeException( |
62 | 69 | \sprintf('Failed to unserialize data: %s', $e->getMessage()), |
63 | 70 | $e->getCode(), |