Passed
Pull Request — master (#1205)
by Aleksei
18:36 queued 06:28
created
src/Exceptions/src/Style/ConsoleStyle.php 2 patches
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,12 +87,14 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $style = $this->getStyle($token, $previous);
89 89
 
90
-        if (!\str_contains((string) $token[1], "\n")) {
90
+        if (!\str_contains((string) $token[1], "\n"))
91
+        {
91 92
             return \sprintf($this->templates['token'], $style, $token[1]);
92 93
         }
93 94
 
94 95
         $lines = [];
95
-        foreach (\explode("\n", (string) $token[1]) as $line) {
96
+        foreach (\explode("\n", (string) $token[1]) as $line)
97
+        {
96 98
             $lines[] = \sprintf($this->templates['token'], $style, $line);
97 99
         }
98 100
 
@@ -113,16 +115,21 @@  discard block
 block discarded – undo
113 115
      */
114 116
     private function getStyle(array $token, array $previous): string
115 117
     {
116
-        if (!empty($previous)) {
117
-            foreach ($this->style as $style => $tokens) {
118
-                if (\in_array($previous[1] . $token[0], $tokens)) {
118
+        if (!empty($previous))
119
+        {
120
+            foreach ($this->style as $style => $tokens)
121
+            {
122
+                if (\in_array($previous[1] . $token[0], $tokens))
123
+                {
119 124
                     return $style;
120 125
                 }
121 126
             }
122 127
         }
123 128
 
124
-        foreach ($this->style as $style => $tokens) {
125
-            if (\in_array($token[0], $tokens)) {
129
+        foreach ($this->style as $style => $tokens)
130
+        {
131
+            if (\in_array($token[0], $tokens))
132
+            {
126 133
                 return $style;
127 134
             }
128 135
         }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 class ConsoleStyle implements StyleInterface
14 14
 {
15 15
     protected array $templates = [
16
-        'token'  => '%s%s' . Color::RESET,
17
-        'line'   => Color::LIGHT_CYAN . ' %s ' . Color::RESET . " %s\n",
18
-        'active' => Color::BG_RED . ' ' . Color::LIGHT_WHITE . '%s ' . Color::RESET . " %s\n",
16
+        'token'  => '%s%s'.Color::RESET,
17
+        'line'   => Color::LIGHT_CYAN.' %s '.Color::RESET." %s\n",
18
+        'active' => Color::BG_RED.' '.Color::LIGHT_WHITE.'%s '.Color::RESET." %s\n",
19 19
     ];
20 20
     protected array $style = [
21 21
         Color::YELLOW        => [
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
             T_VARIABLE,
78 78
         ],
79 79
         Color::LIGHT_YELLOW  => [
80
-            '->' . T_STRING,
81
-            '::' . T_STRING,
80
+            '->'.T_STRING,
81
+            '::'.T_STRING,
82 82
         ],
83 83
     ];
84 84
 
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
     {
87 87
         $style = $this->getStyle($token, $previous);
88 88
 
89
-        if (!\str_contains((string) $token[1], "\n")) {
89
+        if (!\str_contains((string)$token[1], "\n")){
90 90
             return \sprintf($this->templates['token'], $style, $token[1]);
91 91
         }
92 92
 
93 93
         $lines = [];
94
-        foreach (\explode("\n", (string) $token[1]) as $line) {
94
+        foreach (\explode("\n", (string)$token[1]) as $line){
95 95
             $lines[] = \sprintf($this->templates['token'], $style, $line);
96 96
         }
97 97
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         return \sprintf(
104 104
             $this->templates[$target ? 'active' : 'line'],
105
-            \str_pad((string) $number, 4, ' ', STR_PAD_LEFT),
105
+            \str_pad((string)$number, 4, ' ', STR_PAD_LEFT),
106 106
             $code,
107 107
         );
108 108
     }
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function getStyle(array $token, array $previous): string
114 114
     {
115
-        if (!empty($previous)) {
116
-            foreach ($this->style as $style => $tokens) {
117
-                if (\in_array($previous[1] . $token[0], $tokens)) {
115
+        if (!empty($previous)){
116
+            foreach ($this->style as $style => $tokens){
117
+                if (\in_array($previous[1].$token[0], $tokens)){
118 118
                     return $style;
119 119
                 }
120 120
             }
121 121
         }
122 122
 
123
-        foreach ($this->style as $style => $tokens) {
124
-            if (\in_array($token[0], $tokens)) {
123
+        foreach ($this->style as $style => $tokens){
124
+            if (\in_array($token[0], $tokens)){
125 125
                 return $style;
126 126
             }
127 127
         }
Please login to merge, or discard this patch.
src/Reactor/tests/ClassDeclarationTest.php 2 patches
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@
 block discarded – undo
42 42
 
43 43
         $declaration
44 44
             ->addConstant('PRIVATE', 123)
45
-            ->setVisibility(Partial\Visibility::PRIVATE);
45
+            ->setVisibility(Partial\Visibility::private);
46 46
 
47 47
         $declaration
48 48
             ->addConstant('PROTECTED', 456)
49
-            ->setVisibility(Partial\Visibility::PROTECTED);
49
+            ->setVisibility(Partial\Visibility::protected);
50 50
 
51 51
         $declaration
52 52
             ->addConstant('PUBLIC', 789)
53
-            ->setVisibility(Partial\Visibility::PUBLIC);
53
+            ->setVisibility(Partial\Visibility::public);
54 54
 
55 55
         $declaration
56 56
             ->addConstant('WITH_COMMENT', 'foo')
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
             */
29 29
             final class MyClass extends Spiral\Tests\Reactor\ClassDeclarationTest implements Countable
30 30
             {
31
-            }'), \preg_replace('/\s+/', '', (string) $declaration));
31
+            }'), \preg_replace('/\s+/', '', (string)$declaration));
32 32
     }
33 33
 
34 34
     public function testClassDeclarationWithConstants(): void
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
                 #[Foo\Cached(mode: true)]
77 77
                 public const WITH_ATTRIBUTE = \'attr\';
78
-            }'), \preg_replace('/\s+/', '', (string) $declaration));
78
+            }'), \preg_replace('/\s+/', '', (string)$declaration));
79 79
     }
80 80
 
81 81
     public function testClassDeclarationWithMethods(): void
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             {
107 107
                 return count($items ?: $this->items);
108 108
             }
109
-        }'), \preg_replace('/\s+/', '', (string) $declaration));
109
+        }'), \preg_replace('/\s+/', '', (string)$declaration));
110 110
     }
111 111
 
112 112
     public function testName(): void
Please login to merge, or discard this patch.
src/Reactor/src/Traits/FunctionLike.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         $param = Parameter::fromElement($this->element->addParameter($name));
59 59
 
60
-        if (\func_num_args() > 1) {
60
+        if (\func_num_args() > 1){
61 61
             $param->setDefaultValue($defaultValue);
62 62
         }
63 63
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $type = $this->element->getReturnType(false);
99 99
 
100
-        return $type === null ? null : (string) $type;
100
+        return $type === null ? null : (string)$type;
101 101
     }
102 102
 
103 103
     public function setReturnReference(bool $state = true): static
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@
 block discarded – undo
57 57
     {
58 58
         $param = Parameter::fromElement($this->element->addParameter($name));
59 59
 
60
-        if (\func_num_args() > 1) {
60
+        if (\func_num_args() > 1)
61
+        {
61 62
             $param->setDefaultValue($defaultValue);
62 63
         }
63 64
 
Please login to merge, or discard this patch.
src/Reactor/src/Traits/CommentAware.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
  */
10 10
 trait CommentAware
11 11
 {
12
-    public function setComment(array|string|null $comment): static
12
+    public function setComment(array | string | null $comment): static
13 13
     {
14
-        if (\is_array($comment)) {
15
-            foreach ($comment as $value) {
14
+        if (\is_array($comment)){
15
+            foreach ($comment as $value){
16 16
                 $this->element->addComment($value);
17 17
             }
18 18
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,10 @@
 block discarded – undo
11 11
 {
12 12
     public function setComment(array|string|null $comment): static
13 13
     {
14
-        if (\is_array($comment)) {
15
-            foreach ($comment as $value) {
14
+        if (\is_array($comment))
15
+        {
16
+            foreach ($comment as $value)
17
+            {
16 18
                 $this->element->addComment($value);
17 19
             }
18 20
 
Please login to merge, or discard this patch.
src/Reactor/src/Traits/VisibilityAware.php 2 patches
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,37 +25,37 @@
 block discarded – undo
25 25
 
26 26
     public function setPublic(): static
27 27
     {
28
-        $this->setVisibility(Visibility::PUBLIC);
28
+        $this->setVisibility(Visibility::public);
29 29
 
30 30
         return $this;
31 31
     }
32 32
 
33 33
     public function isPublic(): bool
34 34
     {
35
-        return $this->getVisibility() === Visibility::PUBLIC;
35
+        return $this->getVisibility() === Visibility::public;
36 36
     }
37 37
 
38 38
     public function setProtected(): static
39 39
     {
40
-        $this->setVisibility(Visibility::PROTECTED);
40
+        $this->setVisibility(Visibility::protected);
41 41
 
42 42
         return $this;
43 43
     }
44 44
 
45 45
     public function isProtected(): bool
46 46
     {
47
-        return $this->getVisibility() === Visibility::PROTECTED;
47
+        return $this->getVisibility() === Visibility::protected;
48 48
     }
49 49
 
50 50
     public function setPrivate(): static
51 51
     {
52
-        $this->setVisibility(Visibility::PRIVATE);
52
+        $this->setVisibility(Visibility::private);
53 53
 
54 54
         return $this;
55 55
     }
56 56
 
57 57
     public function isPrivate(): bool
58 58
     {
59
-        return $this->getVisibility() === Visibility::PRIVATE;
59
+        return $this->getVisibility() === Visibility::private;
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 
21 21
     public function getVisibility(): ?Visibility
22 22
     {
23
-        return Visibility::tryFrom((string) $this->element->getVisibility());
23
+        return Visibility::tryFrom((string)$this->element->getVisibility());
24 24
     }
25 25
 
26 26
     public function setPublic(): static
Please login to merge, or discard this patch.
src/Reactor/src/AbstractDeclaration.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 
27 27
     public function setName(?string $name): self
28 28
     {
29
-        if ($name !== null) {
29
+        if ($name !== null){
30 30
             $name = (new InflectorFactory())->build()->classify($name);
31 31
         }
32 32
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@
 block discarded – undo
26 26
 
27 27
     public function setName(?string $name): self
28 28
     {
29
-        if ($name !== null) {
29
+        if ($name !== null)
30
+        {
30 31
             $name = (new InflectorFactory())->build()->classify($name);
31 32
         }
32 33
 
Please login to merge, or discard this patch.
src/Reactor/src/EnumDeclaration.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         ));
85 85
     }
86 86
 
87
-    public function addCase(string $name, string|int|null $value = null): EnumCase
87
+    public function addCase(string $name, string | int | null $value = null): EnumCase
88 88
     {
89 89
         return EnumCase::fromElement($this->element->addCase($name, $value));
90 90
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         return $this;
102 102
     }
103 103
 
104
-    public function addMember(Method|Constant|EnumCase|TraitUse $member): static
104
+    public function addMember(Method | Constant | EnumCase | TraitUse $member): static
105 105
     {
106 106
         $this->element->addMember($member->getElement());
107 107
 
Please login to merge, or discard this patch.
src/Reactor/src/ClassDeclaration.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
         return $this;
90 90
     }
91 91
 
92
-    public function addMember(Method|Property|Constant|TraitUse $member): static
92
+    public function addMember(Method | Property | Constant | TraitUse $member): static
93 93
     {
94 94
         $this->element->addMember($member->getElement());
95 95
 
Please login to merge, or discard this patch.
src/Reactor/src/Partial/Visibility.php 1 patch
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 enum Visibility: string
8 8
 {
9
-    case PUBLIC = 'public';
10
-    case PROTECTED = 'protected';
11
-    case PRIVATE = 'private';
9
+    case public = 'public';
10
+    case protected = 'protected';
11
+    case private = 'private';
12 12
 }
Please login to merge, or discard this patch.