Passed
Pull Request — master (#656)
by Abdul Malik
11:30 queued 05:15
created
src/Stempler/src/Lexer/Grammar/PHPGrammar.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function parse(Buffer $src): Generator
29 29
     {
30
-        while ($n = $src->next()) {
31
-            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?') {
30
+        while ($n = $src->next()){
31
+            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?'){
32 32
                 yield $n;
33 33
                 continue;
34 34
             }
35 35
 
36
-            $php = $this->parseGrammar($n->char . $src->nextBytes(), $n->offset);
37
-            if ($php === null) {
36
+            $php = $this->parseGrammar($n->char.$src->nextBytes(), $n->offset);
37
+            if ($php === null){
38 38
                 yield $n;
39 39
                 $src->replay($n->offset);
40 40
                 continue;
@@ -57,27 +57,27 @@  discard block
 block discarded – undo
57 57
     private function parseGrammar(string $content, int $offset): ?Token
58 58
     {
59 59
         $tokens = null;
60
-        foreach (token_get_all($content) as $token) {
61
-            if ($tokens === null) {
62
-                if (!$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])) {
60
+        foreach (token_get_all($content) as $token){
61
+            if ($tokens === null){
62
+                if (!$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])){
63 63
                     // not php
64 64
                     return null;
65 65
                 }
66 66
             }
67 67
 
68 68
             $tokens[] = $token;
69
-            if ($this->is($token, [T_CLOSE_TAG])) {
69
+            if ($this->is($token, [T_CLOSE_TAG])){
70 70
                 break;
71 71
             }
72 72
         }
73 73
 
74
-        if ($tokens === null) {
74
+        if ($tokens === null){
75 75
             return null;
76 76
         }
77 77
 
78 78
         $buffer = '';
79
-        foreach ($tokens as $token) {
80
-            if (!is_array($token)) {
79
+        foreach ($tokens as $token){
80
+            if (!is_array($token)){
81 81
                 $buffer .= $token;
82 82
                 continue;
83 83
             }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     private function is($token, array $type): bool
97 97
     {
98
-        if (!is_array($token)) {
98
+        if (!is_array($token)){
99 99
             return false;
100 100
         }
101 101
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,14 +27,17 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function parse(Buffer $src): Generator
29 29
     {
30
-        while ($n = $src->next()) {
31
-            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?') {
30
+        while ($n = $src->next())
31
+        {
32
+            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?')
33
+            {
32 34
                 yield $n;
33 35
                 continue;
34 36
             }
35 37
 
36 38
             $php = $this->parseGrammar($n->char . $src->nextBytes(), $n->offset);
37
-            if ($php === null) {
39
+            if ($php === null)
40
+            {
38 41
                 yield $n;
39 42
                 $src->replay($n->offset);
40 43
                 continue;
@@ -57,27 +60,34 @@  discard block
 block discarded – undo
57 60
     private function parseGrammar(string $content, int $offset): ?Token
58 61
     {
59 62
         $tokens = null;
60
-        foreach (token_get_all($content) as $token) {
61
-            if ($tokens === null) {
62
-                if (!$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])) {
63
+        foreach (token_get_all($content) as $token)
64
+        {
65
+            if ($tokens === null)
66
+            {
67
+                if (!$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO]))
68
+                {
63 69
                     // not php
64 70
                     return null;
65 71
                 }
66 72
             }
67 73
 
68 74
             $tokens[] = $token;
69
-            if ($this->is($token, [T_CLOSE_TAG])) {
75
+            if ($this->is($token, [T_CLOSE_TAG]))
76
+            {
70 77
                 break;
71 78
             }
72 79
         }
73 80
 
74
-        if ($tokens === null) {
81
+        if ($tokens === null)
82
+        {
75 83
             return null;
76 84
         }
77 85
 
78 86
         $buffer = '';
79
-        foreach ($tokens as $token) {
80
-            if (!is_array($token)) {
87
+        foreach ($tokens as $token)
88
+        {
89
+            if (!is_array($token))
90
+            {
81 91
                 $buffer .= $token;
82 92
                 continue;
83 93
             }
@@ -95,7 +105,8 @@  discard block
 block discarded – undo
95 105
      */
96 106
     private function is($token, array $type): bool
97 107
     {
98
-        if (!is_array($token)) {
108
+        if (!is_array($token))
109
+        {
99 110
             return false;
100 111
         }
101 112
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/HTMLGrammar.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function parse(Buffer $src): Generator
59 59
     {
60
-        while ($n = $src->next()) {
61
-            if (!$n instanceof Byte || $n->char !== '<') {
60
+        while ($n = $src->next()){
61
+            if (!$n instanceof Byte || $n->char !== '<'){
62 62
                 yield $n;
63 63
                 continue;
64 64
             }
65 65
 
66 66
             // work with isolated token stream!
67 67
             $tag = (clone $this)->parseGrammar($src);
68
-            if ($tag === null) {
68
+            if ($tag === null){
69 69
                 yield $n;
70 70
                 $src->replay($n->offset);
71 71
                 continue;
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             $tagName = $this->tagName($tag);
75 75
 
76 76
             // todo: add support for custom tag list
77
-            if (in_array($tagName, self::VERBATIM_TAGS)) {
77
+            if (in_array($tagName, self::VERBATIM_TAGS)){
78 78
                 yield from $tag;
79 79
                 yield from $this->parseVerbatim($src, $tagName);
80 80
                 continue;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public static function tokenName(int $token): string
92 92
     {
93
-        switch ($token) {
93
+        switch ($token){
94 94
             case self::TYPE_RAW:
95 95
                 return 'HTML:RAW';
96 96
             case self::TYPE_KEYWORD:
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
     {
124 124
         $chunks = [];
125 125
 
126
-        while ($n = $src->next()) {
127
-            if ($n instanceof Token) {
126
+        while ($n = $src->next()){
127
+            if ($n instanceof Token){
128 128
                 $chunks[] = $n;
129 129
                 continue;
130 130
             }
131 131
 
132
-            switch ($n->char) {
132
+            switch ($n->char){
133 133
                 case '"':
134 134
                 case "'":
135 135
                 case '`':
136 136
                     $chunks[] = $n;
137 137
 
138 138
                     // language inclusions allow nested strings
139
-                    while ($nc = $src->next()) {
139
+                    while ($nc = $src->next()){
140 140
                         $chunks[] = $nc;
141
-                        if ($nc instanceof Token) {
141
+                        if ($nc instanceof Token){
142 142
                             continue;
143 143
                         }
144 144
 
145
-                        if ($nc->char === $n->char) {
145
+                        if ($nc->char === $n->char){
146 146
                             break;
147 147
                         }
148 148
                     }
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
                     $chunks[] = $n;
154 154
 
155 155
                     $multiline = false;
156
-                    if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') {
157
-                        if ($src->lookaheadByte(1) === '*') {
156
+                    if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*'){
157
+                        if ($src->lookaheadByte(1) === '*'){
158 158
                             $multiline = true;
159 159
                         }
160 160
 
161 161
                         $chunks[] = $src->next();
162 162
 
163 163
                         // language inclusions allow nested strings
164
-                        while ($nc = $src->next()) {
165
-                            if ($nc instanceof Token) {
164
+                        while ($nc = $src->next()){
165
+                            if ($nc instanceof Token){
166 166
                                 continue;
167 167
                             }
168 168
 
169
-                            if ($nc->char === '<') {
169
+                            if ($nc->char === '<'){
170 170
                                 $tag = (clone $this)->parseGrammar($src);
171
-                                if ($tag === null || $this->tagName($tag) !== $verbatim) {
171
+                                if ($tag === null || $this->tagName($tag) !== $verbatim){
172 172
                                     $src->replay($n->offset);
173 173
                                     break;
174 174
                                 }
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 
180 180
                             $chunks[] = $nc;
181 181
 
182
-                            if ($multiline) {
183
-                                if ($nc->char === '*' && $src->lookaheadByte(1) === '/') {
182
+                            if ($multiline){
183
+                                if ($nc->char === '*' && $src->lookaheadByte(1) === '/'){
184 184
                                     $chunks[] = $src->next();
185 185
                                     break;
186 186
                                 }
187
-                            } elseif ($nc->char === "\n") {
187
+                            } elseif ($nc->char === "\n"){
188 188
                                 break;
189 189
                             }
190 190
                         }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 case '<':
196 196
                     // tag beginning?
197 197
                     $tag = (clone $this)->parseGrammar($src);
198
-                    if ($tag === null || $this->tagName($tag) !== $verbatim) {
198
+                    if ($tag === null || $this->tagName($tag) !== $verbatim){
199 199
                         $chunks[] = $n;
200 200
                         $src->replay($n->offset);
201 201
                         break;
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 
216 216
     private function tagName(array $tag): string
217 217
     {
218
-        foreach ($tag as $token) {
219
-            if ($token->type === self::TYPE_KEYWORD) {
218
+        foreach ($tag as $token){
219
+            if ($token->type === self::TYPE_KEYWORD){
220 220
                 return strtolower($token->content);
221 221
             }
222 222
         }
@@ -230,28 +230,28 @@  discard block
 block discarded – undo
230 230
             new Token(self::TYPE_OPEN, $src->getOffset(), '<'),
231 231
         ];
232 232
 
233
-        if ($src->lookaheadByte() === '/') {
233
+        if ($src->lookaheadByte() === '/'){
234 234
             $this->tokens[0]->type = self::TYPE_OPEN_SHORT;
235 235
             $this->tokens[0]->content .= $src->next()->char;
236 236
         }
237 237
 
238
-        while ($n = $src->next()) {
239
-            if ($this->attribute !== []) {
238
+        while ($n = $src->next()){
239
+            if ($this->attribute !== []){
240 240
                 $this->attribute[] = $n;
241 241
 
242
-                if ($n instanceof Byte && $n->char === $this->attribute[0]->char) {
242
+                if ($n instanceof Byte && $n->char === $this->attribute[0]->char){
243 243
                     $this->flushAttribute();
244 244
                 }
245 245
 
246 246
                 continue;
247 247
             }
248 248
 
249
-            if ($n instanceof Token) {
249
+            if ($n instanceof Token){
250 250
                 $this->keyword[] = $n;
251 251
                 continue;
252 252
             }
253 253
 
254
-            switch ($n->char) {
254
+            switch ($n->char){
255 255
                 case '"':
256 256
                 case "'":
257 257
                 case '`':
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
                     break;
270 270
 
271 271
                 case '/':
272
-                    if ($src->lookaheadByte() === '>') {
272
+                    if ($src->lookaheadByte() === '>'){
273 273
                         $this->flush();
274 274
                         $this->tokens[] = new Token(
275 275
                             self::TYPE_CLOSE_SHORT,
276 276
                             $n->offset,
277
-                            $n->char . $src->next()->char
277
+                            $n->char.$src->next()->char
278 278
                         );
279 279
 
280 280
                         break 2;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                     break 2;
294 294
 
295 295
                 default:
296
-                    if (preg_match(self::REGEXP_WHITESPACE, $n->char)) {
296
+                    if (preg_match(self::REGEXP_WHITESPACE, $n->char)){
297 297
                         $this->flushKeyword();
298 298
                         $this->whitespace[] = $n;
299 299
                         break;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                     $this->flushWhitespace();
302 302
 
303 303
 
304
-                    if (!preg_match(self::REGEXP_KEYWORD, $n->char)) {
304
+                    if (!preg_match(self::REGEXP_KEYWORD, $n->char)){
305 305
                         // unexpected char
306 306
                         return null;
307 307
                     }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             }
311 311
         }
312 312
 
313
-        if (!$this->isValid()) {
313
+        if (!$this->isValid()){
314 314
             return null;
315 315
         }
316 316
 
@@ -320,17 +320,17 @@  discard block
 block discarded – undo
320 320
     private function isValid(): bool
321 321
     {
322 322
         // tag is too short or does not have name keyword
323
-        if (count($this->tokens) < 3) {
323
+        if (count($this->tokens) < 3){
324 324
             return false;
325 325
         }
326 326
 
327 327
         $last = $this->tokens[count($this->tokens) - 1];
328
-        if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) {
328
+        if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT){
329 329
             return false;
330 330
         }
331 331
 
332
-        foreach ($this->tokens as $token) {
333
-            switch ($token->type) {
332
+        foreach ($this->tokens as $token){
333
+            switch ($token->type){
334 334
                 case self::TYPE_WHITESPACE:
335 335
                     // ignore
336 336
                     continue 2;
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
      */
362 362
     private function flushWhitespace(): void
363 363
     {
364
-        if ($this->whitespace === []) {
364
+        if ($this->whitespace === []){
365 365
             return;
366 366
         }
367 367
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
      */
375 375
     private function flushKeyword(): void
376 376
     {
377
-        if ($this->keyword === []) {
377
+        if ($this->keyword === []){
378 378
             return;
379 379
         }
380 380
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
      */
388 388
     private function flushAttribute(): void
389 389
     {
390
-        if ($this->attribute === []) {
390
+        if ($this->attribute === []){
391 391
             return;
392 392
         }
393 393
 
Please login to merge, or discard this patch.
Braces   +81 added lines, -40 removed lines patch added patch discarded remove patch
@@ -57,15 +57,18 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function parse(Buffer $src): Generator
59 59
     {
60
-        while ($n = $src->next()) {
61
-            if (!$n instanceof Byte || $n->char !== '<') {
60
+        while ($n = $src->next())
61
+        {
62
+            if (!$n instanceof Byte || $n->char !== '<')
63
+            {
62 64
                 yield $n;
63 65
                 continue;
64 66
             }
65 67
 
66 68
             // work with isolated token stream!
67 69
             $tag = (clone $this)->parseGrammar($src);
68
-            if ($tag === null) {
70
+            if ($tag === null)
71
+            {
69 72
                 yield $n;
70 73
                 $src->replay($n->offset);
71 74
                 continue;
@@ -74,7 +77,8 @@  discard block
 block discarded – undo
74 77
             $tagName = $this->tagName($tag);
75 78
 
76 79
             // todo: add support for custom tag list
77
-            if (in_array($tagName, self::VERBATIM_TAGS)) {
80
+            if (in_array($tagName, self::VERBATIM_TAGS))
81
+            {
78 82
                 yield from $tag;
79 83
                 yield from $this->parseVerbatim($src, $tagName);
80 84
                 continue;
@@ -90,7 +94,8 @@  discard block
 block discarded – undo
90 94
      */
91 95
     public static function tokenName(int $token): string
92 96
     {
93
-        switch ($token) {
97
+        switch ($token)
98
+        {
94 99
             case self::TYPE_RAW:
95 100
                 return 'HTML:RAW';
96 101
             case self::TYPE_KEYWORD:
@@ -123,26 +128,32 @@  discard block
 block discarded – undo
123 128
     {
124 129
         $chunks = [];
125 130
 
126
-        while ($n = $src->next()) {
127
-            if ($n instanceof Token) {
131
+        while ($n = $src->next())
132
+        {
133
+            if ($n instanceof Token)
134
+            {
128 135
                 $chunks[] = $n;
129 136
                 continue;
130 137
             }
131 138
 
132
-            switch ($n->char) {
139
+            switch ($n->char)
140
+            {
133 141
                 case '"':
134 142
                 case "'":
135 143
                 case '`':
136 144
                     $chunks[] = $n;
137 145
 
138 146
                     // language inclusions allow nested strings
139
-                    while ($nc = $src->next()) {
147
+                    while ($nc = $src->next())
148
+                    {
140 149
                         $chunks[] = $nc;
141
-                        if ($nc instanceof Token) {
150
+                        if ($nc instanceof Token)
151
+                        {
142 152
                             continue;
143 153
                         }
144 154
 
145
-                        if ($nc->char === $n->char) {
155
+                        if ($nc->char === $n->char)
156
+                        {
146 157
                             break;
147 158
                         }
148 159
                     }
@@ -153,22 +164,28 @@  discard block
 block discarded – undo
153 164
                     $chunks[] = $n;
154 165
 
155 166
                     $multiline = false;
156
-                    if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') {
157
-                        if ($src->lookaheadByte(1) === '*') {
167
+                    if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*')
168
+                    {
169
+                        if ($src->lookaheadByte(1) === '*')
170
+                        {
158 171
                             $multiline = true;
159 172
                         }
160 173
 
161 174
                         $chunks[] = $src->next();
162 175
 
163 176
                         // language inclusions allow nested strings
164
-                        while ($nc = $src->next()) {
165
-                            if ($nc instanceof Token) {
177
+                        while ($nc = $src->next())
178
+                        {
179
+                            if ($nc instanceof Token)
180
+                            {
166 181
                                 continue;
167 182
                             }
168 183
 
169
-                            if ($nc->char === '<') {
184
+                            if ($nc->char === '<')
185
+                            {
170 186
                                 $tag = (clone $this)->parseGrammar($src);
171
-                                if ($tag === null || $this->tagName($tag) !== $verbatim) {
187
+                                if ($tag === null || $this->tagName($tag) !== $verbatim)
188
+                                {
172 189
                                     $src->replay($n->offset);
173 190
                                     break;
174 191
                                 }
@@ -179,12 +196,16 @@  discard block
 block discarded – undo
179 196
 
180 197
                             $chunks[] = $nc;
181 198
 
182
-                            if ($multiline) {
183
-                                if ($nc->char === '*' && $src->lookaheadByte(1) === '/') {
199
+                            if ($multiline)
200
+                            {
201
+                                if ($nc->char === '*' && $src->lookaheadByte(1) === '/')
202
+                                {
184 203
                                     $chunks[] = $src->next();
185 204
                                     break;
186 205
                                 }
187
-                            } elseif ($nc->char === "\n") {
206
+                            }
207
+                            elseif ($nc->char === "\n")
208
+                            {
188 209
                                 break;
189 210
                             }
190 211
                         }
@@ -195,7 +216,8 @@  discard block
 block discarded – undo
195 216
                 case '<':
196 217
                     // tag beginning?
197 218
                     $tag = (clone $this)->parseGrammar($src);
198
-                    if ($tag === null || $this->tagName($tag) !== $verbatim) {
219
+                    if ($tag === null || $this->tagName($tag) !== $verbatim)
220
+                    {
199 221
                         $chunks[] = $n;
200 222
                         $src->replay($n->offset);
201 223
                         break;
@@ -215,8 +237,10 @@  discard block
 block discarded – undo
215 237
 
216 238
     private function tagName(array $tag): string
217 239
     {
218
-        foreach ($tag as $token) {
219
-            if ($token->type === self::TYPE_KEYWORD) {
240
+        foreach ($tag as $token)
241
+        {
242
+            if ($token->type === self::TYPE_KEYWORD)
243
+            {
220 244
                 return strtolower($token->content);
221 245
             }
222 246
         }
@@ -230,28 +254,34 @@  discard block
 block discarded – undo
230 254
             new Token(self::TYPE_OPEN, $src->getOffset(), '<'),
231 255
         ];
232 256
 
233
-        if ($src->lookaheadByte() === '/') {
257
+        if ($src->lookaheadByte() === '/')
258
+        {
234 259
             $this->tokens[0]->type = self::TYPE_OPEN_SHORT;
235 260
             $this->tokens[0]->content .= $src->next()->char;
236 261
         }
237 262
 
238
-        while ($n = $src->next()) {
239
-            if ($this->attribute !== []) {
263
+        while ($n = $src->next())
264
+        {
265
+            if ($this->attribute !== [])
266
+            {
240 267
                 $this->attribute[] = $n;
241 268
 
242
-                if ($n instanceof Byte && $n->char === $this->attribute[0]->char) {
269
+                if ($n instanceof Byte && $n->char === $this->attribute[0]->char)
270
+                {
243 271
                     $this->flushAttribute();
244 272
                 }
245 273
 
246 274
                 continue;
247 275
             }
248 276
 
249
-            if ($n instanceof Token) {
277
+            if ($n instanceof Token)
278
+            {
250 279
                 $this->keyword[] = $n;
251 280
                 continue;
252 281
             }
253 282
 
254
-            switch ($n->char) {
283
+            switch ($n->char)
284
+            {
255 285
                 case '"':
256 286
                 case "'":
257 287
                 case '`':
@@ -269,7 +299,8 @@  discard block
 block discarded – undo
269 299
                     break;
270 300
 
271 301
                 case '/':
272
-                    if ($src->lookaheadByte() === '>') {
302
+                    if ($src->lookaheadByte() === '>')
303
+                    {
273 304
                         $this->flush();
274 305
                         $this->tokens[] = new Token(
275 306
                             self::TYPE_CLOSE_SHORT,
@@ -293,7 +324,8 @@  discard block
 block discarded – undo
293 324
                     break 2;
294 325
 
295 326
                 default:
296
-                    if (preg_match(self::REGEXP_WHITESPACE, $n->char)) {
327
+                    if (preg_match(self::REGEXP_WHITESPACE, $n->char))
328
+                    {
297 329
                         $this->flushKeyword();
298 330
                         $this->whitespace[] = $n;
299 331
                         break;
@@ -301,7 +333,8 @@  discard block
 block discarded – undo
301 333
                     $this->flushWhitespace();
302 334
 
303 335
 
304
-                    if (!preg_match(self::REGEXP_KEYWORD, $n->char)) {
336
+                    if (!preg_match(self::REGEXP_KEYWORD, $n->char))
337
+                    {
305 338
                         // unexpected char
306 339
                         return null;
307 340
                     }
@@ -310,7 +343,8 @@  discard block
 block discarded – undo
310 343
             }
311 344
         }
312 345
 
313
-        if (!$this->isValid()) {
346
+        if (!$this->isValid())
347
+        {
314 348
             return null;
315 349
         }
316 350
 
@@ -320,17 +354,21 @@  discard block
 block discarded – undo
320 354
     private function isValid(): bool
321 355
     {
322 356
         // tag is too short or does not have name keyword
323
-        if (count($this->tokens) < 3) {
357
+        if (count($this->tokens) < 3)
358
+        {
324 359
             return false;
325 360
         }
326 361
 
327 362
         $last = $this->tokens[count($this->tokens) - 1];
328
-        if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) {
363
+        if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT)
364
+        {
329 365
             return false;
330 366
         }
331 367
 
332
-        foreach ($this->tokens as $token) {
333
-            switch ($token->type) {
368
+        foreach ($this->tokens as $token)
369
+        {
370
+            switch ($token->type)
371
+            {
334 372
                 case self::TYPE_WHITESPACE:
335 373
                     // ignore
336 374
                     continue 2;
@@ -361,7 +399,8 @@  discard block
 block discarded – undo
361 399
      */
362 400
     private function flushWhitespace(): void
363 401
     {
364
-        if ($this->whitespace === []) {
402
+        if ($this->whitespace === [])
403
+        {
365 404
             return;
366 405
         }
367 406
 
@@ -374,7 +413,8 @@  discard block
 block discarded – undo
374 413
      */
375 414
     private function flushKeyword(): void
376 415
     {
377
-        if ($this->keyword === []) {
416
+        if ($this->keyword === [])
417
+        {
378 418
             return;
379 419
         }
380 420
 
@@ -387,7 +427,8 @@  discard block
 block discarded – undo
387 427
      */
388 428
     private function flushAttribute(): void
389 429
     {
390
-        if ($this->attribute === []) {
430
+        if ($this->attribute === [])
431
+        {
391 432
             return;
392 433
         }
393 434
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/InlineGrammar.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function parse(Buffer $src): Generator
51 51
     {
52
-        while ($n = $src->next()) {
53
-            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') {
52
+        while ($n = $src->next()){
53
+            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{'){
54 54
                 yield $n;
55 55
                 continue;
56 56
             }
57 57
 
58 58
             $binding = (clone $this)->parseGrammar($src, $n->offset);
59
-            if ($binding === null) {
59
+            if ($binding === null){
60 60
                 yield $n;
61 61
                 $src->replay($n->offset);
62 62
                 continue;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public static function tokenName(int $token): string
74 74
     {
75
-        switch ($token) {
75
+        switch ($token){
76 76
             case self::TYPE_OPEN_TAG:
77 77
                 return 'INLINE:OPEN_TAG';
78 78
             case self::TYPE_CLOSE_TAG:
@@ -94,27 +94,27 @@  discard block
 block discarded – undo
94 94
     private function parseGrammar(Buffer $src, int $offset): ?array
95 95
     {
96 96
         $this->tokens = [
97
-            new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char),
97
+            new Token(self::TYPE_OPEN_TAG, $offset, '$'.$src->next()->char),
98 98
         ];
99 99
 
100
-        while ($n = $src->next()) {
101
-            if (!$n instanceof Byte) {
100
+        while ($n = $src->next()){
101
+            if (!$n instanceof Byte){
102 102
                 // no other grammars are allowed
103 103
                 return null;
104 104
             }
105 105
 
106
-            switch ($n->char) {
106
+            switch ($n->char){
107 107
                 case '"':
108 108
                 case "'":
109
-                    if ($this->default === null) {
109
+                    if ($this->default === null){
110 110
                         // " and ' not allowed in names
111 111
                         return null;
112 112
                     }
113 113
 
114 114
                     $this->default[] = $n;
115
-                    while ($nn = $src->next()) {
115
+                    while ($nn = $src->next()){
116 116
                         $this->default[] = $nn;
117
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
117
+                        if ($nn instanceof Byte && $nn->char === $n->char){
118 118
                             break;
119 119
                         }
120 120
                     }
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
                     break;
148 148
 
149 149
                 default:
150
-                    if ($this->default !== null) {
150
+                    if ($this->default !== null){
151 151
                         // default allows spaces
152 152
                         $this->default[] = $n;
153 153
                         break;
154 154
                     }
155 155
 
156
-                    if (preg_match(self::REGEXP_WHITESPACE, $n->char)) {
156
+                    if (preg_match(self::REGEXP_WHITESPACE, $n->char)){
157 157
                         break;
158 158
                     }
159 159
 
160
-                    if (preg_match(self::REGEXP_KEYWORD, $n->char)) {
160
+                    if (preg_match(self::REGEXP_KEYWORD, $n->char)){
161 161
                         $this->name[] = $n;
162 162
                         break;
163 163
                     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             }
167 167
         }
168 168
 
169
-        if (!$this->isValid()) {
169
+        if (!$this->isValid()){
170 170
             return null;
171 171
         }
172 172
 
@@ -175,25 +175,25 @@  discard block
 block discarded – undo
175 175
 
176 176
     private function isValid(): bool
177 177
     {
178
-        if (count($this->tokens) < 3) {
178
+        if (count($this->tokens) < 3){
179 179
             return false;
180 180
         }
181 181
 
182 182
         $hasName = false;
183 183
         $hasDefault = null;
184
-        foreach ($this->tokens as $token) {
185
-            if ($token->type === self::TYPE_NAME) {
184
+        foreach ($this->tokens as $token){
185
+            if ($token->type === self::TYPE_NAME){
186 186
                 $hasName = true;
187 187
                 continue;
188 188
             }
189 189
 
190
-            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) {
190
+            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null){
191 191
                 $hasDefault = false;
192 192
                 continue;
193 193
             }
194 194
 
195
-            if ($token->type === self::TYPE_DEFAULT) {
196
-                if ($hasDefault === true) {
195
+            if ($token->type === self::TYPE_DEFAULT){
196
+                if ($hasDefault === true){
197 197
                     // multiple default value
198 198
                     return false;
199 199
                 }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     private function flushName(): void
212 212
     {
213
-        if ($this->name === []) {
213
+        if ($this->name === []){
214 214
             return;
215 215
         }
216 216
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     private function flushDefault(): void
225 225
     {
226
-        if ($this->default === [] || $this->default === null) {
226
+        if ($this->default === [] || $this->default === null){
227 227
             return;
228 228
         }
229 229
 
Please login to merge, or discard this patch.
Braces   +44 added lines, -22 removed lines patch added patch discarded remove patch
@@ -49,14 +49,17 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function parse(Buffer $src): Generator
51 51
     {
52
-        while ($n = $src->next()) {
53
-            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') {
52
+        while ($n = $src->next())
53
+        {
54
+            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{')
55
+            {
54 56
                 yield $n;
55 57
                 continue;
56 58
             }
57 59
 
58 60
             $binding = (clone $this)->parseGrammar($src, $n->offset);
59
-            if ($binding === null) {
61
+            if ($binding === null)
62
+            {
60 63
                 yield $n;
61 64
                 $src->replay($n->offset);
62 65
                 continue;
@@ -72,7 +75,8 @@  discard block
 block discarded – undo
72 75
      */
73 76
     public static function tokenName(int $token): string
74 77
     {
75
-        switch ($token) {
78
+        switch ($token)
79
+        {
76 80
             case self::TYPE_OPEN_TAG:
77 81
                 return 'INLINE:OPEN_TAG';
78 82
             case self::TYPE_CLOSE_TAG:
@@ -97,24 +101,30 @@  discard block
 block discarded – undo
97 101
             new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char),
98 102
         ];
99 103
 
100
-        while ($n = $src->next()) {
101
-            if (!$n instanceof Byte) {
104
+        while ($n = $src->next())
105
+        {
106
+            if (!$n instanceof Byte)
107
+            {
102 108
                 // no other grammars are allowed
103 109
                 return null;
104 110
             }
105 111
 
106
-            switch ($n->char) {
112
+            switch ($n->char)
113
+            {
107 114
                 case '"':
108 115
                 case "'":
109
-                    if ($this->default === null) {
116
+                    if ($this->default === null)
117
+                    {
110 118
                         // " and ' not allowed in names
111 119
                         return null;
112 120
                     }
113 121
 
114 122
                     $this->default[] = $n;
115
-                    while ($nn = $src->next()) {
123
+                    while ($nn = $src->next())
124
+                    {
116 125
                         $this->default[] = $nn;
117
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
126
+                        if ($nn instanceof Byte && $nn->char === $n->char)
127
+                        {
118 128
                             break;
119 129
                         }
120 130
                     }
@@ -147,17 +157,20 @@  discard block
 block discarded – undo
147 157
                     break;
148 158
 
149 159
                 default:
150
-                    if ($this->default !== null) {
160
+                    if ($this->default !== null)
161
+                    {
151 162
                         // default allows spaces
152 163
                         $this->default[] = $n;
153 164
                         break;
154 165
                     }
155 166
 
156
-                    if (preg_match(self::REGEXP_WHITESPACE, $n->char)) {
167
+                    if (preg_match(self::REGEXP_WHITESPACE, $n->char))
168
+                    {
157 169
                         break;
158 170
                     }
159 171
 
160
-                    if (preg_match(self::REGEXP_KEYWORD, $n->char)) {
172
+                    if (preg_match(self::REGEXP_KEYWORD, $n->char))
173
+                    {
161 174
                         $this->name[] = $n;
162 175
                         break;
163 176
                     }
@@ -166,7 +179,8 @@  discard block
 block discarded – undo
166 179
             }
167 180
         }
168 181
 
169
-        if (!$this->isValid()) {
182
+        if (!$this->isValid())
183
+        {
170 184
             return null;
171 185
         }
172 186
 
@@ -175,25 +189,31 @@  discard block
 block discarded – undo
175 189
 
176 190
     private function isValid(): bool
177 191
     {
178
-        if (count($this->tokens) < 3) {
192
+        if (count($this->tokens) < 3)
193
+        {
179 194
             return false;
180 195
         }
181 196
 
182 197
         $hasName = false;
183 198
         $hasDefault = null;
184
-        foreach ($this->tokens as $token) {
185
-            if ($token->type === self::TYPE_NAME) {
199
+        foreach ($this->tokens as $token)
200
+        {
201
+            if ($token->type === self::TYPE_NAME)
202
+            {
186 203
                 $hasName = true;
187 204
                 continue;
188 205
             }
189 206
 
190
-            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) {
207
+            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null)
208
+            {
191 209
                 $hasDefault = false;
192 210
                 continue;
193 211
             }
194 212
 
195
-            if ($token->type === self::TYPE_DEFAULT) {
196
-                if ($hasDefault === true) {
213
+            if ($token->type === self::TYPE_DEFAULT)
214
+            {
215
+                if ($hasDefault === true)
216
+                {
197 217
                     // multiple default value
198 218
                     return false;
199 219
                 }
@@ -210,7 +230,8 @@  discard block
 block discarded – undo
210 230
      */
211 231
     private function flushName(): void
212 232
     {
213
-        if ($this->name === []) {
233
+        if ($this->name === [])
234
+        {
214 235
             return;
215 236
         }
216 237
 
@@ -223,7 +244,8 @@  discard block
 block discarded – undo
223 244
      */
224 245
     private function flushDefault(): void
225 246
     {
226
-        if ($this->default === [] || $this->default === null) {
247
+        if ($this->default === [] || $this->default === null)
248
+        {
227 249
             return;
228 250
         }
229 251
 
Please login to merge, or discard this patch.
src/Hmvc/src/AbstractCore.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function callAction(string $controller, string $action, array $parameters = [])
46 46
     {
47
-        try {
47
+        try{
48 48
             $method = new ReflectionMethod($controller, $action);
49
-        } catch (ReflectionException $e) {
49
+        }catch (ReflectionException $e){
50 50
             throw new ControllerException(
51 51
                 "Invalid action `{$controller}`->`{$action}`",
52 52
                 ControllerException::BAD_ACTION,
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
             );
55 55
         }
56 56
 
57
-        if ($method->isStatic() || !$method->isPublic()) {
57
+        if ($method->isStatic() || !$method->isPublic()){
58 58
             throw new ControllerException(
59 59
                 "Invalid action `{$controller}`->`{$action}`",
60 60
                 ControllerException::BAD_ACTION
61 61
             );
62 62
         }
63 63
 
64
-        try {
64
+        try{
65 65
             // getting the set of arguments should be sent to requested method
66 66
             $args = $this->resolver->resolveArguments($method, $parameters);
67
-        } catch (ArgumentException $e) {
67
+        }catch (ArgumentException $e){
68 68
             throw new ControllerException(
69 69
                 "Missing/invalid parameter '{$e->getParameter()->name}' of  `{$controller}`->`{$action}`",
70 70
                 ControllerException::BAD_ARGUMENT
71 71
             );
72
-        } catch (ContainerExceptionInterface $e) {
72
+        }catch (ContainerExceptionInterface $e){
73 73
             throw new ControllerException(
74 74
                 $e->getMessage(),
75 75
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,9 +44,12 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function callAction(string $controller, string $action, array $parameters = [])
46 46
     {
47
-        try {
47
+        try
48
+        {
48 49
             $method = new ReflectionMethod($controller, $action);
49
-        } catch (ReflectionException $e) {
50
+        }
51
+        catch (ReflectionException $e)
52
+        {
50 53
             throw new ControllerException(
51 54
                 "Invalid action `{$controller}`->`{$action}`",
52 55
                 ControllerException::BAD_ACTION,
@@ -54,22 +57,28 @@  discard block
 block discarded – undo
54 57
             );
55 58
         }
56 59
 
57
-        if ($method->isStatic() || !$method->isPublic()) {
60
+        if ($method->isStatic() || !$method->isPublic())
61
+        {
58 62
             throw new ControllerException(
59 63
                 "Invalid action `{$controller}`->`{$action}`",
60 64
                 ControllerException::BAD_ACTION
61 65
             );
62 66
         }
63 67
 
64
-        try {
68
+        try
69
+        {
65 70
             // getting the set of arguments should be sent to requested method
66 71
             $args = $this->resolver->resolveArguments($method, $parameters);
67
-        } catch (ArgumentException $e) {
72
+        }
73
+        catch (ArgumentException $e)
74
+        {
68 75
             throw new ControllerException(
69 76
                 "Missing/invalid parameter '{$e->getParameter()->name}' of  `{$controller}`->`{$action}`",
70 77
                 ControllerException::BAD_ARGUMENT
71 78
             );
72
-        } catch (ContainerExceptionInterface $e) {
79
+        }
80
+        catch (ContainerExceptionInterface $e)
81
+        {
73 82
             throw new ControllerException(
74 83
                 $e->getMessage(),
75 84
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
src/Exceptions/src/ConsoleHandler.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $result = '';
70 70
 
71
-        if ($e instanceof Error) {
72
-            $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:magenta,white');
73
-        } else {
74
-            $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:red,white');
71
+        if ($e instanceof Error){
72
+            $result .= $this->renderHeader('['.get_class($e)."]\n".$e->getMessage(), 'bg:magenta,white');
73
+        }else{
74
+            $result .= $this->renderHeader('['.get_class($e)."]\n".$e->getMessage(), 'bg:red,white');
75 75
         }
76 76
 
77 77
         $result .= $this->format(
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
             $e->getLine()
81 81
         );
82 82
 
83
-        if ($verbosity >= self::VERBOSITY_DEBUG) {
83
+        if ($verbosity >= self::VERBOSITY_DEBUG){
84 84
             $result .= $this->renderTrace($e, new Highlighter(
85 85
                 $this->colorsSupport ? new ConsoleStyle() : new PlainStyle()
86 86
             ));
87
-        } elseif ($verbosity >= self::VERBOSITY_VERBOSE) {
87
+        } elseif ($verbosity >= self::VERBOSITY_VERBOSE){
88 88
             $result .= $this->renderTrace($e);
89 89
         }
90 90
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         $length += $padding;
112 112
 
113
-        foreach ($lines as $line) {
113
+        foreach ($lines as $line){
114 114
             $result .= $this->format(
115 115
                 "<{$style}>%s%s%s</reset>\n",
116 116
                 str_repeat(' ', $padding + 1),
@@ -130,34 +130,34 @@  discard block
 block discarded – undo
130 130
     private function renderTrace(Throwable $e, Highlighter $h = null): string
131 131
     {
132 132
         $stacktrace = $this->getStacktrace($e);
133
-        if (empty($stacktrace)) {
133
+        if (empty($stacktrace)){
134 134
             return '';
135 135
         }
136 136
 
137 137
         $result = $this->format("\n<red>Exception Trace:</reset>\n");
138 138
 
139
-        foreach ($stacktrace as $trace) {
140
-            if (isset($trace['type']) && isset($trace['class'])) {
139
+        foreach ($stacktrace as $trace){
140
+            if (isset($trace['type']) && isset($trace['class'])){
141 141
                 $line = $this->format(
142 142
                     ' <white>%s%s%s()</reset>',
143 143
                     $trace['class'],
144 144
                     $trace['type'],
145 145
                     $trace['function']
146 146
                 );
147
-            } else {
147
+            }else{
148 148
                 $line = $this->format(
149 149
                     ' <white>%s()</reset>',
150 150
                     $trace['function']
151 151
                 );
152 152
             }
153 153
 
154
-            if (isset($trace['file'])) {
154
+            if (isset($trace['file'])){
155 155
                 $line .= $this->format(
156 156
                     ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>',
157 157
                     $trace['file'],
158 158
                     $trace['line']
159 159
                 );
160
-            } else {
160
+            }else{
161 161
                 $line .= $this->format(
162 162
                     ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>',
163 163
                     'n/a',
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
                 );
166 166
             }
167 167
 
168
-            $result .= $line . "\n";
168
+            $result .= $line."\n";
169 169
 
170
-            if (!empty($h) && !empty($trace['file'])) {
170
+            if (!empty($h) && !empty($trace['file'])){
171 171
                 $result .= $h->highlightLines(
172 172
                     file_get_contents($trace['file']),
173 173
                     $trace['line'],
174 174
                     static::SHOW_LINES
175
-                ) . "\n";
175
+                )."\n";
176 176
             }
177 177
         }
178 178
 
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
      */
187 187
     private function format(string $format, ...$args): string
188 188
     {
189
-        if (!$this->colorsSupport) {
189
+        if (!$this->colorsSupport){
190 190
             $format = preg_replace('/<[^>]+>/', '', $format);
191
-        } else {
192
-            $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial) {
191
+        }else{
192
+            $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial){
193 193
                 $style = '';
194
-                foreach (explode(',', trim($partial[2], '/')) as $color) {
195
-                    if (isset(self::COLORS[$color])) {
194
+                foreach (explode(',', trim($partial[2], '/')) as $color){
195
+                    if (isset(self::COLORS[$color])){
196 196
                         $style .= self::COLORS[$color];
197 197
                     }
198 198
                 }
Please login to merge, or discard this patch.
Braces   +39 added lines, -17 removed lines patch added patch discarded remove patch
@@ -68,9 +68,12 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $result = '';
70 70
 
71
-        if ($e instanceof Error) {
71
+        if ($e instanceof Error)
72
+        {
72 73
             $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:magenta,white');
73
-        } else {
74
+        }
75
+        else
76
+        {
74 77
             $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:red,white');
75 78
         }
76 79
 
@@ -80,11 +83,14 @@  discard block
 block discarded – undo
80 83
             $e->getLine()
81 84
         );
82 85
 
83
-        if ($verbosity >= self::VERBOSITY_DEBUG) {
86
+        if ($verbosity >= self::VERBOSITY_DEBUG)
87
+        {
84 88
             $result .= $this->renderTrace($e, new Highlighter(
85 89
                 $this->colorsSupport ? new ConsoleStyle() : new PlainStyle()
86 90
             ));
87
-        } elseif ($verbosity >= self::VERBOSITY_VERBOSE) {
91
+        }
92
+        elseif ($verbosity >= self::VERBOSITY_VERBOSE)
93
+        {
88 94
             $result .= $this->renderTrace($e);
89 95
         }
90 96
 
@@ -110,7 +116,8 @@  discard block
 block discarded – undo
110 116
 
111 117
         $length += $padding;
112 118
 
113
-        foreach ($lines as $line) {
119
+        foreach ($lines as $line)
120
+        {
114 121
             $result .= $this->format(
115 122
                 "<{$style}>%s%s%s</reset>\n",
116 123
                 str_repeat(' ', $padding + 1),
@@ -130,34 +137,42 @@  discard block
 block discarded – undo
130 137
     private function renderTrace(Throwable $e, Highlighter $h = null): string
131 138
     {
132 139
         $stacktrace = $this->getStacktrace($e);
133
-        if (empty($stacktrace)) {
140
+        if (empty($stacktrace))
141
+        {
134 142
             return '';
135 143
         }
136 144
 
137 145
         $result = $this->format("\n<red>Exception Trace:</reset>\n");
138 146
 
139
-        foreach ($stacktrace as $trace) {
140
-            if (isset($trace['type']) && isset($trace['class'])) {
147
+        foreach ($stacktrace as $trace)
148
+        {
149
+            if (isset($trace['type']) && isset($trace['class']))
150
+            {
141 151
                 $line = $this->format(
142 152
                     ' <white>%s%s%s()</reset>',
143 153
                     $trace['class'],
144 154
                     $trace['type'],
145 155
                     $trace['function']
146 156
                 );
147
-            } else {
157
+            }
158
+            else
159
+            {
148 160
                 $line = $this->format(
149 161
                     ' <white>%s()</reset>',
150 162
                     $trace['function']
151 163
                 );
152 164
             }
153 165
 
154
-            if (isset($trace['file'])) {
166
+            if (isset($trace['file']))
167
+            {
155 168
                 $line .= $this->format(
156 169
                     ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>',
157 170
                     $trace['file'],
158 171
                     $trace['line']
159 172
                 );
160
-            } else {
173
+            }
174
+            else
175
+            {
161 176
                 $line .= $this->format(
162 177
                     ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>',
163 178
                     'n/a',
@@ -167,7 +182,8 @@  discard block
 block discarded – undo
167 182
 
168 183
             $result .= $line . "\n";
169 184
 
170
-            if (!empty($h) && !empty($trace['file'])) {
185
+            if (!empty($h) && !empty($trace['file']))
186
+            {
171 187
                 $result .= $h->highlightLines(
172 188
                     file_get_contents($trace['file']),
173 189
                     $trace['line'],
@@ -186,13 +202,19 @@  discard block
 block discarded – undo
186 202
      */
187 203
     private function format(string $format, ...$args): string
188 204
     {
189
-        if (!$this->colorsSupport) {
205
+        if (!$this->colorsSupport)
206
+        {
190 207
             $format = preg_replace('/<[^>]+>/', '', $format);
191
-        } else {
192
-            $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial) {
208
+        }
209
+        else
210
+        {
211
+            $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial)
212
+            {
193 213
                 $style = '';
194
-                foreach (explode(',', trim($partial[2], '/')) as $color) {
195
-                    if (isset(self::COLORS[$color])) {
214
+                foreach (explode(',', trim($partial[2], '/')) as $color)
215
+                {
216
+                    if (isset(self::COLORS[$color]))
217
+                    {
196 218
                         $style .= self::COLORS[$color];
197 219
                     }
198 220
                 }
Please login to merge, or discard this patch.
src/Exceptions/src/PlainHandler.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $result = '';
28 28
 
29
-        $result .= '[' . get_class($e) . "]\n" . $e->getMessage();
29
+        $result .= '['.get_class($e)."]\n".$e->getMessage();
30 30
 
31 31
         $result .= sprintf(" in %s:%s\n", $e->getFile(), $e->getLine());
32 32
 
33
-        if ($verbosity >= self::VERBOSITY_DEBUG) {
33
+        if ($verbosity >= self::VERBOSITY_DEBUG){
34 34
             $result .= $this->renderTrace($e, new Highlighter(new PlainStyle()));
35
-        } elseif ($verbosity >= self::VERBOSITY_VERBOSE) {
35
+        } elseif ($verbosity >= self::VERBOSITY_VERBOSE){
36 36
             $result .= $this->renderTrace($e);
37 37
         }
38 38
 
@@ -47,38 +47,38 @@  discard block
 block discarded – undo
47 47
     private function renderTrace(Throwable $e, Highlighter $h = null): string
48 48
     {
49 49
         $stacktrace = $this->getStacktrace($e);
50
-        if (empty($stacktrace)) {
50
+        if (empty($stacktrace)){
51 51
             return '';
52 52
         }
53 53
 
54 54
         $result = "\nException Trace:\n";
55 55
 
56
-        foreach ($stacktrace as $trace) {
57
-            if (isset($trace['type']) && isset($trace['class'])) {
56
+        foreach ($stacktrace as $trace){
57
+            if (isset($trace['type']) && isset($trace['class'])){
58 58
                 $line = sprintf(
59 59
                     ' %s%s%s()',
60 60
                     $trace['class'],
61 61
                     $trace['type'],
62 62
                     $trace['function']
63 63
                 );
64
-            } else {
64
+            }else{
65 65
                 $line = $trace['function'];
66 66
             }
67 67
 
68
-            if (isset($trace['file'])) {
68
+            if (isset($trace['file'])){
69 69
                 $line .= sprintf(' at %s:%s', $trace['file'], $trace['line']);
70
-            } else {
70
+            }else{
71 71
                 $line .= sprintf(' at %s:%s', 'n/a', 'n/a');
72 72
             }
73 73
 
74
-            $result .= $line . "\n";
74
+            $result .= $line."\n";
75 75
 
76
-            if (!empty($h) && !empty($trace['file'])) {
76
+            if (!empty($h) && !empty($trace['file'])){
77 77
                 $result .= $h->highlightLines(
78 78
                     file_get_contents($trace['file']),
79 79
                     $trace['line'],
80 80
                     static::SHOW_LINES
81
-                ) . "\n";
81
+                )."\n";
82 82
             }
83 83
         }
84 84
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,9 +30,12 @@  discard block
 block discarded – undo
30 30
 
31 31
         $result .= sprintf(" in %s:%s\n", $e->getFile(), $e->getLine());
32 32
 
33
-        if ($verbosity >= self::VERBOSITY_DEBUG) {
33
+        if ($verbosity >= self::VERBOSITY_DEBUG)
34
+        {
34 35
             $result .= $this->renderTrace($e, new Highlighter(new PlainStyle()));
35
-        } elseif ($verbosity >= self::VERBOSITY_VERBOSE) {
36
+        }
37
+        elseif ($verbosity >= self::VERBOSITY_VERBOSE)
38
+        {
36 39
             $result .= $this->renderTrace($e);
37 40
         }
38 41
 
@@ -47,33 +50,42 @@  discard block
 block discarded – undo
47 50
     private function renderTrace(Throwable $e, Highlighter $h = null): string
48 51
     {
49 52
         $stacktrace = $this->getStacktrace($e);
50
-        if (empty($stacktrace)) {
53
+        if (empty($stacktrace))
54
+        {
51 55
             return '';
52 56
         }
53 57
 
54 58
         $result = "\nException Trace:\n";
55 59
 
56
-        foreach ($stacktrace as $trace) {
57
-            if (isset($trace['type']) && isset($trace['class'])) {
60
+        foreach ($stacktrace as $trace)
61
+        {
62
+            if (isset($trace['type']) && isset($trace['class']))
63
+            {
58 64
                 $line = sprintf(
59 65
                     ' %s%s%s()',
60 66
                     $trace['class'],
61 67
                     $trace['type'],
62 68
                     $trace['function']
63 69
                 );
64
-            } else {
70
+            }
71
+            else
72
+            {
65 73
                 $line = $trace['function'];
66 74
             }
67 75
 
68
-            if (isset($trace['file'])) {
76
+            if (isset($trace['file']))
77
+            {
69 78
                 $line .= sprintf(' at %s:%s', $trace['file'], $trace['line']);
70
-            } else {
79
+            }
80
+            else
81
+            {
71 82
                 $line .= sprintf(' at %s:%s', 'n/a', 'n/a');
72 83
             }
73 84
 
74 85
             $result .= $line . "\n";
75 86
 
76
-            if (!empty($h) && !empty($trace['file'])) {
87
+            if (!empty($h) && !empty($trace['file']))
88
+            {
77 89
                 $result .= $h->highlightLines(
78 90
                     file_get_contents($trace['file']),
79 91
                     $trace['line'],
Please login to merge, or discard this patch.
src/Exceptions/src/AbstractHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     protected function getStacktrace(Throwable $e): array
33 33
     {
34 34
         $stacktrace = $e->getTrace();
35
-        if (empty($stacktrace)) {
35
+        if (empty($stacktrace)){
36 36
             return [];
37 37
         }
38 38
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                 'line' => $e->getLine(),
43 43
             ] + $stacktrace[0];
44 44
 
45
-        if ($stacktrace[0] != $header) {
45
+        if ($stacktrace[0] != $header){
46 46
             array_unshift($stacktrace, $header);
47 47
         }
48 48
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,8 @@  discard block
 block discarded – undo
32 32
     protected function getStacktrace(Throwable $e): array
33 33
     {
34 34
         $stacktrace = $e->getTrace();
35
-        if (empty($stacktrace)) {
35
+        if (empty($stacktrace))
36
+        {
36 37
             return [];
37 38
         }
38 39
 
@@ -42,7 +43,8 @@  discard block
 block discarded – undo
42 43
                 'line' => $e->getLine(),
43 44
             ] + $stacktrace[0];
44 45
 
45
-        if ($stacktrace[0] != $header) {
46
+        if ($stacktrace[0] != $header)
47
+        {
46 48
             array_unshift($stacktrace, $header);
47 49
         }
48 50
 
Please login to merge, or discard this patch.
src/Exceptions/src/ValueWrapper.php 3 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,33 +43,33 @@
 block discarded – undo
43 43
     public function wrap(array $args): array
44 44
     {
45 45
         $result = [];
46
-        foreach ($args as $arg) {
46
+        foreach ($args as $arg){
47 47
             $display = $type = strtolower(gettype($arg));
48 48
 
49
-            if (is_numeric($arg)) {
49
+            if (is_numeric($arg)){
50 50
                 $result[] = $this->r->apply($arg, 'value', $type);
51 51
                 continue;
52
-            } elseif (is_bool($arg)) {
52
+            } elseif (is_bool($arg)){
53 53
                 $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type);
54 54
                 continue;
55
-            } elseif (is_null($arg)) {
55
+            } elseif (is_null($arg)){
56 56
                 $result[] = $this->r->apply('null', 'value', $type);
57 57
                 continue;
58 58
             }
59 59
 
60
-            if (is_object($arg)) {
60
+            if (is_object($arg)){
61 61
                 $reflection = new ReflectionClass($arg);
62 62
                 $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName());
63 63
             }
64 64
 
65 65
             $type = $this->r->apply($display, 'value', $type);
66 66
 
67
-            if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) {
67
+            if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG){
68 68
                 $result[] = sprintf('<span>%s</span>', $type);
69
-            } else {
69
+            }else{
70 70
                 $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR));
71 71
 
72
-                if (!isset($this->values[$hash])) {
72
+                if (!isset($this->values[$hash])){
73 73
                     $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN);
74 74
                 }
75 75
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,33 +43,44 @@
 block discarded – undo
43 43
     public function wrap(array $args): array
44 44
     {
45 45
         $result = [];
46
-        foreach ($args as $arg) {
46
+        foreach ($args as $arg)
47
+        {
47 48
             $display = $type = strtolower(gettype($arg));
48 49
 
49
-            if (is_numeric($arg)) {
50
+            if (is_numeric($arg))
51
+            {
50 52
                 $result[] = $this->r->apply($arg, 'value', $type);
51 53
                 continue;
52
-            } elseif (is_bool($arg)) {
54
+            }
55
+            elseif (is_bool($arg))
56
+            {
53 57
                 $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type);
54 58
                 continue;
55
-            } elseif (is_null($arg)) {
59
+            }
60
+            elseif (is_null($arg))
61
+            {
56 62
                 $result[] = $this->r->apply('null', 'value', $type);
57 63
                 continue;
58 64
             }
59 65
 
60
-            if (is_object($arg)) {
66
+            if (is_object($arg))
67
+            {
61 68
                 $reflection = new ReflectionClass($arg);
62 69
                 $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName());
63 70
             }
64 71
 
65 72
             $type = $this->r->apply($display, 'value', $type);
66 73
 
67
-            if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) {
74
+            if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG)
75
+            {
68 76
                 $result[] = sprintf('<span>%s</span>', $type);
69
-            } else {
77
+            }
78
+            else
79
+            {
70 80
                 $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR));
71 81
 
72
-                if (!isset($this->values[$hash])) {
82
+                if (!isset($this->values[$hash]))
83
+                {
73 84
                     $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN);
74 85
                 }
75 86
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
                 $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR));
71 71
 
72 72
                 if (!isset($this->values[$hash])) {
73
-                    $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN);
73
+                    $this->values[$hash] = $this->dumper->dump($arg, Dumper::return);
74 74
                 }
75 75
 
76 76
                 $result[] = sprintf('<span onclick="_da(\'%s\')">%s</span>', $hash, $type);
Please login to merge, or discard this patch.
src/Exceptions/src/JsonHandler.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,24 +32,24 @@
 block discarded – undo
32 32
 
33 33
     private function renderTrace(array $trace, int $verbosity): Generator
34 34
     {
35
-        foreach ($trace as $item) {
35
+        foreach ($trace as $item){
36 36
             $result = [];
37 37
 
38
-            if (isset($item['class'])) {
38
+            if (isset($item['class'])){
39 39
                 $result['function'] = sprintf(
40 40
                     '%s%s%s()',
41 41
                     $item['class'],
42 42
                     $item['type'],
43 43
                     $item['function']
44 44
                 );
45
-            } else {
45
+            }else{
46 46
                 $result['function'] = sprintf(
47 47
                     '%s()',
48 48
                     $item['function']
49 49
                 );
50 50
             }
51 51
 
52
-            if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) {
52
+            if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])){
53 53
                 $result['at'] = [
54 54
                     'file' => $item['file'] ?? null,
55 55
                     'line' => $item['line'] ?? null,
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,24 +32,29 @@
 block discarded – undo
32 32
 
33 33
     private function renderTrace(array $trace, int $verbosity): Generator
34 34
     {
35
-        foreach ($trace as $item) {
35
+        foreach ($trace as $item)
36
+        {
36 37
             $result = [];
37 38
 
38
-            if (isset($item['class'])) {
39
+            if (isset($item['class']))
40
+            {
39 41
                 $result['function'] = sprintf(
40 42
                     '%s%s%s()',
41 43
                     $item['class'],
42 44
                     $item['type'],
43 45
                     $item['function']
44 46
                 );
45
-            } else {
47
+            }
48
+            else
49
+            {
46 50
                 $result['function'] = sprintf(
47 51
                     '%s()',
48 52
                     $item['function']
49 53
                 );
50 54
             }
51 55
 
52
-            if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) {
56
+            if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file']))
57
+            {
53 58
                 $result['at'] = [
54 59
                     'file' => $item['file'] ?? null,
55 60
                     'line' => $item['line'] ?? null,
Please login to merge, or discard this patch.