Passed
Pull Request — master (#656)
by Abdul Malik
11:30 queued 05:15
created
src/Stempler/src/Parser/Syntax/HTMLSyntax.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function handle(Parser $parser, Assembler $asm, Token $token): void
70 70
     {
71
-        switch ($token->type) {
71
+        switch ($token->type){
72 72
             case HTMLGrammar::TYPE_OPEN:
73 73
             case HTMLGrammar::TYPE_OPEN_SHORT:
74 74
                 $this->node = new Tag(new Context($token, $parser->getPath()));
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
                 break;
78 78
 
79 79
             case HTMLGrammar::TYPE_KEYWORD:
80
-                if ($this->node->name === null) {
80
+                if ($this->node->name === null){
81 81
                     $this->node->name = $this->parseToken($parser, $token);
82 82
                     return;
83 83
                 }
84 84
 
85
-                if ($this->attr !== null && !$this->attr->value instanceof Nil) {
85
+                if ($this->attr !== null && !$this->attr->value instanceof Nil){
86 86
                     $this->attr->value = $this->parseToken($parser, $token);
87 87
                     $this->attr = null;
88 88
                     break;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 break;
99 99
 
100 100
             case HTMLGrammar::TYPE_EQUAL:
101
-                if ($this->attr === null) {
101
+                if ($this->attr === null){
102 102
                     throw new SyntaxException('unexpected attribute token', $token);
103 103
                 }
104 104
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 break;
108 108
 
109 109
             case HTMLGrammar::TYPE_ATTRIBUTE:
110
-                if ($this->attr === null) {
110
+                if ($this->attr === null){
111 111
                     throw new SyntaxException('unexpected attribute token', $token);
112 112
                 }
113 113
 
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                         strpos($this->attr->name, 'on') === 0
118 118
                         || in_array($this->attr->name, self::VERBATIM_ATTRIBUTES, true)
119 119
                     )
120
-                ) {
120
+                ){
121 121
                     $this->attr->value = $this->parseVerbatim($parser, $token);
122
-                } else {
122
+                }else{
123 123
                     $this->attr->value = $this->parseToken($parser, $token);
124 124
                 }
125 125
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
                 break;
134 134
 
135 135
             case HTMLGrammar::TYPE_CLOSE:
136
-                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) {
137
-                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) {
136
+                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT){
137
+                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name){
138 138
                         throw new SyntaxException(
139 139
                             "Invalid closing tag `{$this->node->name}`, expected `{$asm->getNode()->name}`",
140 140
                             $this->token
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
                     }
143 143
 
144 144
                     $asm->close();
145
-                } else {
146
-                    if (in_array($this->node->name, self::VOID_TAGS)) {
145
+                }else{
146
+                    if (in_array($this->node->name, self::VOID_TAGS)){
147 147
                         $this->node->void = true;
148 148
                         $asm->push($this->node);
149
-                    } else {
149
+                    }else{
150 150
                         $asm->open($this->node, 'nodes');
151 151
                     }
152 152
                 }
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
                 break;
160 160
 
161 161
             default:
162
-                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) {
162
+                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim){
163 163
                     $node = $this->parseToken($parser, $token);
164
-                    if (is_string($node)) {
164
+                    if (is_string($node)){
165 165
                         $node = new Raw($node, new Context($token, $parser->getPath()));
166 166
                     }
167 167
 
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
     {
185 185
         $verbatim = new Verbatim(new Context($token, $parser->getPath()));
186 186
 
187
-        if ($token->tokens === []) {
188
-            if ($token->content) {
187
+        if ($token->tokens === []){
188
+            if ($token->content){
189 189
                 $verbatim->nodes[] = $token->content;
190 190
             }
191
-        } else {
191
+        }else{
192 192
             $parser->parseTokens(
193 193
                 new Assembler($verbatim, 'nodes'),
194 194
                 $token->tokens
Please login to merge, or discard this patch.
Braces   +36 added lines, -16 removed lines patch added patch discarded remove patch
@@ -68,7 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function handle(Parser $parser, Assembler $asm, Token $token): void
70 70
     {
71
-        switch ($token->type) {
71
+        switch ($token->type)
72
+        {
72 73
             case HTMLGrammar::TYPE_OPEN:
73 74
             case HTMLGrammar::TYPE_OPEN_SHORT:
74 75
                 $this->node = new Tag(new Context($token, $parser->getPath()));
@@ -77,12 +78,14 @@  discard block
 block discarded – undo
77 78
                 break;
78 79
 
79 80
             case HTMLGrammar::TYPE_KEYWORD:
80
-                if ($this->node->name === null) {
81
+                if ($this->node->name === null)
82
+                {
81 83
                     $this->node->name = $this->parseToken($parser, $token);
82 84
                     return;
83 85
                 }
84 86
 
85
-                if ($this->attr !== null && !$this->attr->value instanceof Nil) {
87
+                if ($this->attr !== null && !$this->attr->value instanceof Nil)
88
+                {
86 89
                     $this->attr->value = $this->parseToken($parser, $token);
87 90
                     $this->attr = null;
88 91
                     break;
@@ -98,7 +101,8 @@  discard block
 block discarded – undo
98 101
                 break;
99 102
 
100 103
             case HTMLGrammar::TYPE_EQUAL:
101
-                if ($this->attr === null) {
104
+                if ($this->attr === null)
105
+                {
102 106
                     throw new SyntaxException('unexpected attribute token', $token);
103 107
                 }
104 108
 
@@ -107,7 +111,8 @@  discard block
 block discarded – undo
107 111
                 break;
108 112
 
109 113
             case HTMLGrammar::TYPE_ATTRIBUTE:
110
-                if ($this->attr === null) {
114
+                if ($this->attr === null)
115
+                {
111 116
                     throw new SyntaxException('unexpected attribute token', $token);
112 117
                 }
113 118
 
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
                     )
120 125
                 ) {
121 126
                     $this->attr->value = $this->parseVerbatim($parser, $token);
122
-                } else {
127
+                }
128
+                else
129
+                {
123 130
                     $this->attr->value = $this->parseToken($parser, $token);
124 131
                 }
125 132
 
@@ -133,8 +140,10 @@  discard block
 block discarded – undo
133 140
                 break;
134 141
 
135 142
             case HTMLGrammar::TYPE_CLOSE:
136
-                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) {
137
-                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) {
143
+                if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT)
144
+                {
145
+                    if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name)
146
+                    {
138 147
                         throw new SyntaxException(
139 148
                             "Invalid closing tag `{$this->node->name}`, expected `{$asm->getNode()->name}`",
140 149
                             $this->token
@@ -142,11 +151,16 @@  discard block
 block discarded – undo
142 151
                     }
143 152
 
144 153
                     $asm->close();
145
-                } else {
146
-                    if (in_array($this->node->name, self::VOID_TAGS)) {
154
+                }
155
+                else
156
+                {
157
+                    if (in_array($this->node->name, self::VOID_TAGS))
158
+                    {
147 159
                         $this->node->void = true;
148 160
                         $asm->push($this->node);
149
-                    } else {
161
+                    }
162
+                    else
163
+                    {
150 164
                         $asm->open($this->node, 'nodes');
151 165
                     }
152 166
                 }
@@ -159,9 +173,11 @@  discard block
 block discarded – undo
159 173
                 break;
160 174
 
161 175
             default:
162
-                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) {
176
+                if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim)
177
+                {
163 178
                     $node = $this->parseToken($parser, $token);
164
-                    if (is_string($node)) {
179
+                    if (is_string($node))
180
+                    {
165 181
                         $node = new Raw($node, new Context($token, $parser->getPath()));
166 182
                     }
167 183
 
@@ -184,11 +200,15 @@  discard block
 block discarded – undo
184 200
     {
185 201
         $verbatim = new Verbatim(new Context($token, $parser->getPath()));
186 202
 
187
-        if ($token->tokens === []) {
188
-            if ($token->content) {
203
+        if ($token->tokens === [])
204
+        {
205
+            if ($token->content)
206
+            {
189 207
                 $verbatim->nodes[] = $token->content;
190 208
             }
191
-        } else {
209
+        }
210
+        else
211
+        {
192 212
             $parser->parseTokens(
193 213
                 new Assembler($verbatim, 'nodes'),
194 214
                 $token->tokens
Please login to merge, or discard this patch.
src/Stempler/src/Parser/Syntax/DynamicSyntax.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function handle(Parser $parser, Assembler $asm, Token $token): void
37 37
     {
38
-        switch ($token->type) {
38
+        switch ($token->type){
39 39
             case DynamicGrammar::TYPE_DIRECTIVE:
40 40
                 $this->directive = new Directive(new Context($token, $parser->getPath()));
41 41
                 $asm->push($this->directive);
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
                 break;
61 61
 
62 62
             case DynamicGrammar::TYPE_KEYWORD:
63
-                if ($this->directive !== null) {
63
+                if ($this->directive !== null){
64 64
                     $this->directive->name = $token->content;
65 65
                 }
66 66
                 break;
67 67
 
68 68
             case DynamicGrammar::TYPE_BODY:
69
-                if ($this->directive !== null) {
69
+                if ($this->directive !== null){
70 70
                     $this->directive->body = $token->content;
71 71
                     $this->directive->values = $this->fetchValues($this->directive->body);
72 72
 
73 73
                     $this->directive = null;
74 74
                 }
75 75
 
76
-                if ($this->output !== null) {
76
+                if ($this->output !== null){
77 77
                     $this->output->body = $token->content;
78 78
                 }
79 79
 
@@ -91,31 +91,31 @@  discard block
 block discarded – undo
91 91
 
92 92
         $src = new StringStream($body);
93 93
 
94
-        while ($n = $src->peak()) {
95
-            if (in_array($n, ['"', '"'])) {
94
+        while ($n = $src->peak()){
95
+            if (in_array($n, ['"', '"'])){
96 96
                 $values[count($values) - 1] .= $n;
97
-                while ($nn = $src->peak()) {
97
+                while ($nn = $src->peak()){
98 98
                     $values[count($values) - 1] .= $nn;
99
-                    if ($nn === $n) {
99
+                    if ($nn === $n){
100 100
                         break;
101 101
                     }
102 102
                 }
103 103
                 continue;
104 104
             }
105 105
 
106
-            if ($n === ',' && $level === 0) {
106
+            if ($n === ',' && $level === 0){
107 107
                 $values[] = '';
108 108
                 continue;
109 109
             }
110 110
 
111 111
             $values[count($values) - 1] .= $n;
112 112
 
113
-            if ($n === '(' || $n === '[' || $n === '{') {
113
+            if ($n === '(' || $n === '[' || $n === '{'){
114 114
                 $level++;
115 115
                 continue;
116 116
             }
117 117
 
118
-            if ($n === ')' || $n === ']' || $n === '}') {
118
+            if ($n === ')' || $n === ']' || $n === '}'){
119 119
                 $level--;
120 120
             }
121 121
         }
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function handle(Parser $parser, Assembler $asm, Token $token): void
37 37
     {
38
-        switch ($token->type) {
38
+        switch ($token->type)
39
+        {
39 40
             case DynamicGrammar::TYPE_DIRECTIVE:
40 41
                 $this->directive = new Directive(new Context($token, $parser->getPath()));
41 42
                 $asm->push($this->directive);
@@ -60,20 +61,23 @@  discard block
 block discarded – undo
60 61
                 break;
61 62
 
62 63
             case DynamicGrammar::TYPE_KEYWORD:
63
-                if ($this->directive !== null) {
64
+                if ($this->directive !== null)
65
+                {
64 66
                     $this->directive->name = $token->content;
65 67
                 }
66 68
                 break;
67 69
 
68 70
             case DynamicGrammar::TYPE_BODY:
69
-                if ($this->directive !== null) {
71
+                if ($this->directive !== null)
72
+                {
70 73
                     $this->directive->body = $token->content;
71 74
                     $this->directive->values = $this->fetchValues($this->directive->body);
72 75
 
73 76
                     $this->directive = null;
74 77
                 }
75 78
 
76
-                if ($this->output !== null) {
79
+                if ($this->output !== null)
80
+                {
77 81
                     $this->output->body = $token->content;
78 82
                 }
79 83
 
@@ -91,31 +95,38 @@  discard block
 block discarded – undo
91 95
 
92 96
         $src = new StringStream($body);
93 97
 
94
-        while ($n = $src->peak()) {
95
-            if (in_array($n, ['"', '"'])) {
98
+        while ($n = $src->peak())
99
+        {
100
+            if (in_array($n, ['"', '"']))
101
+            {
96 102
                 $values[count($values) - 1] .= $n;
97
-                while ($nn = $src->peak()) {
103
+                while ($nn = $src->peak())
104
+                {
98 105
                     $values[count($values) - 1] .= $nn;
99
-                    if ($nn === $n) {
106
+                    if ($nn === $n)
107
+                    {
100 108
                         break;
101 109
                     }
102 110
                 }
103 111
                 continue;
104 112
             }
105 113
 
106
-            if ($n === ',' && $level === 0) {
114
+            if ($n === ',' && $level === 0)
115
+            {
107 116
                 $values[] = '';
108 117
                 continue;
109 118
             }
110 119
 
111 120
             $values[count($values) - 1] .= $n;
112 121
 
113
-            if ($n === '(' || $n === '[' || $n === '{') {
122
+            if ($n === '(' || $n === '[' || $n === '{')
123
+            {
114 124
                 $level++;
115 125
                 continue;
116 126
             }
117 127
 
118
-            if ($n === ')' || $n === ']' || $n === '}') {
128
+            if ($n === ')' || $n === ']' || $n === '}')
129
+            {
119 130
                 $level--;
120 131
             }
121 132
         }
Please login to merge, or discard this patch.
src/Stempler/src/Parser/Syntax/InlineSyntax.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
      */
32 32
     public function handle(Parser $parser, Assembler $asm, Token $token): void
33 33
     {
34
-        switch ($token->type) {
34
+        switch ($token->type){
35 35
             case InlineGrammar::TYPE_OPEN_TAG:
36 36
                 $this->inline = new Inline(new Context($token, $parser->getPath()));
37 37
                 $asm->push($this->inline);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
      */
32 32
     public function handle(Parser $parser, Assembler $asm, Token $token): void
33 33
     {
34
-        switch ($token->type) {
34
+        switch ($token->type)
35
+        {
35 36
             case InlineGrammar::TYPE_OPEN_TAG:
36 37
                 $this->inline = new Inline(new Context($token, $parser->getPath()));
37 38
                 $asm->push($this->inline);
Please login to merge, or discard this patch.
src/Stempler/src/Parser/Assembler.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function getStackPath(): string
41 41
     {
42 42
         $path = [$this->nodeName($this->node)];
43
-        foreach ($this->stack as $tuple) {
43
+        foreach ($this->stack as $tuple){
44 44
             $path[] = $this->nodeName($tuple[0]);
45 45
         }
46 46
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     private function nodeName(NodeInterface $node): string
73 73
     {
74 74
         $r = new ReflectionClass($node);
75
-        if (property_exists($node, 'name')) {
76
-            return lcfirst($r->getShortName()) . "[{$node->name}]";
75
+        if (property_exists($node, 'name')){
76
+            return lcfirst($r->getShortName())."[{$node->name}]";
77 77
         }
78 78
 
79 79
         return lcfirst($r->getShortName());
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,8 @@  discard block
 block discarded – undo
40 40
     public function getStackPath(): string
41 41
     {
42 42
         $path = [$this->nodeName($this->node)];
43
-        foreach ($this->stack as $tuple) {
43
+        foreach ($this->stack as $tuple)
44
+        {
44 45
             $path[] = $this->nodeName($tuple[0]);
45 46
         }
46 47
 
@@ -72,7 +73,8 @@  discard block
 block discarded – undo
72 73
     private function nodeName(NodeInterface $node): string
73 74
     {
74 75
         $r = new ReflectionClass($node);
75
-        if (property_exists($node, 'name')) {
76
+        if (property_exists($node, 'name'))
77
+        {
76 78
             return lcfirst($r->getShortName()) . "[{$node->name}]";
77 79
         }
78 80
 
Please login to merge, or discard this patch.
src/Stempler/src/Traverser.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function __construct(array $visitors = [])
31 31
     {
32
-        foreach ($visitors as $visitor) {
32
+        foreach ($visitors as $visitor){
33 33
             $this->addVisitor($visitor);
34 34
         }
35 35
     }
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function removeVisitor(VisitorInterface $visitor): void
46 46
     {
47
-        foreach ($this->visitors as $index => $added) {
48
-            if ($added === $visitor) {
47
+        foreach ($this->visitors as $index => $added){
48
+            if ($added === $visitor){
49 49
                 unset($this->visitors[$index]);
50 50
                 break;
51 51
             }
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
         $context ??= new VisitorContext();
65 65
 
66 66
         $ctx = clone $context;
67
-        foreach ($nodes as $index => $node) {
68
-            if ($this->stopTraversal) {
67
+        foreach ($nodes as $index => $node){
68
+            if ($this->stopTraversal){
69 69
                 break;
70 70
             }
71 71
 
72 72
             $traverseChildren = true;
73 73
             $breakVisitorID = null;
74 74
 
75
-            if ($node instanceof NodeInterface) {
75
+            if ($node instanceof NodeInterface){
76 76
                 $ctx = $context->withNode($node);
77 77
             }
78 78
 
79
-            foreach ($this->visitors as $visitorID => $visitor) {
79
+            foreach ($this->visitors as $visitorID => $visitor){
80 80
                 $result = $visitor->enterNode($node, $ctx);
81 81
 
82
-                switch (true) {
82
+                switch (true){
83 83
                     case $result === null:
84 84
                         break;
85 85
 
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
 
104 104
                     default:
105 105
                         throw new LogicException(
106
-                            'enterNode() returned invalid value of type ' . gettype($result)
106
+                            'enterNode() returned invalid value of type '.gettype($result)
107 107
                         );
108 108
                 }
109 109
             }
110 110
 
111 111
             // sub nodes
112
-            if ($traverseChildren && $node instanceof NodeInterface) {
112
+            if ($traverseChildren && $node instanceof NodeInterface){
113 113
                 $nodes[$index] = $this->traverseNode($node, $ctx);
114
-                if ($this->stopTraversal) {
114
+                if ($this->stopTraversal){
115 115
                     break;
116 116
                 }
117 117
             }
118 118
 
119
-            foreach ($this->visitors as $visitorID => $visitor) {
119
+            foreach ($this->visitors as $visitorID => $visitor){
120 120
                 $result = $visitor->leaveNode($node, $ctx);
121 121
 
122
-                switch (true) {
122
+                switch (true){
123 123
                     case $result === null:
124 124
                         break;
125 125
 
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 
138 138
                     default:
139 139
                         throw new LogicException(
140
-                            'leaveNode() returned invalid value of type ' . gettype($result)
140
+                            'leaveNode() returned invalid value of type '.gettype($result)
141 141
                         );
142 142
                 }
143 143
 
144
-                if ($breakVisitorID === $visitorID) {
144
+                if ($breakVisitorID === $visitorID){
145 145
                     break;
146 146
                 }
147 147
             }
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
     private function traverseNode(NodeInterface $node, VisitorContext $context): NodeInterface
157 157
     {
158 158
         $ctx = clone $context;
159
-        foreach ($node as $name => $_) {
159
+        foreach ($node as $name => $_){
160 160
             $child = &$node->$name;
161
-            if (is_array($child)) {
161
+            if (is_array($child)){
162 162
                 $child = $this->traverse($child, $ctx);
163
-                if ($this->stopTraversal) {
163
+                if ($this->stopTraversal){
164 164
                     break;
165 165
                 }
166 166
 
167 167
                 continue;
168 168
             }
169 169
 
170
-            if (!$child instanceof NodeInterface) {
170
+            if (!$child instanceof NodeInterface){
171 171
                 continue;
172 172
             }
173 173
 
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
             $traverseChildren = true;
177 177
             $breakVisitorID = null;
178 178
 
179
-            foreach ($this->visitors as $visitorID => $visitor) {
179
+            foreach ($this->visitors as $visitorID => $visitor){
180 180
                 $result = $visitor->enterNode($child, $ctx);
181
-                switch (true) {
181
+                switch (true){
182 182
                     case $result === null:
183 183
                         break;
184 184
 
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 
202 202
                     default:
203 203
                         throw new LogicException(
204
-                            'enterNode() returned invalid value of type ' . gettype($result)
204
+                            'enterNode() returned invalid value of type '.gettype($result)
205 205
                         );
206 206
                 }
207 207
             }
208 208
 
209
-            if ($traverseChildren) {
209
+            if ($traverseChildren){
210 210
                 $child = $this->traverseNode($child, $ctx);
211
-                if ($this->stopTraversal) {
211
+                if ($this->stopTraversal){
212 212
                     break;
213 213
                 }
214 214
             }
215 215
 
216
-            foreach ($this->visitors as $visitorID => $visitor) {
216
+            foreach ($this->visitors as $visitorID => $visitor){
217 217
                 $result = $visitor->leaveNode($child, $ctx);
218 218
 
219
-                switch (true) {
219
+                switch (true){
220 220
                     case $result === null:
221 221
                         break;
222 222
 
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 
231 231
                     default:
232 232
                         throw new LogicException(
233
-                            'leaveNode() returned invalid value of type ' . gettype($result)
233
+                            'leaveNode() returned invalid value of type '.gettype($result)
234 234
                         );
235 235
                 }
236 236
 
237
-                if ($breakVisitorID === $visitorID) {
237
+                if ($breakVisitorID === $visitorID){
238 238
                     break;
239 239
                 }
240 240
             }
Please login to merge, or discard this patch.
Braces   +48 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function __construct(array $visitors = [])
31 31
     {
32
-        foreach ($visitors as $visitor) {
32
+        foreach ($visitors as $visitor)
33
+        {
33 34
             $this->addVisitor($visitor);
34 35
         }
35 36
     }
@@ -44,8 +45,10 @@  discard block
 block discarded – undo
44 45
 
45 46
     public function removeVisitor(VisitorInterface $visitor): void
46 47
     {
47
-        foreach ($this->visitors as $index => $added) {
48
-            if ($added === $visitor) {
48
+        foreach ($this->visitors as $index => $added)
49
+        {
50
+            if ($added === $visitor)
51
+            {
49 52
                 unset($this->visitors[$index]);
50 53
                 break;
51 54
             }
@@ -64,22 +67,27 @@  discard block
 block discarded – undo
64 67
         $context ??= new VisitorContext();
65 68
 
66 69
         $ctx = clone $context;
67
-        foreach ($nodes as $index => $node) {
68
-            if ($this->stopTraversal) {
70
+        foreach ($nodes as $index => $node)
71
+        {
72
+            if ($this->stopTraversal)
73
+            {
69 74
                 break;
70 75
             }
71 76
 
72 77
             $traverseChildren = true;
73 78
             $breakVisitorID = null;
74 79
 
75
-            if ($node instanceof NodeInterface) {
80
+            if ($node instanceof NodeInterface)
81
+            {
76 82
                 $ctx = $context->withNode($node);
77 83
             }
78 84
 
79
-            foreach ($this->visitors as $visitorID => $visitor) {
85
+            foreach ($this->visitors as $visitorID => $visitor)
86
+            {
80 87
                 $result = $visitor->enterNode($node, $ctx);
81 88
 
82
-                switch (true) {
89
+                switch (true)
90
+                {
83 91
                     case $result === null:
84 92
                         break;
85 93
 
@@ -109,17 +117,21 @@  discard block
 block discarded – undo
109 117
             }
110 118
 
111 119
             // sub nodes
112
-            if ($traverseChildren && $node instanceof NodeInterface) {
120
+            if ($traverseChildren && $node instanceof NodeInterface)
121
+            {
113 122
                 $nodes[$index] = $this->traverseNode($node, $ctx);
114
-                if ($this->stopTraversal) {
123
+                if ($this->stopTraversal)
124
+                {
115 125
                     break;
116 126
                 }
117 127
             }
118 128
 
119
-            foreach ($this->visitors as $visitorID => $visitor) {
129
+            foreach ($this->visitors as $visitorID => $visitor)
130
+            {
120 131
                 $result = $visitor->leaveNode($node, $ctx);
121 132
 
122
-                switch (true) {
133
+                switch (true)
134
+                {
123 135
                     case $result === null:
124 136
                         break;
125 137
 
@@ -141,7 +153,8 @@  discard block
 block discarded – undo
141 153
                         );
142 154
                 }
143 155
 
144
-                if ($breakVisitorID === $visitorID) {
156
+                if ($breakVisitorID === $visitorID)
157
+                {
145 158
                     break;
146 159
                 }
147 160
             }
@@ -156,18 +169,22 @@  discard block
 block discarded – undo
156 169
     private function traverseNode(NodeInterface $node, VisitorContext $context): NodeInterface
157 170
     {
158 171
         $ctx = clone $context;
159
-        foreach ($node as $name => $_) {
172
+        foreach ($node as $name => $_)
173
+        {
160 174
             $child = &$node->$name;
161
-            if (is_array($child)) {
175
+            if (is_array($child))
176
+            {
162 177
                 $child = $this->traverse($child, $ctx);
163
-                if ($this->stopTraversal) {
178
+                if ($this->stopTraversal)
179
+                {
164 180
                     break;
165 181
                 }
166 182
 
167 183
                 continue;
168 184
             }
169 185
 
170
-            if (!$child instanceof NodeInterface) {
186
+            if (!$child instanceof NodeInterface)
187
+            {
171 188
                 continue;
172 189
             }
173 190
 
@@ -176,9 +193,11 @@  discard block
 block discarded – undo
176 193
             $traverseChildren = true;
177 194
             $breakVisitorID = null;
178 195
 
179
-            foreach ($this->visitors as $visitorID => $visitor) {
196
+            foreach ($this->visitors as $visitorID => $visitor)
197
+            {
180 198
                 $result = $visitor->enterNode($child, $ctx);
181
-                switch (true) {
199
+                switch (true)
200
+                {
182 201
                     case $result === null:
183 202
                         break;
184 203
 
@@ -206,17 +225,21 @@  discard block
 block discarded – undo
206 225
                 }
207 226
             }
208 227
 
209
-            if ($traverseChildren) {
228
+            if ($traverseChildren)
229
+            {
210 230
                 $child = $this->traverseNode($child, $ctx);
211
-                if ($this->stopTraversal) {
231
+                if ($this->stopTraversal)
232
+                {
212 233
                     break;
213 234
                 }
214 235
             }
215 236
 
216
-            foreach ($this->visitors as $visitorID => $visitor) {
237
+            foreach ($this->visitors as $visitorID => $visitor)
238
+            {
217 239
                 $result = $visitor->leaveNode($child, $ctx);
218 240
 
219
-                switch (true) {
241
+                switch (true)
242
+                {
220 243
                     case $result === null:
221 244
                         break;
222 245
 
@@ -234,7 +257,8 @@  discard block
 block discarded – undo
234 257
                         );
235 258
                 }
236 259
 
237
-                if ($breakVisitorID === $visitorID) {
260
+                if ($breakVisitorID === $visitorID)
261
+                {
238 262
                     break;
239 263
                 }
240 264
             }
Please login to merge, or discard this patch.
src/Stempler/src/Compiler/Renderer/HTMLRenderer.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function render(Compiler $compiler, Result $result, NodeInterface $node): bool
30 30
     {
31
-        switch (true) {
31
+        switch (true){
32 32
             case $node instanceof Tag:
33 33
                 $this->tag($compiler, $result, $node);
34 34
                 return true;
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $result->push(sprintf('<%s', $node->name), $node->getContext());
52 52
 
53
-        foreach ($node->attrs as $attr) {
54
-            if (!$attr instanceof Attribute) {
53
+        foreach ($node->attrs as $attr){
54
+            if (!$attr instanceof Attribute){
55 55
                 $compiler->compile($attr, $result);
56 56
                 continue;
57 57
             }
@@ -61,30 +61,30 @@  discard block
 block discarded – undo
61 61
 
62 62
         $result->push(sprintf('%s>', $node->void ? '/' : ''), null);
63 63
 
64
-        foreach ($node->nodes as $child) {
64
+        foreach ($node->nodes as $child){
65 65
             $compiler->compile($child, $result);
66 66
         }
67 67
 
68
-        if (!$node->void) {
68
+        if (!$node->void){
69 69
             $result->push(sprintf('</%s>', $node->name), null);
70 70
         }
71 71
     }
72 72
 
73 73
     private function attribute(Compiler $compiler, Result $result, Attr $node): void
74 74
     {
75
-        if ($node->name instanceof NodeInterface) {
75
+        if ($node->name instanceof NodeInterface){
76 76
             $result->push(' ', null);
77 77
             $compiler->compile($node->name, $result);
78
-        } else {
78
+        }else{
79 79
             $result->push(sprintf(' %s', $node->name), $node->getContext());
80 80
         }
81 81
 
82 82
         $value = $node->value;
83
-        if ($value instanceof Nil) {
83
+        if ($value instanceof Nil){
84 84
             return;
85 85
         }
86 86
 
87
-        if ($value instanceof NodeInterface) {
87
+        if ($value instanceof NodeInterface){
88 88
             $result->push('=', null);
89 89
             $compiler->compile($value, $result);
90 90
             return;
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 
96 96
     private function verbatim(Compiler $compiler, Result $result, Verbatim $node): void
97 97
     {
98
-        foreach ($node->nodes as $child) {
99
-            if (is_string($child)) {
98
+        foreach ($node->nodes as $child){
99
+            if (is_string($child)){
100 100
                 $result->push($child, null);
101 101
                 continue;
102 102
             }
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function render(Compiler $compiler, Result $result, NodeInterface $node): bool
30 30
     {
31
-        switch (true) {
31
+        switch (true)
32
+        {
32 33
             case $node instanceof Tag:
33 34
                 $this->tag($compiler, $result, $node);
34 35
                 return true;
@@ -50,8 +51,10 @@  discard block
 block discarded – undo
50 51
     {
51 52
         $result->push(sprintf('<%s', $node->name), $node->getContext());
52 53
 
53
-        foreach ($node->attrs as $attr) {
54
-            if (!$attr instanceof Attribute) {
54
+        foreach ($node->attrs as $attr)
55
+        {
56
+            if (!$attr instanceof Attribute)
57
+            {
55 58
                 $compiler->compile($attr, $result);
56 59
                 continue;
57 60
             }
@@ -61,30 +64,37 @@  discard block
 block discarded – undo
61 64
 
62 65
         $result->push(sprintf('%s>', $node->void ? '/' : ''), null);
63 66
 
64
-        foreach ($node->nodes as $child) {
67
+        foreach ($node->nodes as $child)
68
+        {
65 69
             $compiler->compile($child, $result);
66 70
         }
67 71
 
68
-        if (!$node->void) {
72
+        if (!$node->void)
73
+        {
69 74
             $result->push(sprintf('</%s>', $node->name), null);
70 75
         }
71 76
     }
72 77
 
73 78
     private function attribute(Compiler $compiler, Result $result, Attr $node): void
74 79
     {
75
-        if ($node->name instanceof NodeInterface) {
80
+        if ($node->name instanceof NodeInterface)
81
+        {
76 82
             $result->push(' ', null);
77 83
             $compiler->compile($node->name, $result);
78
-        } else {
84
+        }
85
+        else
86
+        {
79 87
             $result->push(sprintf(' %s', $node->name), $node->getContext());
80 88
         }
81 89
 
82 90
         $value = $node->value;
83
-        if ($value instanceof Nil) {
91
+        if ($value instanceof Nil)
92
+        {
84 93
             return;
85 94
         }
86 95
 
87
-        if ($value instanceof NodeInterface) {
96
+        if ($value instanceof NodeInterface)
97
+        {
88 98
             $result->push('=', null);
89 99
             $compiler->compile($value, $result);
90 100
             return;
@@ -95,8 +105,10 @@  discard block
 block discarded – undo
95 105
 
96 106
     private function verbatim(Compiler $compiler, Result $result, Verbatim $node): void
97 107
     {
98
-        foreach ($node->nodes as $child) {
99
-            if (is_string($child)) {
108
+        foreach ($node->nodes as $child)
109
+        {
110
+            if (is_string($child))
111
+            {
100 112
                 $result->push($child, null);
101 113
                 continue;
102 114
             }
Please login to merge, or discard this patch.
src/Stempler/src/Compiler/Renderer/DynamicRenderer.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     public function __construct(
33 33
         DirectiveRendererInterface $directiveRenderer = null,
34 34
         string $defaultFilter = self::DEFAULT_FILTER
35
-    ) {
35
+    ){
36 36
         $this->directiveRenderer = $directiveRenderer;
37 37
         $this->defaultFilter = $defaultFilter;
38 38
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function render(Compiler $compiler, Result $result, NodeInterface $node): bool
44 44
     {
45
-        switch (true) {
45
+        switch (true){
46 46
             case $node instanceof Output:
47 47
                 $this->output($result, $node);
48 48
                 return true;
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function directive(Result $source, Directive $directive): void
62 62
     {
63
-        if ($this->directiveRenderer !== null) {
63
+        if ($this->directiveRenderer !== null){
64 64
             $result = $this->directiveRenderer->render($directive);
65
-            if ($result !== null) {
65
+            if ($result !== null){
66 66
                 $source->push($result, $directive->getContext());
67 67
                 return;
68 68
             }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
     private function output(Result $source, Output $output): void
78 78
     {
79
-        if ($output->rawOutput) {
79
+        if ($output->rawOutput){
80 80
             $source->push(sprintf('<?php echo %s; ?>', trim($output->body)), $output->getContext());
81 81
             return;
82 82
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function render(Compiler $compiler, Result $result, NodeInterface $node): bool
44 44
     {
45
-        switch (true) {
45
+        switch (true)
46
+        {
46 47
             case $node instanceof Output:
47 48
                 $this->output($result, $node);
48 49
                 return true;
@@ -60,9 +61,11 @@  discard block
 block discarded – undo
60 61
      */
61 62
     private function directive(Result $source, Directive $directive): void
62 63
     {
63
-        if ($this->directiveRenderer !== null) {
64
+        if ($this->directiveRenderer !== null)
65
+        {
64 66
             $result = $this->directiveRenderer->render($directive);
65
-            if ($result !== null) {
67
+            if ($result !== null)
68
+            {
66 69
                 $source->push($result, $directive->getContext());
67 70
                 return;
68 71
             }
@@ -76,7 +79,8 @@  discard block
 block discarded – undo
76 79
 
77 80
     private function output(Result $source, Output $output): void
78 81
     {
79
-        if ($output->rawOutput) {
82
+        if ($output->rawOutput)
83
+        {
80 84
             $source->push(sprintf('<?php echo %s; ?>', trim($output->body)), $output->getContext());
81 85
             return;
82 86
         }
Please login to merge, or discard this patch.
src/Stempler/src/Compiler/Renderer/CoreRenderer.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         Result $result,
33 33
         NodeInterface $node
34 34
     ): bool {
35
-        switch (true) {
35
+        switch (true){
36 36
             case $node instanceof Hidden:
37 37
                 return true;
38 38
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
                 $result->withinContext(
41 41
                     $node->getContext(),
42 42
                     function (Result $source) use ($node, $compiler): void {
43
-                        foreach ($node->nodes as $child) {
43
+                        foreach ($node->nodes as $child){
44 44
                             $compiler->compile($child, $source);
45 45
                         }
46 46
                     }
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
                 $result->withinContext(
53 53
                     $node->getContext(),
54 54
                     function (Result $source) use ($node, $compiler): void {
55
-                        foreach ($node->nodes as $child) {
56
-                            if (is_string($child)) {
55
+                        foreach ($node->nodes as $child){
56
+                            if (is_string($child)){
57 57
                                 $source->push($child, null);
58 58
                                 continue;
59 59
                             }
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,8 @@  discard block
 block discarded – undo
32 32
         Result $result,
33 33
         NodeInterface $node
34 34
     ): bool {
35
-        switch (true) {
35
+        switch (true)
36
+        {
36 37
             case $node instanceof Hidden:
37 38
                 return true;
38 39
 
@@ -40,7 +41,8 @@  discard block
 block discarded – undo
40 41
                 $result->withinContext(
41 42
                     $node->getContext(),
42 43
                     function (Result $source) use ($node, $compiler): void {
43
-                        foreach ($node->nodes as $child) {
44
+                        foreach ($node->nodes as $child)
45
+                        {
44 46
                             $compiler->compile($child, $source);
45 47
                         }
46 48
                     }
@@ -52,8 +54,10 @@  discard block
 block discarded – undo
52 54
                 $result->withinContext(
53 55
                     $node->getContext(),
54 56
                     function (Result $source) use ($node, $compiler): void {
55
-                        foreach ($node->nodes as $child) {
56
-                            if (is_string($child)) {
57
+                        foreach ($node->nodes as $child)
58
+                        {
59
+                            if (is_string($child))
60
+                            {
57 61
                                 $source->push($child, null);
58 62
                                 continue;
59 63
                             }
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
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function render(Compiler $compiler, Result $result, NodeInterface $node): bool
26 26
     {
27
-        if ($node instanceof PHP) {
27
+        if ($node instanceof PHP){
28 28
             $result->push($node->content, $node->getContext());
29 29
             return true;
30 30
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@
 block discarded – undo
24 24
      */
25 25
     public function render(Compiler $compiler, Result $result, NodeInterface $node): bool
26 26
     {
27
-        if ($node instanceof PHP) {
27
+        if ($node instanceof PHP)
28
+        {
28 29
             $result->push($node->content, $node->getContext());
29 30
             return true;
30 31
         }
Please login to merge, or discard this patch.