Passed
Push — master ( 72934f...dfb406 )
by Aleksei
05:59 queued 26s
created
src/Serializer/tests/Serializer/PhpSerializerTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
         $this->assertSame('a:2:{i:0;s:4:"some";i:1;s:8:"elements";}', $serializer->serialize(['some', 'elements']));
21 21
         $this->assertSame(['some', 'elements'], $serializer->unserialize('a:2:{i:0;s:4:"some";i:1;s:8:"elements";}'));
22
-        $this->assertSame(['some', 'elements'], $serializer->unserialize(new class() implements \Stringable {
22
+        $this->assertSame(['some', 'elements'], $serializer->unserialize(new class() implements \Stringable{
23 23
             public function __toString(): string
24 24
             {
25 25
                 return 'a:2:{i:0;s:4:"some";i:1;s:8:"elements";}';
Please login to merge, or discard this patch.
src/Serializer/tests/Serializer/JsonSerializerTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
         $this->assertSame('["some","elements"]', $serializer->serialize(['some', 'elements']));
19 19
         $this->assertSame(['some', 'elements'], $serializer->unserialize('["some","elements"]'));
20
-        $this->assertSame(['some', 'elements'], $serializer->unserialize(new class() implements \Stringable {
20
+        $this->assertSame(['some', 'elements'], $serializer->unserialize(new class() implements \Stringable{
21 21
             public function __toString(): string
22 22
             {
23 23
                 return '["some","elements"]';
Please login to merge, or discard this patch.
src/Serializer/src/Serializer/PhpSerializer.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@
 block discarded – undo
10 10
 
11 11
 final class PhpSerializer implements SerializerInterface
12 12
 {
13
-    public function serialize(mixed $payload): string|\Stringable
13
+    public function serialize(mixed $payload): string | \Stringable
14 14
     {
15 15
         return \serialize($payload);
16 16
     }
17 17
 
18
-    public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed
18
+    public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed
19 19
     {
20
-        if (\is_object($type)) {
20
+        if (\is_object($type)){
21 21
             $type = $type::class;
22 22
         }
23 23
 
24
-        if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)) {
24
+        if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)){
25 25
             throw new InvalidArgumentException(\sprintf('Class or interface `%s` doesn\'t exist.', $type));
26 26
         }
27 27
 
28 28
         return $this->runUnserialize($payload, $type);
29 29
     }
30 30
 
31
-    private function runUnserialize(\Stringable|string $payload, ?string $type = null): mixed
31
+    private function runUnserialize(\Stringable | string $payload, ?string $type = null): mixed
32 32
     {
33
-        $result = \unserialize((string) $payload, $type ? [] : ['allowed_classes' => false]);
33
+        $result = \unserialize((string)$payload, $type ? [] : ['allowed_classes' => false]);
34 34
 
35
-        if ($result === false) {
35
+        if ($result === false){
36 36
             throw new UnserializeException('Failed to unserialize data.');
37 37
         }
38 38
 
39
-        if ($type !== null && !$result instanceof $type) {
39
+        if ($type !== null && !$result instanceof $type){
40 40
             throw new InvalidArgumentException(\sprintf(
41 41
                 'Data received after unserializing must be of type: `%s`, received `%s`',
42 42
                 $type,
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,11 +17,13 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed
19 19
     {
20
-        if (\is_object($type)) {
20
+        if (\is_object($type))
21
+        {
21 22
             $type = $type::class;
22 23
         }
23 24
 
24
-        if (\is_string($type) && !\class_exists($type) && !\interface_exists($type)) {
25
+        if (\is_string($type) && !\class_exists($type) && !\interface_exists($type))
26
+        {
25 27
             throw new InvalidArgumentException(\sprintf('Class or interface `%s` doesn\'t exist.', $type));
26 28
         }
27 29
 
@@ -32,11 +34,13 @@  discard block
 block discarded – undo
32 34
     {
33 35
         $result = \unserialize((string) $payload, $type ? [] : ['allowed_classes' => false]);
34 36
 
35
-        if ($result === false) {
37
+        if ($result === false)
38
+        {
36 39
             throw new UnserializeException('Failed to unserialize data.');
37 40
         }
38 41
 
39
-        if ($type !== null && !$result instanceof $type) {
42
+        if ($type !== null && !$result instanceof $type)
43
+        {
40 44
             throw new InvalidArgumentException(\sprintf(
41 45
                 'Data received after unserializing must be of type: `%s`, received `%s`',
42 46
                 $type,
Please login to merge, or discard this patch.
src/Serializer/src/Serializer/CallbackSerializer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         return ($this->serializeCallback)($payload);
26 26
     }
27 27
 
28
-    public function unserialize(string|\Stringable $payload, string|object|null $type = null): mixed
28
+    public function unserialize(string | \Stringable $payload, string | object | null $type = null): mixed
29 29
     {
30 30
         return ($this->unserializeCallback)($payload, $type);
31 31
     }
Please login to merge, or discard this patch.
src/Serializer/src/Serializer/JsonSerializer.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @throws SerializeException
16 16
      */
17
-    public function serialize(mixed $payload): string|\Stringable
17
+    public function serialize(mixed $payload): string | \Stringable
18 18
     {
19
-        try {
19
+        try{
20 20
             return \json_encode($payload, JSON_THROW_ON_ERROR);
21
-        } catch (\JsonException $e) {
21
+        }catch (\JsonException $e){
22 22
             throw new SerializeException($e->getMessage(), $e->getCode(), $e);
23 23
         }
24 24
     }
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * @throws \JsonException
28 28
      */
29
-    public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed
29
+    public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed
30 30
     {
31
-        if ($type !== null) {
31
+        if ($type !== null){
32 32
             throw new InvalidArgumentException(
33 33
                 \sprintf('Serializer `%s` does not support data hydration to an object.', self::class)
34 34
             );
35 35
         }
36 36
 
37
-        try {
38
-            return \json_decode((string) $payload, true, 512, JSON_THROW_ON_ERROR);
39
-        } catch (\JsonException $e) {
37
+        try{
38
+            return \json_decode((string)$payload, true, 512, JSON_THROW_ON_ERROR);
39
+        }catch (\JsonException $e){
40 40
             throw new UnserializeException($e->getMessage(), $e->getCode(), $e);
41 41
         }
42 42
     }
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,9 +16,12 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function serialize(mixed $payload): string|\Stringable
18 18
     {
19
-        try {
19
+        try
20
+        {
20 21
             return \json_encode($payload, JSON_THROW_ON_ERROR);
21
-        } catch (\JsonException $e) {
22
+        }
23
+        catch (\JsonException $e)
24
+        {
22 25
             throw new SerializeException($e->getMessage(), $e->getCode(), $e);
23 26
         }
24 27
     }
@@ -28,15 +31,19 @@  discard block
 block discarded – undo
28 31
      */
29 32
     public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed
30 33
     {
31
-        if ($type !== null) {
34
+        if ($type !== null)
35
+        {
32 36
             throw new InvalidArgumentException(
33 37
                 \sprintf('Serializer `%s` does not support data hydration to an object.', self::class)
34 38
             );
35 39
         }
36 40
 
37
-        try {
41
+        try
42
+        {
38 43
             return \json_decode((string) $payload, true, 512, JSON_THROW_ON_ERROR);
39
-        } catch (\JsonException $e) {
44
+        }
45
+        catch (\JsonException $e)
46
+        {
40 47
             throw new UnserializeException($e->getMessage(), $e->getCode(), $e);
41 48
         }
42 49
     }
Please login to merge, or discard this patch.
src/Serializer/src/SerializerInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 interface SerializerInterface
8 8
 {
9
-    public function serialize(mixed $payload): string|\Stringable;
9
+    public function serialize(mixed $payload): string | \Stringable;
10 10
 
11
-    public function unserialize(string|\Stringable $payload, string|object|null $type = null): mixed;
11
+    public function unserialize(string | \Stringable $payload, string | object | null $type = null): mixed;
12 12
 }
Please login to merge, or discard this patch.
src/Serializer/src/SerializerManager.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     public function __construct(
10 10
         protected readonly SerializerRegistry $serializers,
11 11
         protected readonly string $defaultFormat
12
-    ) {
12
+    ){
13 13
     }
14 14
 
15 15
     public function getSerializer(string $format = null): SerializerInterface
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
         return $this->serializers->get($format ?? $this->defaultFormat);
18 18
     }
19 19
 
20
-    public function serialize(mixed $payload, ?string $format = null): string|\Stringable
20
+    public function serialize(mixed $payload, ?string $format = null): string | \Stringable
21 21
     {
22 22
         return $this->getSerializer($format ?? $this->defaultFormat)->serialize($payload);
23 23
     }
24 24
 
25 25
     public function unserialize(
26
-        string|\Stringable $payload,
27
-        string|object|null $type = null,
26
+        string | \Stringable $payload,
27
+        string | object | null $type = null,
28 28
         ?string $format = null
29 29
     ): mixed {
30 30
         return $this->getSerializer($format ?? $this->defaultFormat)->unserialize($payload, $type);
Please login to merge, or discard this patch.
src/Serializer/src/SerializerRegistry.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
     public function __construct(array $serializers = [])
15 15
     {
16
-        foreach ($serializers as $name => $serializer) {
16
+        foreach ($serializers as $name => $serializer){
17 17
             $this->register($name, $serializer);
18 18
         }
19 19
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@
 block discarded – undo
13 13
 
14 14
     public function __construct(array $serializers = [])
15 15
     {
16
-        foreach ($serializers as $name => $serializer) {
16
+        foreach ($serializers as $name => $serializer)
17
+        {
17 18
             $this->register($name, $serializer);
18 19
         }
19 20
     }
Please login to merge, or discard this patch.
src/Config/tests/fixtures/broken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-return ;
3
+return;
Please login to merge, or discard this patch.