Passed
Pull Request — master (#1141)
by Aleksei
13:56 queued 02:59
created
src/Stempler/src/Transform/Finalizer/DynamicToPHP.php 1 patch
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -55,17 +55,21 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function leaveNode(mixed $node, VisitorContext $ctx): mixed
57 57
     {
58
-        if ($node instanceof Output) {
58
+        if ($node instanceof Output)
59
+        {
59 60
             return $this->output($node, $ctx);
60 61
         }
61 62
 
62
-        if ($node instanceof Directive) {
63
+        if ($node instanceof Directive)
64
+        {
63 65
             return $this->directive($node);
64 66
         }
65 67
 
66
-        if ($node instanceof Template) {
68
+        if ($node instanceof Template)
69
+        {
67 70
             $extendsTag = $node->getAttribute(ExtendsParent::class);
68
-            if ($extendsTag instanceof Tag) {
71
+            if ($extendsTag instanceof Tag)
72
+            {
69 73
                 $extendsTag->attrs = $this->traverser->traverse($extendsTag->attrs);
70 74
             }
71 75
         }
@@ -75,9 +79,11 @@  discard block
 block discarded – undo
75 79
 
76 80
     private function directive(Directive $node): PHP
77 81
     {
78
-        foreach ($this->directives as $renderer) {
82
+        foreach ($this->directives as $renderer)
83
+        {
79 84
             $result = $renderer->render($node);
80
-            if ($result !== null) {
85
+            if ($result !== null)
86
+            {
81 87
                 return new PHP($result, \token_get_all($result), $node->getContext());
82 88
             }
83 89
         }
@@ -94,9 +100,12 @@  discard block
 block discarded – undo
94 100
          * In future this method can support context aware escaping based on tag location.
95 101
          */
96 102
 
97
-        if ($node->rawOutput) {
103
+        if ($node->rawOutput)
104
+        {
98 105
             $result = \sprintf('<?php echo %s; ?>', \trim((string) $node->body));
99
-        } else {
106
+        }
107
+        else
108
+        {
100 109
             $filter = $node->filter ?? $this->getFilterContext($ctx);
101 110
 
102 111
             $result = \sprintf(\sprintf('<?php echo %s; ?>', $filter), \trim((string) $node->body));
@@ -114,22 +123,27 @@  discard block
 block discarded – undo
114 123
         // only "interesting" nodes
115 124
         $context = [];
116 125
 
117
-        foreach (\array_reverse($ctx->getScope()) as $node) {
118
-            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim) {
126
+        foreach (\array_reverse($ctx->getScope()) as $node)
127
+        {
128
+            if ($node instanceof Attr || $node instanceof Tag || $node instanceof Verbatim)
129
+            {
119 130
                 $context[] = $node;
120 131
             }
121 132
 
122
-            if (\count($context) === 2) {
133
+            if (\count($context) === 2)
134
+            {
123 135
                 break;
124 136
             }
125 137
         }
126 138
 
127
-        if (\count($context) !== 2) {
139
+        if (\count($context) !== 2)
140
+        {
128 141
             return $this->defaultFilter;
129 142
         }
130 143
 
131 144
         // php {{ }} in javascript code (variable passing), use {! !} to bypass the filter
132
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script') {
145
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Tag && $context[1]->name === 'script')
146
+        {
133 147
             return \sprintf(
134 148
                 'json_encode(%s, %s, %s)',
135 149
                 '%s',
@@ -139,7 +153,8 @@  discard block
 block discarded – undo
139 153
         }
140 154
 
141 155
         // in on* and other attributes
142
-        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style') {
156
+        if ($context[0] instanceof Verbatim && $context[1] instanceof Attr && $context[1]->name !== 'style')
157
+        {
143 158
             return \sprintf("'%s', %s, '%s'", '&quot;', $this->defaultFilter, '&quot;');
144 159
         }
145 160
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Visitor/DefineBlocks.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,13 +22,16 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function enterNode(mixed $node, VisitorContext $ctx): mixed
24 24
     {
25
-        if ($node instanceof Tag) {
25
+        if ($node instanceof Tag)
26
+        {
26 27
             return $this->makeBlock($node);
27 28
         }
28 29
 
29
-        if ($node instanceof Inline) {
30
+        if ($node instanceof Inline)
31
+        {
30 32
             $block = new Block($node->name, $node->getContext());
31
-            if ($node->value !== null) {
33
+            if ($node->value !== null)
34
+            {
32 35
                 $block->nodes[] = new Raw($node->value);
33 36
             }
34 37
 
@@ -49,14 +52,17 @@  discard block
 block discarded – undo
49 52
     private function makeBlock(Tag $node): ?NodeInterface
50 53
     {
51 54
         $name = null;
52
-        foreach ($this->prefix as $prefix) {
53
-            if (\str_starts_with($node->name, (string) $prefix)) {
55
+        foreach ($this->prefix as $prefix)
56
+        {
57
+            if (\str_starts_with($node->name, (string) $prefix))
58
+            {
54 59
                 $name = \substr($node->name, \strlen((string) $prefix));
55 60
                 break;
56 61
             }
57 62
         }
58 63
 
59
-        if ($name === null) {
64
+        if ($name === null)
65
+        {
60 66
             return null;
61 67
         }
62 68
 
Please login to merge, or discard this patch.
src/Stempler/src/Transform/Merge/Inject/PHPMixin.php 1 patch
Braces   +48 added lines, -24 removed lines patch added patch discarded remove patch
@@ -22,8 +22,10 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $replace = [];
24 24
 
25
-        foreach ($this->blocks as $block) {
26
-            for ($i = $block['start']; $i <= $block['end']; $i++) {
25
+        foreach ($this->blocks as $block)
26
+        {
27
+            for ($i = $block['start']; $i <= $block['end']; $i++)
28
+            {
27 29
                 $replace[$i] = '';
28 30
             }
29 31
 
@@ -31,13 +33,16 @@  discard block
 block discarded – undo
31 33
         }
32 34
 
33 35
         $result = '';
34
-        foreach ($this->tokens as $position => $token) {
35
-            if (\array_key_exists($position, $replace)) {
36
+        foreach ($this->tokens as $position => $token)
37
+        {
38
+            if (\array_key_exists($position, $replace))
39
+            {
36 40
                 $result .= $replace[$position];
37 41
                 continue;
38 42
             }
39 43
 
40
-            if (\is_string($token)) {
44
+            if (\is_string($token))
45
+            {
41 46
                 $result .= $token;
42 47
                 continue;
43 48
             }
@@ -55,8 +60,10 @@  discard block
 block discarded – undo
55 60
     {
56 61
         $replace = [];
57 62
 
58
-        foreach ($this->blocks as $block) {
59
-            for ($i = $block['start']; $i <= $block['end']; ++$i) {
63
+        foreach ($this->blocks as $block)
64
+        {
65
+            for ($i = $block['start']; $i <= $block['end']; ++$i)
66
+            {
60 67
                 $replace[$i] = '';
61 68
             }
62 69
 
@@ -64,18 +71,22 @@  discard block
 block discarded – undo
64 71
         }
65 72
 
66 73
         $result = '';
67
-        foreach ($this->tokens as $position => $token) {
68
-            if (\array_key_exists($position, $replace)) {
74
+        foreach ($this->tokens as $position => $token)
75
+        {
76
+            if (\array_key_exists($position, $replace))
77
+            {
69 78
                 $result .= $replace[$position];
70 79
                 continue;
71 80
             }
72 81
 
73
-            if (\is_string($token)) {
82
+            if (\is_string($token))
83
+            {
74 84
                 $result .= $token;
75 85
                 continue;
76 86
             }
77 87
 
78
-            if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) {
88
+            if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO]))
89
+            {
79 90
                 continue;
80 91
             }
81 92
 
@@ -91,7 +102,8 @@  discard block
 block discarded – undo
91 102
     public function getBlocks(): array
92 103
     {
93 104
         $result = [];
94
-        foreach ($this->blocks as $name => $macro) {
105
+        foreach ($this->blocks as $name => $macro)
106
+        {
95 107
             $result[$name] = $macro['value'];
96 108
         }
97 109
 
@@ -105,7 +117,8 @@  discard block
 block discarded – undo
105 117
 
106 118
     public function set(string $block, string $value): void
107 119
     {
108
-        if (!isset($this->blocks[$block])) {
120
+        if (!isset($this->blocks[$block]))
121
+        {
109 122
             return;
110 123
         }
111 124
 
@@ -116,26 +129,32 @@  discard block
 block discarded – undo
116 129
     {
117 130
         $level = 0;
118 131
         $start = $name = $value = null;
119
-        foreach ($this->tokens as $position => $token) {
120
-            if (!\is_array($token)) {
132
+        foreach ($this->tokens as $position => $token)
133
+        {
134
+            if (!\is_array($token))
135
+            {
121 136
                 $token = [$token, $token, 0];
122 137
             }
123 138
 
124
-            switch ($token[0]) {
139
+            switch ($token[0])
140
+            {
125 141
                 case '(':
126
-                    if ($start !== null) {
142
+                    if ($start !== null)
143
+                    {
127 144
                         $level++;
128 145
                         $value .= $token[1];
129 146
                     }
130 147
                     break;
131 148
                 case ')':
132
-                    if ($start === null) {
149
+                    if ($start === null)
150
+                    {
133 151
                         break;
134 152
                     }
135 153
 
136 154
                     $level--;
137 155
                     $value .= $token[1];
138
-                    if ($level === 0) {
156
+                    if ($level === 0)
157
+                    {
139 158
                         $this->blocks[$name] = [
140 159
                             'start' => $start,
141 160
                             'value' => trim($value),
@@ -147,22 +166,26 @@  discard block
 block discarded – undo
147 166
                     }
148 167
                     break;
149 168
                 case T_STRING:
150
-                    if ($token[1] === $func) {
169
+                    if ($token[1] === $func)
170
+                    {
151 171
                         $start = $position;
152 172
                         $value = $token[1];
153 173
                         break;
154 174
                     }
155 175
 
156
-                    if ($start !== null) {
176
+                    if ($start !== null)
177
+                    {
157 178
                         $value .= $token[1];
158 179
                     }
159 180
                     break;
160 181
                 case T_CONSTANT_ENCAPSED_STRING:
161
-                    if ($start === null) {
182
+                    if ($start === null)
183
+                    {
162 184
                         break;
163 185
                     }
164 186
 
165
-                    if ($name === null) {
187
+                    if ($name === null)
188
+                    {
166 189
                         $name = \stripcslashes(\substr((string) $token[1], 1, -1));
167 190
                     }
168 191
                     $value .= $token[1];
@@ -171,7 +194,8 @@  discard block
 block discarded – undo
171 194
                     $value .= $token[1];
172 195
                     break;
173 196
                 default:
174
-                    if ($start !== null) {
197
+                    if ($start !== null)
198
+                    {
175 199
                         $value .= $token[1];
176 200
                     }
177 201
             }
Please login to merge, or discard this patch.
src/Stempler/src/Compiler/Renderer/DynamicRenderer.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
26 26
     {
27
-        switch (true) {
27
+        switch (true)
28
+        {
28 29
             case $node instanceof Output:
29 30
                 $this->output($result, $node);
30 31
                 return true;
@@ -41,9 +42,11 @@  discard block
 block discarded – undo
41 42
      */
42 43
     private function directive(Compiler\Result $source, Directive $directive): void
43 44
     {
44
-        if ($this->directiveRenderer !== null) {
45
+        if ($this->directiveRenderer !== null)
46
+        {
45 47
             $result = $this->directiveRenderer->render($directive);
46
-            if ($result !== null) {
48
+            if ($result !== null)
49
+            {
47 50
                 $source->push($result, $directive->getContext());
48 51
                 return;
49 52
             }
@@ -57,7 +60,8 @@  discard block
 block discarded – undo
57 60
 
58 61
     private function output(Compiler\Result $source, Output $output): void
59 62
     {
60
-        if ($output->rawOutput) {
63
+        if ($output->rawOutput)
64
+        {
61 65
             $source->push(\sprintf('<?php echo %s; ?>', \trim((string) $output->body)), $output->getContext());
62 66
             return;
63 67
         }
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/DynamicGrammar.php 1 patch
Braces   +40 added lines, -19 removed lines patch added patch discarded remove patch
@@ -67,13 +67,16 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function parse(Buffer $src): \Generator
69 69
     {
70
-        while ($n = $src->next()) {
71
-            if (!$n instanceof Byte) {
70
+        while ($n = $src->next())
71
+        {
72
+            if (!$n instanceof Byte)
73
+            {
72 74
                 yield $n;
73 75
                 continue;
74 76
             }
75 77
 
76
-            if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR) {
78
+            if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR)
79
+            {
77 80
                 if (
78 81
                     $this->echo->nextToken($src) ||
79 82
                     $this->raw->nextToken($src) ||
@@ -85,11 +88,15 @@  discard block
 block discarded – undo
85 88
                 }
86 89
 
87 90
                 $directive = new DirectiveGrammar();
88
-                if ($directive->parse($src, $n->offset)) {
89
-                    if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE) {
91
+                if ($directive->parse($src, $n->offset))
92
+                {
93
+                    if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE)
94
+                    {
90 95
                         // configure braces syntax
91 96
                         $this->declare($directive->getBody());
92
-                    } else {
97
+                    }
98
+                    else
99
+                    {
93 100
                         if (
94 101
                             $this->directiveRenderer !== null
95 102
                             && !$this->directiveRenderer->hasDirective($directive->getKeyword())
@@ -114,15 +121,20 @@  discard block
 block discarded – undo
114 121
 
115 122
             /** @var BracesGrammar|null $braces */
116 123
             $braces = null;
117
-            if ($this->echo->starts($src, $n)) {
124
+            if ($this->echo->starts($src, $n))
125
+            {
118 126
                 $braces = clone $this->echo;
119
-            } elseif ($this->raw->starts($src, $n)) {
127
+            }
128
+            elseif ($this->raw->starts($src, $n))
129
+            {
120 130
                 $braces = clone $this->raw;
121 131
             }
122 132
 
123
-            if ($braces !== null) {
133
+            if ($braces !== null)
134
+            {
124 135
                 $echo = $braces->parse($src, $n);
125
-                if ($echo !== null) {
136
+                if ($echo !== null)
137
+                {
126 138
                     yield from $echo;
127 139
                     continue;
128 140
                 }
@@ -156,18 +168,22 @@  discard block
 block discarded – undo
156 168
 
157 169
     private function declare(?string $body): void
158 170
     {
159
-        if ($body === null) {
171
+        if ($body === null)
172
+        {
160 173
             return;
161 174
         }
162 175
 
163
-        foreach ($this->fetchOptions($body) as $option => $value) {
176
+        foreach ($this->fetchOptions($body) as $option => $value)
177
+        {
164 178
             $value = \trim((string) $value, '\'" ');
165
-            switch ($option) {
179
+            switch ($option)
180
+            {
166 181
                 case 'syntax':
167 182
                     $this->echo->setActive($value !== 'off');
168 183
                     $this->raw->setActive($value !== 'off');
169 184
 
170
-                    if ($value === 'default') {
185
+                    if ($value === 'default')
186
+                    {
171 187
                         $this->echo->setStartSequence('{{');
172 188
                         $this->echo->setEndSequence('}}');
173 189
                         $this->raw->setStartSequence('{!!');
@@ -204,10 +220,13 @@  discard block
 block discarded – undo
204 220
         $keyword = null;
205 221
 
206 222
         /** @var Token $token */
207
-        foreach ($lexer->parse(new StringStream($body)) as $token) {
208
-            switch ($token->type) {
223
+        foreach ($lexer->parse(new StringStream($body)) as $token)
224
+        {
225
+            switch ($token->type)
226
+            {
209 227
                 case DeclareGrammar::TYPE_KEYWORD:
210
-                    if ($keyword !== null) {
228
+                    if ($keyword !== null)
229
+                    {
211 230
                         $options[$keyword] = $token->content;
212 231
                         $keyword = null;
213 232
                         break;
@@ -215,7 +234,8 @@  discard block
 block discarded – undo
215 234
                     $keyword = $token->content;
216 235
                     break;
217 236
                 case DeclareGrammar::TYPE_QUOTED:
218
-                    if ($keyword !== null) {
237
+                    if ($keyword !== null)
238
+                    {
219 239
                         $options[$keyword] = \trim($token->content, $token->content[0]);
220 240
                         $keyword = null;
221 241
                         break;
@@ -224,7 +244,8 @@  discard block
 block discarded – undo
224 244
                     $keyword = \trim($token->content, $token->content[0]);
225 245
                     break;
226 246
                 case DeclareGrammar::TYPE_COMMA:
227
-                    if ($keyword !== null) {
247
+                    if ($keyword !== null)
248
+                    {
228 249
                         $options[$keyword] = null;
229 250
                         $keyword = null;
230 251
                         break;
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/Builder.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,18 +42,22 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function makeSchema(string $name, array $schema): array
44 44
     {
45
-        if (empty($schema)) {
45
+        if (empty($schema))
46
+        {
46 47
             throw new SchemaException(\sprintf('Filter `%s` does not define any schema', $name));
47 48
         }
48 49
 
49 50
         $result = [];
50
-        foreach ($schema as $field => $definition) {
51
+        foreach ($schema as $field => $definition)
52
+        {
51 53
             $optional = false;
52 54
 
53 55
             // short definition
54
-            if (\is_string($definition)) {
56
+            if (\is_string($definition))
57
+            {
55 58
                 // simple scalar field definition
56
-                if (!\class_exists($definition)) {
59
+                if (!\class_exists($definition))
60
+                {
57 61
                     [$source, $origin] = $this->parseDefinition($field, $definition);
58 62
                     $result[$field] = [
59 63
                         self::SCHEMA_SOURCE => $source,
@@ -74,25 +78,30 @@  discard block
 block discarded – undo
74 78
                 continue;
75 79
             }
76 80
 
77
-            if (!\is_array($definition) || $definition === []) {
81
+            if (!\is_array($definition) || $definition === [])
82
+            {
78 83
                 throw new SchemaException(
79 84
                     \sprintf('Invalid schema definition at `%s`->`%s`', $name, $field)
80 85
                 );
81 86
             }
82 87
 
83 88
             // complex definition
84
-            if (!empty($definition[self::ORIGIN])) {
89
+            if (!empty($definition[self::ORIGIN]))
90
+            {
85 91
                 $origin = $definition[self::ORIGIN];
86 92
 
87 93
                 // [class, 'data:something.*'] vs [class, 'data:something']
88 94
                 $iterate = \str_contains((string)$origin, '.*') || !empty($definition[self::ITERATE]);
89 95
                 $origin = \rtrim((string) $origin, '.*');
90
-            } else {
96
+            }
97
+            else
98
+            {
91 99
                 $origin = $field;
92 100
                 $iterate = true;
93 101
             }
94 102
 
95
-            if (!empty($definition[self::OPTIONAL])) {
103
+            if (!empty($definition[self::OPTIONAL]))
104
+            {
96 105
                 $optional = true;
97 106
             }
98 107
 
@@ -105,7 +114,8 @@  discard block
 block discarded – undo
105 114
                 self::SCHEMA_OPTIONAL => $optional,
106 115
             ];
107 116
 
108
-            if ($iterate) {
117
+            if ($iterate)
118
+            {
109 119
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
110 120
 
111 121
                 $map[self::SCHEMA_ITERATE_SOURCE] = $source;
@@ -128,7 +138,8 @@  discard block
 block discarded – undo
128 138
      */
129 139
     private function parseDefinition(string $field, string $definition): array
130 140
     {
131
-        if (!\str_contains($definition, ':')) {
141
+        if (!\str_contains($definition, ':'))
142
+        {
132 143
             return ['data', empty($definition) ? $field : $definition];
133 144
         }
134 145
 
Please login to merge, or discard this patch.
src/Http/src/Header/AcceptHeader.php 1 patch
Braces   +30 added lines, -15 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function __construct(array $items = [])
28 28
     {
29
-        foreach ($items as $item) {
29
+        foreach ($items as $item)
30
+        {
30 31
             $this->addItem($item);
31 32
         }
32 33
     }
@@ -41,9 +42,11 @@  discard block
 block discarded – undo
41 42
         $header = new static();
42 43
 
43 44
         $parts = \explode(',', $raw);
44
-        foreach ($parts as $part) {
45
+        foreach ($parts as $part)
46
+        {
45 47
             $part = \trim($part);
46
-            if ($part !== '') {
48
+            if ($part !== '')
49
+            {
47 50
                 $header->addItem($part);
48 51
             }
49 52
         }
@@ -74,7 +77,8 @@  discard block
 block discarded – undo
74 77
      */
75 78
     public function getAll(): array
76 79
     {
77
-        if (!$this->sorted) {
80
+        if (!$this->sorted)
81
+        {
78 82
             /**
79 83
              * Sort item in descending order.
80 84
              */
@@ -91,12 +95,14 @@  discard block
 block discarded – undo
91 95
      */
92 96
     private function addItem(AcceptHeaderItem|string $item): void
93 97
     {
94
-        if (\is_string($item)) {
98
+        if (\is_string($item))
99
+        {
95 100
             $item = AcceptHeaderItem::fromString($item);
96 101
         }
97 102
 
98 103
         $value = \strtolower((string) $item->getValue());
99
-        if ($value !== '' && (!$this->has($value) || self::compare($item, $this->get($value)) === 1)) {
104
+        if ($value !== '' && (!$this->has($value) || self::compare($item, $this->get($value)) === 1))
105
+        {
100 106
             $this->sorted = false;
101 107
             $this->items[$value] = $item;
102 108
         }
@@ -108,9 +114,11 @@  discard block
 block discarded – undo
108 114
      */
109 115
     private static function compare(AcceptHeaderItem|string $a, AcceptHeaderItem|string $b): int
110 116
     {
111
-        if ($a->getQuality() === $b->getQuality()) {
117
+        if ($a->getQuality() === $b->getQuality())
118
+        {
112 119
             // If quality are same value with more params has more weight.
113
-            if (\count($a->getParams()) === \count($b->getParams())) {
120
+            if (\count($a->getParams()) === \count($b->getParams()))
121
+            {
114 122
                 // If quality and params then check for specific type or subtype.
115 123
                 // Means */* or * has less weight.
116 124
                 return static::compareValue($a->getValue(), $b->getValue());
@@ -129,11 +137,13 @@  discard block
 block discarded – undo
129 137
     private static function compareValue(string $a, string $b): int
130 138
     {
131 139
         // Check "Accept" headers values with it is type and subtype.
132
-        if (\str_contains($a, '/') && \str_contains($b, '/')) {
140
+        if (\str_contains($a, '/') && \str_contains($b, '/'))
141
+        {
133 142
             [$typeA, $subtypeA] = \explode('/', $a, 2);
134 143
             [$typeB, $subtypeB] = \explode('/', $b, 2);
135 144
 
136
-            if ($typeA === $typeB) {
145
+            if ($typeA === $typeB)
146
+            {
137 147
                 return static::compareAtomic($subtypeA, $subtypeB);
138 148
             }
139 149
 
@@ -145,23 +155,28 @@  discard block
 block discarded – undo
145 155
 
146 156
     private static function compareAtomic(string $a, string $b): int
147 157
     {
148
-        if (\mb_strpos($a, '*/') === 0) {
158
+        if (\mb_strpos($a, '*/') === 0)
159
+        {
149 160
             $a = '*';
150 161
         }
151 162
 
152
-        if (\mb_strpos($b, '*/') === 0) {
163
+        if (\mb_strpos($b, '*/') === 0)
164
+        {
153 165
             $b = '*';
154 166
         }
155 167
 
156
-        if (\strtolower($a) === \strtolower($b)) {
168
+        if (\strtolower($a) === \strtolower($b))
169
+        {
157 170
             return 0;
158 171
         }
159 172
 
160
-        if ($a === '*') {
173
+        if ($a === '*')
174
+        {
161 175
             return -1;
162 176
         }
163 177
 
164
-        if ($b === '*') {
178
+        if ($b === '*')
179
+        {
165 180
             return 1;
166 181
         }
167 182
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Config/ScaffolderConfig.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,11 +79,13 @@  discard block
 block discarded – undo
79 79
         $localNamespace = \trim((string) $this->getOption($element, 'namespace', ''), '\\');
80 80
         ['namespace' => $namespace] = $this->parseName($name);
81 81
 
82
-        if (!empty($namespace)) {
82
+        if (!empty($namespace))
83
+        {
83 84
             $localNamespace .= '\\' . $this->classify($namespace);
84 85
         }
85 86
 
86
-        if (empty($this->baseNamespace($element))) {
87
+        if (empty($this->baseNamespace($element)))
88
+        {
87 89
             return $localNamespace;
88 90
         }
89 91
 
@@ -117,7 +119,8 @@  discard block
 block discarded – undo
117 119
     {
118 120
         $class = $this->getOption($element, 'class');
119 121
 
120
-        if (empty($class)) {
122
+        if (empty($class))
123
+        {
121 124
             throw new ScaffolderException(
122 125
                 \sprintf("Unable to scaffold '%s', no declaration class found", $element),
123 126
             );
@@ -165,11 +168,13 @@  discard block
 block discarded – undo
165 168
     {
166 169
         $declaration = $this->getDeclaration($element);
167 170
 
168
-        if ($declaration === []) {
171
+        if ($declaration === [])
172
+        {
169 173
             throw new ScaffolderException(\sprintf("Undefined declaration '%s'.", $element));
170 174
         }
171 175
 
172
-        if (\array_key_exists($section, $declaration)) {
176
+        if (\array_key_exists($section, $declaration))
177
+        {
173 178
             return $declaration[$section];
174 179
         }
175 180
 
@@ -187,7 +192,8 @@  discard block
 block discarded – undo
187 192
     {
188 193
         $name = \str_replace('/', '\\', $name);
189 194
 
190
-        if (str_contains($name, '\\')) {
195
+        if (str_contains($name, '\\'))
196
+        {
191 197
             $names = \explode('\\', $name);
192 198
             $class = \array_pop($names);
193 199
 
@@ -205,7 +211,8 @@  discard block
 block discarded – undo
205 211
     {
206 212
         $declaration = $this->getDeclaration($element);
207 213
 
208
-        if (\array_key_exists('baseNamespace', $declaration)) {
214
+        if (\array_key_exists('baseNamespace', $declaration))
215
+        {
209 216
             return \trim((string)$this->getOption($element, 'baseNamespace', ''), '\\');
210 217
         }
211 218
 
@@ -216,11 +223,15 @@  discard block
 block discarded – undo
216 223
     {
217 224
         $firstChunkIterated = false;
218 225
         $joinedPath = '';
219
-        foreach ($chunks as $chunk) {
220
-            if (!$firstChunkIterated) {
226
+        foreach ($chunks as $chunk)
227
+        {
228
+            if (!$firstChunkIterated)
229
+            {
221 230
                 $firstChunkIterated = true;
222 231
                 $joinedPath = $chunk;
223
-            } else {
232
+            }
233
+            else
234
+            {
224 235
                 $joinedPath = \rtrim((string) $joinedPath, $joint) . $joint . \ltrim((string) $chunk, $joint);
225 236
             }
226 237
         }
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/CommandCommand.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,11 +42,13 @@
 block discarded – undo
42 42
             'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)),
43 43
         ]);
44 44
 
45
-        foreach ($this->arguments as $argument) {
45
+        foreach ($this->arguments as $argument)
46
+        {
46 47
             $declaration->addArgument($argument);
47 48
         }
48 49
 
49
-        foreach ($this->options as $option) {
50
+        foreach ($this->options as $option)
51
+        {
50 52
             $declaration->addOption($option);
51 53
         }
52 54
 
Please login to merge, or discard this patch.