Passed
Pull Request — master (#1208)
by Aleksei
12:46
created
src/Stempler/src/Directive/ConditionalDirective.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function renderCase(Directive $directive): string
74 74
     {
75
-        if ($this->firstSwitchCase) {
75
+        if ($this->firstSwitchCase){
76 76
             $this->firstSwitchCase = false;
77 77
 
78 78
             return \sprintf('case (%s): ?>', $directive->body);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
     public function renderDefault(Directive $directive): string
85 85
     {
86
-        if ($this->firstSwitchCase) {
86
+        if ($this->firstSwitchCase){
87 87
             $this->firstSwitchCase = false;
88 88
 
89 89
             return 'default: ?>';
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
     public function renderBreak(Directive $directive): string
101 101
     {
102
-        if (isset($directive->values[0])) {
102
+        if (isset($directive->values[0])){
103 103
             return \sprintf('<?php break %s; ?>', $directive->values[0]);
104 104
         }
105 105
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,8 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function renderCase(Directive $directive): string
74 74
     {
75
-        if ($this->firstSwitchCase) {
75
+        if ($this->firstSwitchCase)
76
+        {
76 77
             $this->firstSwitchCase = false;
77 78
 
78 79
             return \sprintf('case (%s): ?>', $directive->body);
@@ -83,7 +84,8 @@  discard block
 block discarded – undo
83 84
 
84 85
     public function renderDefault(Directive $directive): string
85 86
     {
86
-        if ($this->firstSwitchCase) {
87
+        if ($this->firstSwitchCase)
88
+        {
87 89
             $this->firstSwitchCase = false;
88 90
 
89 91
             return 'default: ?>';
@@ -99,7 +101,8 @@  discard block
 block discarded – undo
99 101
 
100 102
     public function renderBreak(Directive $directive): string
101 103
     {
102
-        if (isset($directive->values[0])) {
104
+        if (isset($directive->values[0]))
105
+        {
103 106
             return \sprintf('<?php break %s; ?>', $directive->values[0]);
104 107
         }
105 108
 
Please login to merge, or discard this patch.
src/Stempler/src/Directive/LoopDirective.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function renderBreak(Directive $directive): string
35 35
     {
36
-        if (isset($directive->values[0])) {
36
+        if (isset($directive->values[0])){
37 37
             return \sprintf('<?php break %s; ?>', $directive->values[0]);
38 38
         }
39 39
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function renderContinue(Directive $directive): string
44 44
     {
45
-        if (isset($directive->values[0])) {
45
+        if (isset($directive->values[0])){
46 46
             return \sprintf('<?php continue %s; ?>', $directive->values[0]);
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
@@ -33,7 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function renderBreak(Directive $directive): string
35 35
     {
36
-        if (isset($directive->values[0])) {
36
+        if (isset($directive->values[0]))
37
+        {
37 38
             return \sprintf('<?php break %s; ?>', $directive->values[0]);
38 39
         }
39 40
 
@@ -42,7 +43,8 @@  discard block
 block discarded – undo
42 43
 
43 44
     public function renderContinue(Directive $directive): string
44 45
     {
45
-        if (isset($directive->values[0])) {
46
+        if (isset($directive->values[0]))
47
+        {
46 48
             return \sprintf('<?php continue %s; ?>', $directive->values[0]);
47 49
         }
48 50
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/Traits/TokenTrait.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
         $buffer = null;
21 21
         $bufferOffset = 0;
22 22
 
23
-        foreach ($inner as $n) {
23
+        foreach ($inner as $n){
24 24
             $token->offset ??= $n->offset;
25 25
 
26
-            if ($n instanceof Byte) {
27
-                if ($buffer === null) {
26
+            if ($n instanceof Byte){
27
+                if ($buffer === null){
28 28
                     $buffer = '';
29 29
                     $bufferOffset = $n->offset;
30 30
                 }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                 continue;
36 36
             }
37 37
 
38
-            if ($buffer !== null) {
38
+            if ($buffer !== null){
39 39
                 $token->tokens[] = new Token(
40 40
                     Token::TYPE_RAW,
41 41
                     $bufferOffset,
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $token->tokens[] = $n;
50 50
         }
51 51
 
52
-        if ($buffer !== null) {
52
+        if ($buffer !== null){
53 53
             $token->tokens[] = new Token(
54 54
                 Token::TYPE_RAW,
55 55
                 $bufferOffset,
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             );
59 59
         }
60 60
 
61
-        if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) {
61
+        if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW){
62 62
             $token->tokens = [];
63 63
         }
64 64
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,11 +20,14 @@  discard block
 block discarded – undo
20 20
         $buffer = null;
21 21
         $bufferOffset = 0;
22 22
 
23
-        foreach ($inner as $n) {
23
+        foreach ($inner as $n)
24
+        {
24 25
             $token->offset ??= $n->offset;
25 26
 
26
-            if ($n instanceof Byte) {
27
-                if ($buffer === null) {
27
+            if ($n instanceof Byte)
28
+            {
29
+                if ($buffer === null)
30
+                {
28 31
                     $buffer = '';
29 32
                     $bufferOffset = $n->offset;
30 33
                 }
@@ -35,7 +38,8 @@  discard block
 block discarded – undo
35 38
                 continue;
36 39
             }
37 40
 
38
-            if ($buffer !== null) {
41
+            if ($buffer !== null)
42
+            {
39 43
                 $token->tokens[] = new Token(
40 44
                     Token::TYPE_RAW,
41 45
                     $bufferOffset,
@@ -49,7 +53,8 @@  discard block
 block discarded – undo
49 53
             $token->tokens[] = $n;
50 54
         }
51 55
 
52
-        if ($buffer !== null) {
56
+        if ($buffer !== null)
57
+        {
53 58
             $token->tokens[] = new Token(
54 59
                 Token::TYPE_RAW,
55 60
                 $bufferOffset,
@@ -58,7 +63,8 @@  discard block
 block discarded – undo
58 63
             );
59 64
         }
60 65
 
61
-        if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) {
66
+        if (\count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW)
67
+        {
62 68
             $token->tokens = [];
63 69
         }
64 70
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/Dynamic/DeclareGrammar.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
     public function parse(Buffer $src): \Generator
36 36
     {
37 37
         $quoted = [];
38
-        while ($n = $src->next()) {
39
-            switch ($n->char) {
38
+        while ($n = $src->next()){
39
+            switch ($n->char){
40 40
                 case '"':
41 41
                 case "'":
42
-                    if ($this->keyword !== []) {
42
+                    if ($this->keyword !== []){
43 43
                         yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
44 44
                         $this->keyword = [];
45 45
                     }
46 46
 
47 47
                     $quoted[] = $n;
48
-                    while ($nn = $src->next()) {
48
+                    while ($nn = $src->next()){
49 49
                         $quoted[] = $nn;
50
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
50
+                        if ($nn instanceof Byte && $nn->char === $n->char){
51 51
                             break;
52 52
                         }
53 53
                     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
                     break;
59 59
                 case '=':
60
-                    if ($this->keyword !== []) {
60
+                    if ($this->keyword !== []){
61 61
                         yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
62 62
                         $this->keyword = [];
63 63
                     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                     yield new Token(self::TYPE_EQUAL, $n->offset, '=');
66 66
                     break;
67 67
                 case ',':
68
-                    if ($this->keyword !== []) {
68
+                    if ($this->keyword !== []){
69 69
                         yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
70 70
                         $this->keyword = [];
71 71
                     }
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
                     yield new Token(self::TYPE_COMMA, $n->offset, ',');
74 74
                     break;
75 75
                 default:
76
-                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) {
77
-                        if ($this->keyword !== []) {
76
+                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)){
77
+                        if ($this->keyword !== []){
78 78
                             yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
79 79
                             $this->keyword = [];
80 80
                         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             }
87 87
         }
88 88
 
89
-        if ($this->keyword !== []) {
89
+        if ($this->keyword !== []){
90 90
             yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
91 91
         }
92 92
     }
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,19 +35,24 @@  discard block
 block discarded – undo
35 35
     public function parse(Buffer $src): \Generator
36 36
     {
37 37
         $quoted = [];
38
-        while ($n = $src->next()) {
39
-            switch ($n->char) {
38
+        while ($n = $src->next())
39
+        {
40
+            switch ($n->char)
41
+            {
40 42
                 case '"':
41 43
                 case "'":
42
-                    if ($this->keyword !== []) {
44
+                    if ($this->keyword !== [])
45
+                    {
43 46
                         yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
44 47
                         $this->keyword = [];
45 48
                     }
46 49
 
47 50
                     $quoted[] = $n;
48
-                    while ($nn = $src->next()) {
51
+                    while ($nn = $src->next())
52
+                    {
49 53
                         $quoted[] = $nn;
50
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
54
+                        if ($nn instanceof Byte && $nn->char === $n->char)
55
+                        {
51 56
                             break;
52 57
                         }
53 58
                     }
@@ -57,7 +62,8 @@  discard block
 block discarded – undo
57 62
 
58 63
                     break;
59 64
                 case '=':
60
-                    if ($this->keyword !== []) {
65
+                    if ($this->keyword !== [])
66
+                    {
61 67
                         yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
62 68
                         $this->keyword = [];
63 69
                     }
@@ -65,7 +71,8 @@  discard block
 block discarded – undo
65 71
                     yield new Token(self::TYPE_EQUAL, $n->offset, '=');
66 72
                     break;
67 73
                 case ',':
68
-                    if ($this->keyword !== []) {
74
+                    if ($this->keyword !== [])
75
+                    {
69 76
                         yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
70 77
                         $this->keyword = [];
71 78
                     }
@@ -73,8 +80,10 @@  discard block
 block discarded – undo
73 80
                     yield new Token(self::TYPE_COMMA, $n->offset, ',');
74 81
                     break;
75 82
                 default:
76
-                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) {
77
-                        if ($this->keyword !== []) {
83
+                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char))
84
+                    {
85
+                        if ($this->keyword !== [])
86
+                        {
78 87
                             yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
79 88
                             $this->keyword = [];
80 89
                         }
@@ -86,7 +95,8 @@  discard block
 block discarded – undo
86 95
             }
87 96
         }
88 97
 
89
-        if ($this->keyword !== []) {
98
+        if ($this->keyword !== [])
99
+        {
90 100
             yield $this->packToken($this->keyword, self::TYPE_KEYWORD);
91 101
         }
92 102
     }
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/Dynamic/BracesGrammar.php 2 patches
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,7 +76,8 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function starts(Buffer $src, Byte $n): bool
78 78
     {
79
-        if (!$this->active) {
79
+        if (!$this->active)
80
+        {
80 81
             return false;
81 82
         }
82 83
 
@@ -96,26 +97,32 @@  discard block
 block discarded – undo
96 97
             ),
97 98
         ];
98 99
 
99
-        while ($n = $src->next()) {
100
-            if (!$n instanceof Byte) {
100
+        while ($n = $src->next())
101
+        {
102
+            if (!$n instanceof Byte)
103
+            {
101 104
                 // no other grammars are allowed
102 105
                 break;
103 106
             }
104 107
 
105
-            switch ($n->char) {
108
+            switch ($n->char)
109
+            {
106 110
                 case '"':
107 111
                 case "'":
108 112
                     $this->body[] = $n;
109
-                    while ($nn = $src->next()) {
113
+                    while ($nn = $src->next())
114
+                    {
110 115
                         $this->body[] = $nn;
111
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
116
+                        if ($nn instanceof Byte && $nn->char === $n->char)
117
+                        {
112 118
                             break;
113 119
                         }
114 120
                     }
115 121
                     break;
116 122
 
117 123
                 case $this->endSequence[0]:
118
-                    if (!$this->ends($src, $n)) {
124
+                    if (!$this->ends($src, $n))
125
+                    {
119 126
                         // still part of body
120 127
                         $this->body[] = $n;
121 128
                         break;
@@ -134,7 +141,8 @@  discard block
 block discarded – undo
134 141
             }
135 142
         }
136 143
 
137
-        if (\count($this->tokens) !== 3) {
144
+        if (\count($this->tokens) !== 3)
145
+        {
138 146
             return null;
139 147
         }
140 148
 
@@ -161,7 +169,8 @@  discard block
 block discarded – undo
161 169
     private function nextBytes(Buffer $src, int $size): string
162 170
     {
163 171
         $result = '';
164
-        for ($i = 0; $i < $size; $i++) {
172
+        for ($i = 0; $i < $size; $i++)
173
+        {
165 174
             $result .= $src->next()->char;
166 175
         }
167 176
 
@@ -173,7 +182,8 @@  discard block
 block discarded – undo
173 182
      */
174 183
     private function flushBody(): void
175 184
     {
176
-        if ($this->body === []) {
185
+        if ($this->body === [])
186
+        {
177 187
             return;
178 188
         }
179 189
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         string $endSequence,
28 28
         private readonly int $startToken,
29 29
         private readonly int $endToken,
30
-    ) {
30
+    ){
31 31
         $this->setStartSequence($startSequence);
32 32
         $this->setEndSequence($endSequence);
33 33
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     public function nextToken(Buffer $src): bool
70 70
     {
71
-        return $this->active && $src->lookaheadByte(\strlen((string) $this->startSequence)) === $this->startSequence;
71
+        return $this->active && $src->lookaheadByte(\strlen((string)$this->startSequence)) === $this->startSequence;
72 72
     }
73 73
 
74 74
     /**
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function starts(Buffer $src, Byte $n): bool
78 78
     {
79
-        if (!$this->active) {
79
+        if (!$this->active){
80 80
             return false;
81 81
         }
82 82
 
83
-        return $this->startSequence === ($n->char . $src->lookaheadByte(\strlen((string) $this->startSequence) - 1));
83
+        return $this->startSequence === ($n->char.$src->lookaheadByte(\strlen((string)$this->startSequence) - 1));
84 84
     }
85 85
 
86 86
     /**
@@ -92,30 +92,30 @@  discard block
 block discarded – undo
92 92
             new Token(
93 93
                 $this->startToken,
94 94
                 $n->offset,
95
-                $n->char . $this->nextBytes($src, \strlen((string) $this->startSequence) - 1),
95
+                $n->char.$this->nextBytes($src, \strlen((string)$this->startSequence) - 1),
96 96
             ),
97 97
         ];
98 98
 
99
-        while ($n = $src->next()) {
100
-            if (!$n instanceof Byte) {
99
+        while ($n = $src->next()){
100
+            if (!$n instanceof Byte){
101 101
                 // no other grammars are allowed
102 102
                 break;
103 103
             }
104 104
 
105
-            switch ($n->char) {
105
+            switch ($n->char){
106 106
                 case '"':
107 107
                 case "'":
108 108
                     $this->body[] = $n;
109
-                    while ($nn = $src->next()) {
109
+                    while ($nn = $src->next()){
110 110
                         $this->body[] = $nn;
111
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
111
+                        if ($nn instanceof Byte && $nn->char === $n->char){
112 112
                             break;
113 113
                         }
114 114
                     }
115 115
                     break;
116 116
 
117 117
                 case $this->endSequence[0]:
118
-                    if (!$this->ends($src, $n)) {
118
+                    if (!$this->ends($src, $n)){
119 119
                         // still part of body
120 120
                         $this->body[] = $n;
121 121
                         break;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                     $this->tokens[] = new Token(
126 126
                         $this->endToken,
127 127
                         $n->offset,
128
-                        $n->char . $this->nextBytes($src, \strlen((string) $this->endSequence) - 1),
128
+                        $n->char.$this->nextBytes($src, \strlen((string)$this->endSequence) - 1),
129 129
                     );
130 130
 
131 131
                     break 2;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             }
135 135
         }
136 136
 
137
-        if (\count($this->tokens) !== 3) {
137
+        if (\count($this->tokens) !== 3){
138 138
             return null;
139 139
         }
140 140
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function ends(Buffer $src, Byte $n): bool
148 148
     {
149
-        return $this->endSequence === ($n->char . $src->lookaheadByte(\strlen((string) $this->endSequence) - 1));
149
+        return $this->endSequence === ($n->char.$src->lookaheadByte(\strlen((string)$this->endSequence) - 1));
150 150
     }
151 151
 
152 152
     /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     private function nextBytes(Buffer $src, int $size): string
160 160
     {
161 161
         $result = '';
162
-        for ($i = 0; $i < $size; $i++) {
162
+        for ($i = 0; $i < $size; $i++){
163 163
             $result .= $src->next()->char;
164 164
         }
165 165
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     private function flushBody(): void
173 173
     {
174
-        if ($this->body === []) {
174
+        if ($this->body === []){
175 175
             return;
176 176
         }
177 177
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/InlineGrammar.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function parse(Buffer $src): \Generator
40 40
     {
41
-        while ($n = $src->next()) {
42
-            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') {
41
+        while ($n = $src->next()){
42
+            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{'){
43 43
                 yield $n;
44 44
                 continue;
45 45
             }
46 46
 
47 47
             $binding = (clone $this)->parseGrammar($src, $n->offset);
48
-            if ($binding === null) {
48
+            if ($binding === null){
49 49
                 yield $n;
50 50
                 $src->replay($n->offset);
51 51
                 continue;
@@ -80,27 +80,27 @@  discard block
 block discarded – undo
80 80
     private function parseGrammar(Buffer $src, int $offset): ?array
81 81
     {
82 82
         $this->tokens = [
83
-            new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char),
83
+            new Token(self::TYPE_OPEN_TAG, $offset, '$'.$src->next()->char),
84 84
         ];
85 85
 
86
-        while ($n = $src->next()) {
87
-            if (!$n instanceof Byte) {
86
+        while ($n = $src->next()){
87
+            if (!$n instanceof Byte){
88 88
                 // no other grammars are allowed
89 89
                 return null;
90 90
             }
91 91
 
92
-            switch ($n->char) {
92
+            switch ($n->char){
93 93
                 case '"':
94 94
                 case "'":
95
-                    if ($this->default === null) {
95
+                    if ($this->default === null){
96 96
                         // " and ' not allowed in names
97 97
                         return null;
98 98
                     }
99 99
 
100 100
                     $this->default[] = $n;
101
-                    while ($nn = $src->next()) {
101
+                    while ($nn = $src->next()){
102 102
                         $this->default[] = $nn;
103
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
103
+                        if ($nn instanceof Byte && $nn->char === $n->char){
104 104
                             break;
105 105
                         }
106 106
                     }
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
                     break;
134 134
 
135 135
                 default:
136
-                    if ($this->default !== null) {
136
+                    if ($this->default !== null){
137 137
                         // default allows spaces
138 138
                         $this->default[] = $n;
139 139
                         break;
140 140
                     }
141 141
 
142
-                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) {
142
+                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)){
143 143
                         break;
144 144
                     }
145 145
 
146
-                    if (\preg_match(self::REGEXP_KEYWORD, $n->char)) {
146
+                    if (\preg_match(self::REGEXP_KEYWORD, $n->char)){
147 147
                         $this->name[] = $n;
148 148
                         break;
149 149
                     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             }
153 153
         }
154 154
 
155
-        if (!$this->isValid()) {
155
+        if (!$this->isValid()){
156 156
             return null;
157 157
         }
158 158
 
@@ -161,25 +161,25 @@  discard block
 block discarded – undo
161 161
 
162 162
     private function isValid(): bool
163 163
     {
164
-        if (\count($this->tokens) < 3) {
164
+        if (\count($this->tokens) < 3){
165 165
             return false;
166 166
         }
167 167
 
168 168
         $hasName = false;
169 169
         $hasDefault = null;
170
-        foreach ($this->tokens as $token) {
171
-            if ($token->type === self::TYPE_NAME) {
170
+        foreach ($this->tokens as $token){
171
+            if ($token->type === self::TYPE_NAME){
172 172
                 $hasName = true;
173 173
                 continue;
174 174
             }
175 175
 
176
-            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) {
176
+            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null){
177 177
                 $hasDefault = false;
178 178
                 continue;
179 179
             }
180 180
 
181
-            if ($token->type === self::TYPE_DEFAULT) {
182
-                if ($hasDefault === true) {
181
+            if ($token->type === self::TYPE_DEFAULT){
182
+                if ($hasDefault === true){
183 183
                     // multiple default value
184 184
                     return false;
185 185
                 }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     private function flushName(): void
198 198
     {
199
-        if ($this->name === []) {
199
+        if ($this->name === []){
200 200
             return;
201 201
         }
202 202
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     private function flushDefault(): void
211 211
     {
212
-        if ($this->default === [] || $this->default === null) {
212
+        if ($this->default === [] || $this->default === null){
213 213
             return;
214 214
         }
215 215
 
Please login to merge, or discard this patch.
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -38,14 +38,17 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function parse(Buffer $src): \Generator
40 40
     {
41
-        while ($n = $src->next()) {
42
-            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') {
41
+        while ($n = $src->next())
42
+        {
43
+            if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{')
44
+            {
43 45
                 yield $n;
44 46
                 continue;
45 47
             }
46 48
 
47 49
             $binding = (clone $this)->parseGrammar($src, $n->offset);
48
-            if ($binding === null) {
50
+            if ($binding === null)
51
+            {
49 52
                 yield $n;
50 53
                 $src->replay($n->offset);
51 54
                 continue;
@@ -83,24 +86,30 @@  discard block
 block discarded – undo
83 86
             new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char),
84 87
         ];
85 88
 
86
-        while ($n = $src->next()) {
87
-            if (!$n instanceof Byte) {
89
+        while ($n = $src->next())
90
+        {
91
+            if (!$n instanceof Byte)
92
+            {
88 93
                 // no other grammars are allowed
89 94
                 return null;
90 95
             }
91 96
 
92
-            switch ($n->char) {
97
+            switch ($n->char)
98
+            {
93 99
                 case '"':
94 100
                 case "'":
95
-                    if ($this->default === null) {
101
+                    if ($this->default === null)
102
+                    {
96 103
                         // " and ' not allowed in names
97 104
                         return null;
98 105
                     }
99 106
 
100 107
                     $this->default[] = $n;
101
-                    while ($nn = $src->next()) {
108
+                    while ($nn = $src->next())
109
+                    {
102 110
                         $this->default[] = $nn;
103
-                        if ($nn instanceof Byte && $nn->char === $n->char) {
111
+                        if ($nn instanceof Byte && $nn->char === $n->char)
112
+                        {
104 113
                             break;
105 114
                         }
106 115
                     }
@@ -133,17 +142,20 @@  discard block
 block discarded – undo
133 142
                     break;
134 143
 
135 144
                 default:
136
-                    if ($this->default !== null) {
145
+                    if ($this->default !== null)
146
+                    {
137 147
                         // default allows spaces
138 148
                         $this->default[] = $n;
139 149
                         break;
140 150
                     }
141 151
 
142
-                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char)) {
152
+                    if (\preg_match(self::REGEXP_WHITESPACE, $n->char))
153
+                    {
143 154
                         break;
144 155
                     }
145 156
 
146
-                    if (\preg_match(self::REGEXP_KEYWORD, $n->char)) {
157
+                    if (\preg_match(self::REGEXP_KEYWORD, $n->char))
158
+                    {
147 159
                         $this->name[] = $n;
148 160
                         break;
149 161
                     }
@@ -152,7 +164,8 @@  discard block
 block discarded – undo
152 164
             }
153 165
         }
154 166
 
155
-        if (!$this->isValid()) {
167
+        if (!$this->isValid())
168
+        {
156 169
             return null;
157 170
         }
158 171
 
@@ -161,25 +174,31 @@  discard block
 block discarded – undo
161 174
 
162 175
     private function isValid(): bool
163 176
     {
164
-        if (\count($this->tokens) < 3) {
177
+        if (\count($this->tokens) < 3)
178
+        {
165 179
             return false;
166 180
         }
167 181
 
168 182
         $hasName = false;
169 183
         $hasDefault = null;
170
-        foreach ($this->tokens as $token) {
171
-            if ($token->type === self::TYPE_NAME) {
184
+        foreach ($this->tokens as $token)
185
+        {
186
+            if ($token->type === self::TYPE_NAME)
187
+            {
172 188
                 $hasName = true;
173 189
                 continue;
174 190
             }
175 191
 
176
-            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) {
192
+            if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null)
193
+            {
177 194
                 $hasDefault = false;
178 195
                 continue;
179 196
             }
180 197
 
181
-            if ($token->type === self::TYPE_DEFAULT) {
182
-                if ($hasDefault === true) {
198
+            if ($token->type === self::TYPE_DEFAULT)
199
+            {
200
+                if ($hasDefault === true)
201
+                {
183 202
                     // multiple default value
184 203
                     return false;
185 204
                 }
@@ -196,7 +215,8 @@  discard block
 block discarded – undo
196 215
      */
197 216
     private function flushName(): void
198 217
     {
199
-        if ($this->name === []) {
218
+        if ($this->name === [])
219
+        {
200 220
             return;
201 221
         }
202 222
 
@@ -209,7 +229,8 @@  discard block
 block discarded – undo
209 229
      */
210 230
     private function flushDefault(): void
211 231
     {
212
-        if ($this->default === [] || $this->default === null) {
232
+        if ($this->default === [] || $this->default === null)
233
+        {
213 234
             return;
214 235
         }
215 236
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Grammar/PHPGrammar.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function parse(Buffer $src): \Generator
18 18
     {
19
-        while ($n = $src->next()) {
20
-            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?') {
19
+        while ($n = $src->next()){
20
+            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?'){
21 21
                 yield $n;
22 22
                 continue;
23 23
             }
24 24
 
25
-            $php = $this->parseGrammar($n->char . $src->nextBytes(), $n->offset);
26
-            if ($php === null) {
25
+            $php = $this->parseGrammar($n->char.$src->nextBytes(), $n->offset);
26
+            if ($php === null){
27 27
                 yield $n;
28 28
                 $src->replay($n->offset);
29 29
                 continue;
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
     private function parseGrammar(string $content, int $offset): ?Token
46 46
     {
47 47
         $tokens = null;
48
-        foreach (\token_get_all($content) as $token) {
49
-            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])) {
48
+        foreach (\token_get_all($content) as $token){
49
+            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])){
50 50
                 // not php
51 51
                 return null;
52 52
             }
53 53
 
54 54
             $tokens[] = $token;
55
-            if ($this->is($token, [T_CLOSE_TAG])) {
55
+            if ($this->is($token, [T_CLOSE_TAG])){
56 56
                 break;
57 57
             }
58 58
         }
59 59
 
60
-        if ($tokens === null) {
60
+        if ($tokens === null){
61 61
             return null;
62 62
         }
63 63
 
64 64
         $buffer = '';
65
-        foreach ($tokens as $token) {
66
-            if (!\is_array($token)) {
65
+        foreach ($tokens as $token){
66
+            if (!\is_array($token)){
67 67
                 $buffer .= $token;
68 68
                 continue;
69 69
             }
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         return $token;
77 77
     }
78 78
 
79
-    private function is(array|string $token, array $type): bool
79
+    private function is(array | string $token, array $type): bool
80 80
     {
81
-        if (!\is_array($token)) {
81
+        if (!\is_array($token)){
82 82
             return false;
83 83
         }
84 84
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,14 +16,17 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function parse(Buffer $src): \Generator
18 18
     {
19
-        while ($n = $src->next()) {
20
-            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?') {
19
+        while ($n = $src->next())
20
+        {
21
+            if (!$n instanceof Byte || $n->char !== '<' || $src->lookaheadByte() !== '?')
22
+            {
21 23
                 yield $n;
22 24
                 continue;
23 25
             }
24 26
 
25 27
             $php = $this->parseGrammar($n->char . $src->nextBytes(), $n->offset);
26
-            if ($php === null) {
28
+            if ($php === null)
29
+            {
27 30
                 yield $n;
28 31
                 $src->replay($n->offset);
29 32
                 continue;
@@ -45,25 +48,31 @@  discard block
 block discarded – undo
45 48
     private function parseGrammar(string $content, int $offset): ?Token
46 49
     {
47 50
         $tokens = null;
48
-        foreach (\token_get_all($content) as $token) {
49
-            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO])) {
51
+        foreach (\token_get_all($content) as $token)
52
+        {
53
+            if ($tokens === null && !$this->is($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO]))
54
+            {
50 55
                 // not php
51 56
                 return null;
52 57
             }
53 58
 
54 59
             $tokens[] = $token;
55
-            if ($this->is($token, [T_CLOSE_TAG])) {
60
+            if ($this->is($token, [T_CLOSE_TAG]))
61
+            {
56 62
                 break;
57 63
             }
58 64
         }
59 65
 
60
-        if ($tokens === null) {
66
+        if ($tokens === null)
67
+        {
61 68
             return null;
62 69
         }
63 70
 
64 71
         $buffer = '';
65
-        foreach ($tokens as $token) {
66
-            if (!\is_array($token)) {
72
+        foreach ($tokens as $token)
73
+        {
74
+            if (!\is_array($token))
75
+            {
67 76
                 $buffer .= $token;
68 77
                 continue;
69 78
             }
@@ -78,7 +87,8 @@  discard block
 block discarded – undo
78 87
 
79 88
     private function is(array|string $token, array $type): bool
80 89
     {
81
-        if (!\is_array($token)) {
90
+        if (!\is_array($token))
91
+        {
82 92
             return false;
83 93
         }
84 94
 
Please login to merge, or discard this patch.
src/Stempler/src/Lexer/Lexer.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
     public function parse(StreamInterface $src): \Generator
32 32
     {
33 33
         $stream = new Buffer($this->generate($src));
34
-        foreach ($this->grammars as $grammar) {
34
+        foreach ($this->grammars as $grammar){
35 35
             $stream = new Buffer($this->wrap(clone $grammar, $stream));
36 36
         }
37 37
 
38 38
         // always group raw bytes into raw tokens
39
-        foreach ($this->wrap(new RawGrammar(), $stream) as $n) {
39
+        foreach ($this->wrap(new RawGrammar(), $stream) as $n){
40 40
             yield $n;
41 41
         }
42 42
     }
43 43
 
44 44
     private function wrap(GrammarInterface $grammar, Buffer $stream): \Generator
45 45
     {
46
-        foreach ($grammar->parse($stream) as $n) {
47
-            if ($n instanceof Token && $n->grammar === null) {
46
+        foreach ($grammar->parse($stream) as $n){
47
+            if ($n instanceof Token && $n->grammar === null){
48 48
                 $n->grammar = $grammar::class;
49 49
             }
50 50
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     private function generate(StreamInterface $src): \Generator
61 61
     {
62
-        while (!$src->isEOI()) {
62
+        while (!$src->isEOI()){
63 63
             yield new Byte($src->getOffset(), $src->peak());
64 64
         }
65 65
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,20 +31,24 @@  discard block
 block discarded – undo
31 31
     public function parse(StreamInterface $src): \Generator
32 32
     {
33 33
         $stream = new Buffer($this->generate($src));
34
-        foreach ($this->grammars as $grammar) {
34
+        foreach ($this->grammars as $grammar)
35
+        {
35 36
             $stream = new Buffer($this->wrap(clone $grammar, $stream));
36 37
         }
37 38
 
38 39
         // always group raw bytes into raw tokens
39
-        foreach ($this->wrap(new RawGrammar(), $stream) as $n) {
40
+        foreach ($this->wrap(new RawGrammar(), $stream) as $n)
41
+        {
40 42
             yield $n;
41 43
         }
42 44
     }
43 45
 
44 46
     private function wrap(GrammarInterface $grammar, Buffer $stream): \Generator
45 47
     {
46
-        foreach ($grammar->parse($stream) as $n) {
47
-            if ($n instanceof Token && $n->grammar === null) {
48
+        foreach ($grammar->parse($stream) as $n)
49
+        {
50
+            if ($n instanceof Token && $n->grammar === null)
51
+            {
48 52
                 $n->grammar = $grammar::class;
49 53
             }
50 54
 
@@ -59,7 +63,8 @@  discard block
 block discarded – undo
59 63
      */
60 64
     private function generate(StreamInterface $src): \Generator
61 65
     {
62
-        while (!$src->isEOI()) {
66
+        while (!$src->isEOI())
67
+        {
63 68
             yield new Byte($src->getOffset(), $src->peak());
64 69
         }
65 70
     }
Please login to merge, or discard this patch.
src/Stempler/src/Compiler/Renderer/PHPRenderer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 {
14 14
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
15 15
     {
16
-        if ($node instanceof PHP) {
16
+        if ($node instanceof PHP){
17 17
             $result->push($node->content, $node->getContext());
18 18
             return true;
19 19
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@
 block discarded – undo
13 13
 {
14 14
     public function render(Compiler $compiler, Compiler\Result $result, NodeInterface $node): bool
15 15
     {
16
-        if ($node instanceof PHP) {
16
+        if ($node instanceof PHP)
17
+        {
17 18
             $result->push($node->content, $node->getContext());
18 19
             return true;
19 20
         }
Please login to merge, or discard this patch.