Passed
Pull Request — master (#737)
by Vadim
08:14
created
src/Exceptions/views/partials/stacktrace.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 $vendorDir = dirname(dirname($vendorDir));
11 11
 $vendorID = null;
12 12
 $vendorCount = 0;
13
-foreach ($stacktrace as $index => $trace) {
13
+foreach ($stacktrace as $index => $trace){
14 14
     $args = [];
15
-    if (isset($trace['args'])) {
15
+    if (isset($trace['args'])){
16 16
         $args = $valueWrapper->wrap($trace['args']);
17 17
     }
18 18
 
19
-    $function = '<strong>' . $trace['function'] . '</strong>';
20
-    if (isset($trace['type']) && isset($trace['class'])) {
19
+    $function = '<strong>'.$trace['function'].'</strong>';
20
+    if (isset($trace['type']) && isset($trace['class'])){
21 21
         $reflection = new ReflectionClass($trace['class']);
22 22
         $function = sprintf(
23 23
             '<span title="%s">%s</span>%s%s',
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         );
29 29
     }
30 30
 
31
-    if (!isset($trace['file']) || !file_exists($trace['file'])) { ?>
31
+    if (!isset($trace['file']) || !file_exists($trace['file'])){ ?>
32 32
         <div class="container no-trace">
33 33
             <?= $function ?>(<span class="arguments"><?= implode(', ', $args) ?></span>)
34 34
         </div>
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
     }
38 38
 
39 39
     $isVendor = strpos($trace['file'], $vendorDir) === 0 && $index > 1;
40
-    if ($isVendor) {
41
-        if ($vendorID === null) {
40
+    if ($isVendor){
41
+        if ($vendorID === null){
42 42
             $vendorID = $index;
43 43
             $vendorCount++;
44 44
             echo sprintf('<span id="hidden-trace-%s" style="display: none;">', $vendorID);
45
-        } else {
45
+        }else{
46 46
             $vendorCount++;
47 47
         }
48
-    } elseif ($vendorID !== null) {
48
+    } elseif ($vendorID !== null){
49 49
         echo '</span>';
50 50
         echo sprintf(
51 51
             '<div id="%s" class="container" style="cursor: pointer;" onclick="toggle(\'%s\'); toggle(\'%s\');">&plus; %s vendor frame(s)...</div>',
52
-            'toggle-trace-' . $vendorID,
53
-            'toggle-trace-' . $vendorID,
54
-            'hidden-trace-' . $vendorID,
52
+            'toggle-trace-'.$vendorID,
53
+            'toggle-trace-'.$vendorID,
54
+            'hidden-trace-'.$vendorID,
55 55
             $vendorCount
56 56
         );
57 57
         $vendorID = null;
@@ -72,6 +72,6 @@  discard block
 block discarded – undo
72 72
     <?php
73 73
 }
74 74
 
75
-if ($vendorID !== null) {
75
+if ($vendorID !== null){
76 76
     echo '</span>';
77 77
 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,14 +10,17 @@  discard block
 block discarded – undo
10 10
 $vendorDir = dirname(dirname($vendorDir));
11 11
 $vendorID = null;
12 12
 $vendorCount = 0;
13
-foreach ($stacktrace as $index => $trace) {
13
+foreach ($stacktrace as $index => $trace)
14
+{
14 15
     $args = [];
15
-    if (isset($trace['args'])) {
16
+    if (isset($trace['args']))
17
+    {
16 18
         $args = $valueWrapper->wrap($trace['args']);
17 19
     }
18 20
 
19 21
     $function = '<strong>' . $trace['function'] . '</strong>';
20
-    if (isset($trace['type']) && isset($trace['class'])) {
22
+    if (isset($trace['type']) && isset($trace['class']))
23
+    {
21 24
         $reflection = new ReflectionClass($trace['class']);
22 25
         $function = sprintf(
23 26
             '<span title="%s">%s</span>%s%s',
@@ -28,7 +31,9 @@  discard block
 block discarded – undo
28 31
         );
29 32
     }
30 33
 
31
-    if (!isset($trace['file']) || !file_exists($trace['file'])) { ?>
34
+    if (!isset($trace['file']) || !file_exists($trace['file']))
35
+    {
36
+?>
32 37
         <div class="container no-trace">
33 38
             <?= $function ?>(<span class="arguments"><?= implode(', ', $args) ?></span>)
34 39
         </div>
@@ -37,15 +42,21 @@  discard block
 block discarded – undo
37 42
     }
38 43
 
39 44
     $isVendor = strpos($trace['file'], $vendorDir) === 0 && $index > 1;
40
-    if ($isVendor) {
41
-        if ($vendorID === null) {
45
+    if ($isVendor)
46
+    {
47
+        if ($vendorID === null)
48
+        {
42 49
             $vendorID = $index;
43 50
             $vendorCount++;
44 51
             echo sprintf('<span id="hidden-trace-%s" style="display: none;">', $vendorID);
45
-        } else {
52
+        }
53
+        else
54
+        {
46 55
             $vendorCount++;
47 56
         }
48
-    } elseif ($vendorID !== null) {
57
+    }
58
+    elseif ($vendorID !== null)
59
+    {
49 60
         echo '</span>';
50 61
         echo sprintf(
51 62
             '<div id="%s" class="container" style="cursor: pointer;" onclick="toggle(\'%s\'); toggle(\'%s\');">&plus; %s vendor frame(s)...</div>',
@@ -72,6 +83,7 @@  discard block
 block discarded – undo
72 83
     <?php
73 84
 }
74 85
 
75
-if ($vendorID !== null) {
86
+if ($vendorID !== null)
87
+{
76 88
     echo '</span>';
77 89
 }
Please login to merge, or discard this patch.
src/Prototype/tests/Traverse/ConstructorParamsVisitor.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@
 block discarded – undo
24 24
      */
25 25
     public function leaveNode(Node $node): void
26 26
     {
27
-        if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') {
28
-            foreach ($node->params as $param) {
29
-                if ($param->type instanceof Node\NullableType) {
30
-                    if ($param->type->type instanceof Node\Identifier) {
27
+        if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct'){
28
+            foreach ($node->params as $param){
29
+                if ($param->type instanceof Node\NullableType){
30
+                    if ($param->type->type instanceof Node\Identifier){
31 31
                         $type = $param->type->type->name;
32
-                    } else {
32
+                    }else{
33 33
                         $type = implode('\\', $param->type->type->parts);
34 34
                     }
35 35
 
36 36
                     $type = "?$type";
37
-                } elseif ($param->type instanceof Node\Name) {
37
+                } elseif ($param->type instanceof Node\Name){
38 38
                     $type = implode('\\', $param->type->parts);
39
-                } else {
39
+                }else{
40 40
                     $type = $param->type->name ?? null;
41 41
                 }
42 42
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,19 +24,29 @@
 block discarded – undo
24 24
      */
25 25
     public function leaveNode(Node $node): void
26 26
     {
27
-        if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct') {
28
-            foreach ($node->params as $param) {
29
-                if ($param->type instanceof Node\NullableType) {
30
-                    if ($param->type->type instanceof Node\Identifier) {
27
+        if ($node instanceof Node\Stmt\ClassMethod && $node->name->name === '__construct')
28
+        {
29
+            foreach ($node->params as $param)
30
+            {
31
+                if ($param->type instanceof Node\NullableType)
32
+                {
33
+                    if ($param->type->type instanceof Node\Identifier)
34
+                    {
31 35
                         $type = $param->type->type->name;
32
-                    } else {
36
+                    }
37
+                    else
38
+                    {
33 39
                         $type = implode('\\', $param->type->type->parts);
34 40
                     }
35 41
 
36 42
                     $type = "?$type";
37
-                } elseif ($param->type instanceof Node\Name) {
43
+                }
44
+                elseif ($param->type instanceof Node\Name)
45
+                {
38 46
                     $type = implode('\\', $param->type->parts);
39
-                } else {
47
+                }
48
+                else
49
+                {
40 50
                     $type = $param->type->name ?? null;
41 51
                 }
42 52
 
Please login to merge, or discard this patch.
src/Prototype/src/Annotation/Parser.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $lines = explode("\n", $comment);
28 28
 
29
-        foreach ($lines as $line) {
29
+        foreach ($lines as $line){
30 30
             // strip up comment prefix
31 31
             $line = preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line);
32 32
 
33
-            if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) {
33
+            if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)){
34 34
                 $this->lines[] = new Line($matches[2], $matches[1]);
35
-            } else {
35
+            }else{
36 36
                 $this->lines[] = new Line($line);
37 37
             }
38 38
         }
39 39
 
40
-        if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) {
40
+        if (isset($this->lines[0]) && $this->lines[0]->isEmpty()){
41 41
             array_shift($this->lines);
42 42
         }
43 43
 
44
-        if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()) {
44
+        if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()){
45 45
             array_pop($this->lines);
46 46
         }
47 47
     }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         $result[] = '/**';
56 56
 
57 57
         // skip first and last tokens
58
-        foreach ($this->lines as $line) {
59
-            if ($line->type === null) {
58
+        foreach ($this->lines as $line){
59
+            if ($line->type === null){
60 60
                 $result[] = sprintf(' * %s', $line->value);
61 61
                 continue;
62 62
             }
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,22 +26,28 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $lines = explode("\n", $comment);
28 28
 
29
-        foreach ($lines as $line) {
29
+        foreach ($lines as $line)
30
+        {
30 31
             // strip up comment prefix
31 32
             $line = preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line);
32 33
 
33
-            if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) {
34
+            if (preg_match('/ *@([^ ]+) (.*)/u', $line, $matches))
35
+            {
34 36
                 $this->lines[] = new Line($matches[2], $matches[1]);
35
-            } else {
37
+            }
38
+            else
39
+            {
36 40
                 $this->lines[] = new Line($line);
37 41
             }
38 42
         }
39 43
 
40
-        if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) {
44
+        if (isset($this->lines[0]) && $this->lines[0]->isEmpty())
45
+        {
41 46
             array_shift($this->lines);
42 47
         }
43 48
 
44
-        if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty()) {
49
+        if (isset($this->lines[count($this->lines) - 1]) && $this->lines[count($this->lines) - 1]->isEmpty())
50
+        {
45 51
             array_pop($this->lines);
46 52
         }
47 53
     }
@@ -55,8 +61,10 @@  discard block
 block discarded – undo
55 61
         $result[] = '/**';
56 62
 
57 63
         // skip first and last tokens
58
-        foreach ($this->lines as $line) {
59
-            if ($line->type === null) {
64
+        foreach ($this->lines as $line)
65
+        {
66
+            if ($line->type === null)
67
+            {
60 68
                 $result[] = sprintf(' * %s', $line->value);
61 69
                 continue;
62 70
             }
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/ClassNode/DeclareClass.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@
 block discarded – undo
26 26
      */
27 27
     public function enterNode(Node $node)
28 28
     {
29
-        if ($node instanceof Node\Stmt\Namespace_) {
29
+        if ($node instanceof Node\Stmt\Namespace_){
30 30
             $this->namespace = implode('\\', $node->name->parts);
31 31
         }
32 32
 
33
-        if ($node instanceof Node\Stmt\Class_) {
33
+        if ($node instanceof Node\Stmt\Class_){
34 34
             $this->class = $node->name->name;
35 35
 
36 36
             return NodeTraverser::STOP_TRAVERSAL;
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,11 +26,13 @@
 block discarded – undo
26 26
      */
27 27
     public function enterNode(Node $node)
28 28
     {
29
-        if ($node instanceof Node\Stmt\Namespace_) {
29
+        if ($node instanceof Node\Stmt\Namespace_)
30
+        {
30 31
             $this->namespace = implode('\\', $node->name->parts);
31 32
         }
32 33
 
33
-        if ($node instanceof Node\Stmt\Class_) {
34
+        if ($node instanceof Node\Stmt\Class_)
35
+        {
34 36
             $this->class = $node->name->name;
35 37
 
36 38
             return NodeTraverser::STOP_TRAVERSAL;
Please login to merge, or discard this patch.
src/Prototype/src/NodeVisitors/RemoveTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,26 +28,26 @@
 block discarded – undo
28 28
      */
29 29
     public function leaveNode(Node $node)
30 30
     {
31
-        if (!$node instanceof Node\Stmt\TraitUse) {
31
+        if (!$node instanceof Node\Stmt\TraitUse){
32 32
             return null;
33 33
         }
34 34
 
35
-        foreach ($node->traits as $index => $use) {
36
-            if ($use instanceof Node\Name) {
35
+        foreach ($node->traits as $index => $use){
36
+            if ($use instanceof Node\Name){
37 37
                 $name = $this->trimSlashes(implode('\\', $use->parts));
38 38
                 if (
39 39
                     in_array($name, [
40 40
                         $this->trimSlashes(PrototypeTrait::class),
41 41
                         Utils::shortName(PrototypeTrait::class),
42 42
                     ], true)
43
-                ) {
43
+                ){
44 44
                     unset($node->traits[$index]);
45 45
                 }
46 46
             }
47 47
         }
48 48
 
49 49
         $node->traits = array_values($node->traits);
50
-        if (empty($node->traits)) {
50
+        if (empty($node->traits)){
51 51
             return NodeTraverser::REMOVE_NODE;
52 52
         }
53 53
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,12 +28,15 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function leaveNode(Node $node)
30 30
     {
31
-        if (!$node instanceof Node\Stmt\TraitUse) {
31
+        if (!$node instanceof Node\Stmt\TraitUse)
32
+        {
32 33
             return null;
33 34
         }
34 35
 
35
-        foreach ($node->traits as $index => $use) {
36
-            if ($use instanceof Node\Name) {
36
+        foreach ($node->traits as $index => $use)
37
+        {
38
+            if ($use instanceof Node\Name)
39
+            {
37 40
                 $name = $this->trimSlashes(implode('\\', $use->parts));
38 41
                 if (
39 42
                     in_array($name, [
@@ -47,7 +50,8 @@  discard block
 block discarded – undo
47 50
         }
48 51
 
49 52
         $node->traits = array_values($node->traits);
50
-        if (empty($node->traits)) {
53
+        if (empty($node->traits))
54
+        {
51 55
             return NodeTraverser::REMOVE_NODE;
52 56
         }
53 57
 
Please login to merge, or discard this patch.
monorepo-builder.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
  *
11 11
  * @see https://github.com/symplify/symplify/issues/2061
12 12
  */
13
-\register_shutdown_function(static function () {
14
-    $dest = \json_decode(\file_get_contents(__DIR__ . '/composer.json'), true);
13
+\register_shutdown_function(static function (){
14
+    $dest = \json_decode(\file_get_contents(__DIR__.'/composer.json'), true);
15 15
 
16 16
     $result = [
17 17
         'name'              => 'spiral/framework',
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
     $json = \json_encode($result, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES);
48 48
 
49
-    \file_put_contents(__DIR__ . '/composer.json', $json . "\n");
49
+    \file_put_contents(__DIR__.'/composer.json', $json."\n");
50 50
 });
51 51
 
52 52
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
  *
11 11
  * @see https://github.com/symplify/symplify/issues/2061
12 12
  */
13
-\register_shutdown_function(static function () {
13
+\register_shutdown_function(static function ()
14
+{
14 15
     $dest = \json_decode(\file_get_contents(__DIR__ . '/composer.json'), true);
15 16
 
16 17
     $result = [
Please login to merge, or discard this patch.
src/Streams/tests/StreamsTest.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 class StreamsTest extends TestCase
19 19
 {
20
-    private const FIXTURE_DIRECTORY = __DIR__ . '/fixtures';
20
+    private const FIXTURE_DIRECTORY = __DIR__.'/fixtures';
21 21
 
22 22
     public function setUp(): void
23 23
     {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $this->assertSame(strlen('sample text'), filesize($filename));
43 43
         $this->assertSame(md5('sample text'), md5_file($filename));
44 44
 
45
-        $newFilename = self::FIXTURE_DIRECTORY . '/test.txt';
45
+        $newFilename = self::FIXTURE_DIRECTORY.'/test.txt';
46 46
         copy($filename, $newFilename);
47 47
 
48 48
         $this->assertFileExists($newFilename);
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function testException()
85 85
     {
86
-        try {
86
+        try{
87 87
             fopen('spiral://non-exists', 'rb');
88
-        } catch (\Throwable $e) {
88
+        }catch (\Throwable $e){
89 89
             $this->assertStringContainsString('failed to open stream', $e->getMessage());
90 90
         }
91 91
 
92
-        try {
92
+        try{
93 93
             filemtime('spiral://non-exists');
94
-        } catch (\Throwable $e) {
94
+        }catch (\Throwable $e){
95 95
             $this->assertStringContainsString('stat failed', $e->getMessage());
96 96
         }
97 97
     }
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function testExceptionPHP8()
103 103
     {
104
-        try {
104
+        try{
105 105
             fopen('spiral://non-exists', 'rb');
106
-        } catch (\Throwable $e) {
106
+        }catch (\Throwable $e){
107 107
             $this->assertStringContainsString('Failed to open stream', $e->getMessage());
108 108
         }
109 109
 
110
-        try {
110
+        try{
111 111
             filemtime('spiral://non-exists');
112
-        } catch (\Throwable $e) {
112
+        }catch (\Throwable $e){
113 113
             $this->assertStringContainsString('stat failed', $e->getMessage());
114 114
         }
115 115
     }
Please login to merge, or discard this patch.
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -83,15 +83,21 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function testException()
85 85
     {
86
-        try {
86
+        try
87
+        {
87 88
             fopen('spiral://non-exists', 'rb');
88
-        } catch (\Throwable $e) {
89
+        }
90
+        catch (\Throwable $e)
91
+        {
89 92
             $this->assertStringContainsString('failed to open stream', $e->getMessage());
90 93
         }
91 94
 
92
-        try {
95
+        try
96
+        {
93 97
             filemtime('spiral://non-exists');
94
-        } catch (\Throwable $e) {
98
+        }
99
+        catch (\Throwable $e)
100
+        {
95 101
             $this->assertStringContainsString('stat failed', $e->getMessage());
96 102
         }
97 103
     }
@@ -101,15 +107,21 @@  discard block
 block discarded – undo
101 107
      */
102 108
     public function testExceptionPHP8()
103 109
     {
104
-        try {
110
+        try
111
+        {
105 112
             fopen('spiral://non-exists', 'rb');
106
-        } catch (\Throwable $e) {
113
+        }
114
+        catch (\Throwable $e)
115
+        {
107 116
             $this->assertStringContainsString('Failed to open stream', $e->getMessage());
108 117
         }
109 118
 
110
-        try {
119
+        try
120
+        {
111 121
             filemtime('spiral://non-exists');
112
-        } catch (\Throwable $e) {
122
+        }
123
+        catch (\Throwable $e)
124
+        {
113 125
             $this->assertStringContainsString('stat failed', $e->getMessage());
114 126
         }
115 127
     }
Please login to merge, or discard this patch.
src/SendIt/src/MessageSerializer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@
 block discarded – undo
51 51
     public static function unpack(array $payload): MessageInterface
52 52
     {
53 53
         $message = new Message($payload['subject'], $payload['to'], $payload['data']);
54
-        if ($payload['from'] !== null) {
54
+        if ($payload['from'] !== null){
55 55
             $message->setFrom($payload['from']);
56 56
         }
57 57
 
58
-        if ($payload['replyTo'] !== null) {
58
+        if ($payload['replyTo'] !== null){
59 59
             $message->setReplyTo($payload['replyTo']);
60 60
         }
61 61
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@
 block discarded – undo
51 51
     public static function unpack(array $payload): MessageInterface
52 52
     {
53 53
         $message = new Message($payload['subject'], $payload['to'], $payload['data']);
54
-        if ($payload['from'] !== null) {
54
+        if ($payload['from'] !== null)
55
+        {
55 56
             $message->setFrom($payload['from']);
56 57
         }
57 58
 
58
-        if ($payload['replyTo'] !== null) {
59
+        if ($payload['replyTo'] !== null)
60
+        {
59 61
             $message->setReplyTo($payload['replyTo']);
60 62
         }
61 63
 
Please login to merge, or discard this patch.
src/Reactor/src/Serializer.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function serialize($value): string
37 37
     {
38
-        if (is_array($value)) {
38
+        if (is_array($value)){
39 39
             return $this->packArray($value);
40 40
         }
41 41
 
@@ -50,49 +50,49 @@  discard block
 block discarded – undo
50 50
      */
51 51
     protected function packArray(array $array, int $level = 0): string
52 52
     {
53
-        if ($array === []) {
53
+        if ($array === []){
54 54
             return '[]';
55 55
         }
56 56
         //Delimiters between rows and sub-arrays.
57
-        $subIndent = "\n" . str_repeat(self::INDENT, $level + 2);
58
-        $keyIndent = "\n" . str_repeat(self::INDENT, $level + 1);
57
+        $subIndent = "\n".str_repeat(self::INDENT, $level + 2);
58
+        $keyIndent = "\n".str_repeat(self::INDENT, $level + 1);
59 59
         //No keys for associated array
60 60
         $associated = array_diff_key($array, array_keys(array_keys($array)));
61 61
         $result = [];
62 62
         $innerIndent = 0;
63
-        if (!empty($associated)) {
64
-            foreach ($array as $key => $_) {
63
+        if (!empty($associated)){
64
+            foreach ($array as $key => $_){
65 65
                 //Based on biggest key length
66 66
                 $innerIndent = max(strlen(var_export($key, true)), $innerIndent);
67 67
             }
68 68
         }
69
-        foreach ($array as $key => $value) {
69
+        foreach ($array as $key => $value){
70 70
             $prefix = '';
71
-            if (!empty($associated)) {
71
+            if (!empty($associated)){
72 72
                 //Key prefix
73 73
                 $prefix = str_pad(
74 74
                     var_export($key, true),
75 75
                     $innerIndent,
76 76
                     ' ',
77 77
                     STR_PAD_RIGHT
78
-                ) . ' => ';
78
+                ).' => ';
79 79
             }
80
-            if (!is_array($value)) {
81
-                $result[] = $prefix . $this->packValue($value);
80
+            if (!is_array($value)){
81
+                $result[] = $prefix.$this->packValue($value);
82 82
                 continue;
83 83
             }
84
-            if ($value === []) {
85
-                $result[] = $prefix . '[]';
84
+            if ($value === []){
85
+                $result[] = $prefix.'[]';
86 86
                 continue;
87 87
             }
88 88
             $subArray = $this->packArray($value, $level + 1);
89
-            $result[] = $prefix . "[{$subIndent}" . $subArray . "{$keyIndent}]";
89
+            $result[] = $prefix."[{$subIndent}".$subArray."{$keyIndent}]";
90 90
         }
91
-        if ($level !== 0) {
91
+        if ($level !== 0){
92 92
             return $result ? implode(",{$keyIndent}", $result) : '';
93 93
         }
94 94
 
95
-        return "[{$keyIndent}" . implode(",{$keyIndent}", $result) . "\n]";
95
+        return "[{$keyIndent}".implode(",{$keyIndent}", $result)."\n]";
96 96
     }
97 97
 
98 98
     /**
@@ -105,31 +105,31 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function packValue($value): string
107 107
     {
108
-        if ($value instanceof DeclarationInterface) {
108
+        if ($value instanceof DeclarationInterface){
109 109
             //No indentation here
110 110
             return $value->render();
111 111
         }
112 112
 
113
-        if ($value === null) {
113
+        if ($value === null){
114 114
             return 'null';
115 115
         }
116 116
 
117
-        if (is_bool($value)) {
117
+        if (is_bool($value)){
118 118
             return ($value ? 'true' : 'false');
119 119
         }
120 120
 
121
-        if (is_object($value) && method_exists($value, '__set_state')) {
122
-            return '\\' . var_export($value, true);
121
+        if (is_object($value) && method_exists($value, '__set_state')){
122
+            return '\\'.var_export($value, true);
123 123
         }
124 124
 
125
-        if (!is_string($value) && !is_numeric($value)) {
125
+        if (!is_string($value) && !is_numeric($value)){
126 126
             throw new SerializeException('Unable to pack non scalar value');
127 127
         }
128 128
 
129
-        if (is_string($value) && class_exists($value)) {
129
+        if (is_string($value) && class_exists($value)){
130 130
             $reflection = new ReflectionClass($value);
131
-            if ($value === $reflection->getName()) {
132
-                return '\\' . $reflection->getName() . '::class';
131
+            if ($value === $reflection->getName()){
132
+                return '\\'.$reflection->getName().'::class';
133 133
             }
134 134
         }
135 135
 
Please login to merge, or discard this patch.
Braces   +32 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function serialize($value): string
37 37
     {
38
-        if (is_array($value)) {
38
+        if (is_array($value))
39
+        {
39 40
             return $this->packArray($value);
40 41
         }
41 42
 
@@ -50,7 +51,8 @@  discard block
 block discarded – undo
50 51
      */
51 52
     protected function packArray(array $array, int $level = 0): string
52 53
     {
53
-        if ($array === []) {
54
+        if ($array === [])
55
+        {
54 56
             return '[]';
55 57
         }
56 58
         //Delimiters between rows and sub-arrays.
@@ -60,15 +62,19 @@  discard block
 block discarded – undo
60 62
         $associated = array_diff_key($array, array_keys(array_keys($array)));
61 63
         $result = [];
62 64
         $innerIndent = 0;
63
-        if (!empty($associated)) {
64
-            foreach ($array as $key => $_) {
65
+        if (!empty($associated))
66
+        {
67
+            foreach ($array as $key => $_)
68
+            {
65 69
                 //Based on biggest key length
66 70
                 $innerIndent = max(strlen(var_export($key, true)), $innerIndent);
67 71
             }
68 72
         }
69
-        foreach ($array as $key => $value) {
73
+        foreach ($array as $key => $value)
74
+        {
70 75
             $prefix = '';
71
-            if (!empty($associated)) {
76
+            if (!empty($associated))
77
+            {
72 78
                 //Key prefix
73 79
                 $prefix = str_pad(
74 80
                     var_export($key, true),
@@ -77,18 +83,21 @@  discard block
 block discarded – undo
77 83
                     STR_PAD_RIGHT
78 84
                 ) . ' => ';
79 85
             }
80
-            if (!is_array($value)) {
86
+            if (!is_array($value))
87
+            {
81 88
                 $result[] = $prefix . $this->packValue($value);
82 89
                 continue;
83 90
             }
84
-            if ($value === []) {
91
+            if ($value === [])
92
+            {
85 93
                 $result[] = $prefix . '[]';
86 94
                 continue;
87 95
             }
88 96
             $subArray = $this->packArray($value, $level + 1);
89 97
             $result[] = $prefix . "[{$subIndent}" . $subArray . "{$keyIndent}]";
90 98
         }
91
-        if ($level !== 0) {
99
+        if ($level !== 0)
100
+        {
92 101
             return $result ? implode(",{$keyIndent}", $result) : '';
93 102
         }
94 103
 
@@ -105,30 +114,37 @@  discard block
 block discarded – undo
105 114
      */
106 115
     protected function packValue($value): string
107 116
     {
108
-        if ($value instanceof DeclarationInterface) {
117
+        if ($value instanceof DeclarationInterface)
118
+        {
109 119
             //No indentation here
110 120
             return $value->render();
111 121
         }
112 122
 
113
-        if ($value === null) {
123
+        if ($value === null)
124
+        {
114 125
             return 'null';
115 126
         }
116 127
 
117
-        if (is_bool($value)) {
128
+        if (is_bool($value))
129
+        {
118 130
             return ($value ? 'true' : 'false');
119 131
         }
120 132
 
121
-        if (is_object($value) && method_exists($value, '__set_state')) {
133
+        if (is_object($value) && method_exists($value, '__set_state'))
134
+        {
122 135
             return '\\' . var_export($value, true);
123 136
         }
124 137
 
125
-        if (!is_string($value) && !is_numeric($value)) {
138
+        if (!is_string($value) && !is_numeric($value))
139
+        {
126 140
             throw new SerializeException('Unable to pack non scalar value');
127 141
         }
128 142
 
129
-        if (is_string($value) && class_exists($value)) {
143
+        if (is_string($value) && class_exists($value))
144
+        {
130 145
             $reflection = new ReflectionClass($value);
131
-            if ($value === $reflection->getName()) {
146
+            if ($value === $reflection->getName())
147
+            {
132 148
                 return '\\' . $reflection->getName() . '::class';
133 149
             }
134 150
         }
Please login to merge, or discard this patch.