@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | Compiler\Result $result, |
32 | 32 | NodeInterface $node |
33 | 33 | ): bool { |
34 | - switch (true) { |
|
34 | + switch (true){ |
|
35 | 35 | case $node instanceof Hidden: |
36 | 36 | return true; |
37 | 37 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $result->withinContext( |
40 | 40 | $node->getContext(), |
41 | 41 | function (Compiler\Result $source) use ($node, $compiler): void { |
42 | - foreach ($node->nodes as $child) { |
|
42 | + foreach ($node->nodes as $child){ |
|
43 | 43 | $compiler->compile($child, $source); |
44 | 44 | } |
45 | 45 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $result->withinContext( |
52 | 52 | $node->getContext(), |
53 | 53 | function (Compiler\Result $source) use ($node, $compiler): void { |
54 | - foreach ($node->nodes as $child) { |
|
55 | - if (is_string($child)) { |
|
54 | + foreach ($node->nodes as $child){ |
|
55 | + if (is_string($child)){ |
|
56 | 56 | $source->push($child, null); |
57 | 57 | continue; |
58 | 58 | } |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | Compiler\Result $result, |
32 | 32 | NodeInterface $node |
33 | 33 | ): bool { |
34 | - switch (true) { |
|
34 | + switch (true) |
|
35 | + { |
|
35 | 36 | case $node instanceof Hidden: |
36 | 37 | return true; |
37 | 38 | |
@@ -39,7 +40,8 @@ discard block |
||
39 | 40 | $result->withinContext( |
40 | 41 | $node->getContext(), |
41 | 42 | function (Compiler\Result $source) use ($node, $compiler): void { |
42 | - foreach ($node->nodes as $child) { |
|
43 | + foreach ($node->nodes as $child) |
|
44 | + { |
|
43 | 45 | $compiler->compile($child, $source); |
44 | 46 | } |
45 | 47 | } |
@@ -51,8 +53,10 @@ discard block |
||
51 | 53 | $result->withinContext( |
52 | 54 | $node->getContext(), |
53 | 55 | function (Compiler\Result $source) use ($node, $compiler): void { |
54 | - foreach ($node->nodes as $child) { |
|
55 | - if (is_string($child)) { |
|
56 | + foreach ($node->nodes as $child) |
|
57 | + { |
|
58 | + if (is_string($child)) |
|
59 | + { |
|
56 | 60 | $source->push($child, null); |
57 | 61 | continue; |
58 | 62 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | $buffer = null; |
33 | 33 | $bufferOffset = 0; |
34 | 34 | |
35 | - foreach ($inner as $n) { |
|
35 | + foreach ($inner as $n){ |
|
36 | 36 | $token->offset = $token->offset ?? $n->offset; |
37 | 37 | |
38 | - if ($n instanceof Byte) { |
|
39 | - if ($buffer === null) { |
|
38 | + if ($n instanceof Byte){ |
|
39 | + if ($buffer === null){ |
|
40 | 40 | $buffer = ''; |
41 | 41 | $bufferOffset = $n->offset; |
42 | 42 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | continue; |
48 | 48 | } |
49 | 49 | |
50 | - if ($buffer !== null) { |
|
50 | + if ($buffer !== null){ |
|
51 | 51 | $token->tokens[] = new Token( |
52 | 52 | Token::TYPE_RAW, |
53 | 53 | $bufferOffset, |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $token->tokens[] = $n; |
62 | 62 | } |
63 | 63 | |
64 | - if ($buffer !== null) { |
|
64 | + if ($buffer !== null){ |
|
65 | 65 | $token->tokens[] = new Token( |
66 | 66 | Token::TYPE_RAW, |
67 | 67 | $bufferOffset, |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ); |
71 | 71 | } |
72 | 72 | |
73 | - if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) { |
|
73 | + if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW){ |
|
74 | 74 | $token->tokens = []; |
75 | 75 | } |
76 | 76 |
@@ -32,11 +32,14 @@ discard block |
||
32 | 32 | $buffer = null; |
33 | 33 | $bufferOffset = 0; |
34 | 34 | |
35 | - foreach ($inner as $n) { |
|
35 | + foreach ($inner as $n) |
|
36 | + { |
|
36 | 37 | $token->offset = $token->offset ?? $n->offset; |
37 | 38 | |
38 | - if ($n instanceof Byte) { |
|
39 | - if ($buffer === null) { |
|
39 | + if ($n instanceof Byte) |
|
40 | + { |
|
41 | + if ($buffer === null) |
|
42 | + { |
|
40 | 43 | $buffer = ''; |
41 | 44 | $bufferOffset = $n->offset; |
42 | 45 | } |
@@ -47,7 +50,8 @@ discard block |
||
47 | 50 | continue; |
48 | 51 | } |
49 | 52 | |
50 | - if ($buffer !== null) { |
|
53 | + if ($buffer !== null) |
|
54 | + { |
|
51 | 55 | $token->tokens[] = new Token( |
52 | 56 | Token::TYPE_RAW, |
53 | 57 | $bufferOffset, |
@@ -61,7 +65,8 @@ discard block |
||
61 | 65 | $token->tokens[] = $n; |
62 | 66 | } |
63 | 67 | |
64 | - if ($buffer !== null) { |
|
68 | + if ($buffer !== null) |
|
69 | + { |
|
65 | 70 | $token->tokens[] = new Token( |
66 | 71 | Token::TYPE_RAW, |
67 | 72 | $bufferOffset, |
@@ -70,7 +75,8 @@ discard block |
||
70 | 75 | ); |
71 | 76 | } |
72 | 77 | |
73 | - if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) { |
|
78 | + if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) |
|
79 | + { |
|
74 | 80 | $token->tokens = []; |
75 | 81 | } |
76 | 82 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
71 | 71 | { |
72 | - switch ($token->type) { |
|
72 | + switch ($token->type){ |
|
73 | 73 | case HTMLGrammar::TYPE_OPEN: |
74 | 74 | case HTMLGrammar::TYPE_OPEN_SHORT: |
75 | 75 | $this->node = new Tag(new Parser\Context($token, $parser->getPath())); |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | break; |
79 | 79 | |
80 | 80 | case HTMLGrammar::TYPE_KEYWORD: |
81 | - if ($this->node->name === null) { |
|
81 | + if ($this->node->name === null){ |
|
82 | 82 | $this->node->name = $this->parseToken($parser, $token); |
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
86 | + if ($this->attr !== null && !$this->attr->value instanceof Nil){ |
|
87 | 87 | $this->attr->value = $this->parseToken($parser, $token); |
88 | 88 | $this->attr = null; |
89 | 89 | break; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | break; |
100 | 100 | |
101 | 101 | case HTMLGrammar::TYPE_EQUAL: |
102 | - if ($this->attr === null) { |
|
102 | + if ($this->attr === null){ |
|
103 | 103 | throw new SyntaxException('unexpected attribute token', $token); |
104 | 104 | } |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | break; |
109 | 109 | |
110 | 110 | case HTMLGrammar::TYPE_ATTRIBUTE: |
111 | - if ($this->attr === null) { |
|
111 | + if ($this->attr === null){ |
|
112 | 112 | throw new SyntaxException('unexpected attribute token', $token); |
113 | 113 | } |
114 | 114 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | strpos($this->attr->name, 'on') === 0 |
119 | 119 | || in_array($this->attr->name, self::VERBATIM_ATTRIBUTES, true) |
120 | 120 | ) |
121 | - ) { |
|
121 | + ){ |
|
122 | 122 | $this->attr->value = $this->parseVerbatim($parser, $token); |
123 | - } else { |
|
123 | + }else{ |
|
124 | 124 | $this->attr->value = $this->parseToken($parser, $token); |
125 | 125 | } |
126 | 126 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | break; |
135 | 135 | |
136 | 136 | case HTMLGrammar::TYPE_CLOSE: |
137 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
138 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
137 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT){ |
|
138 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name){ |
|
139 | 139 | throw new SyntaxException( |
140 | 140 | "Invalid closing tag `{$this->node->name}`, expected `{$asm->getNode()->name}`", |
141 | 141 | $this->token |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | $asm->close(); |
146 | - } else { |
|
147 | - if (in_array($this->node->name, self::VOID_TAGS)) { |
|
146 | + }else{ |
|
147 | + if (in_array($this->node->name, self::VOID_TAGS)){ |
|
148 | 148 | $this->node->void = true; |
149 | 149 | $asm->push($this->node); |
150 | - } else { |
|
150 | + }else{ |
|
151 | 151 | $asm->open($this->node, 'nodes'); |
152 | 152 | } |
153 | 153 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | break; |
161 | 161 | |
162 | 162 | default: |
163 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
163 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim){ |
|
164 | 164 | $node = $this->parseToken($parser, $token); |
165 | - if (is_string($node)) { |
|
165 | + if (is_string($node)){ |
|
166 | 166 | $node = new Raw($node, new Parser\Context($token, $parser->getPath())); |
167 | 167 | } |
168 | 168 | |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | { |
191 | 191 | $verbatim = new Verbatim(new Parser\Context($token, $parser->getPath())); |
192 | 192 | |
193 | - if ($token->tokens === []) { |
|
194 | - if ($token->content) { |
|
193 | + if ($token->tokens === []){ |
|
194 | + if ($token->content){ |
|
195 | 195 | $verbatim->nodes[] = $token->content; |
196 | 196 | } |
197 | - } else { |
|
197 | + }else{ |
|
198 | 198 | $parser->parseTokens( |
199 | 199 | new Assembler($verbatim, 'nodes'), |
200 | 200 | $token->tokens |
@@ -69,7 +69,8 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
71 | 71 | { |
72 | - switch ($token->type) { |
|
72 | + switch ($token->type) |
|
73 | + { |
|
73 | 74 | case HTMLGrammar::TYPE_OPEN: |
74 | 75 | case HTMLGrammar::TYPE_OPEN_SHORT: |
75 | 76 | $this->node = new Tag(new Parser\Context($token, $parser->getPath())); |
@@ -78,12 +79,14 @@ discard block |
||
78 | 79 | break; |
79 | 80 | |
80 | 81 | case HTMLGrammar::TYPE_KEYWORD: |
81 | - if ($this->node->name === null) { |
|
82 | + if ($this->node->name === null) |
|
83 | + { |
|
82 | 84 | $this->node->name = $this->parseToken($parser, $token); |
83 | 85 | return; |
84 | 86 | } |
85 | 87 | |
86 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
88 | + if ($this->attr !== null && !$this->attr->value instanceof Nil) |
|
89 | + { |
|
87 | 90 | $this->attr->value = $this->parseToken($parser, $token); |
88 | 91 | $this->attr = null; |
89 | 92 | break; |
@@ -99,7 +102,8 @@ discard block |
||
99 | 102 | break; |
100 | 103 | |
101 | 104 | case HTMLGrammar::TYPE_EQUAL: |
102 | - if ($this->attr === null) { |
|
105 | + if ($this->attr === null) |
|
106 | + { |
|
103 | 107 | throw new SyntaxException('unexpected attribute token', $token); |
104 | 108 | } |
105 | 109 | |
@@ -108,7 +112,8 @@ discard block |
||
108 | 112 | break; |
109 | 113 | |
110 | 114 | case HTMLGrammar::TYPE_ATTRIBUTE: |
111 | - if ($this->attr === null) { |
|
115 | + if ($this->attr === null) |
|
116 | + { |
|
112 | 117 | throw new SyntaxException('unexpected attribute token', $token); |
113 | 118 | } |
114 | 119 | |
@@ -120,7 +125,9 @@ discard block |
||
120 | 125 | ) |
121 | 126 | ) { |
122 | 127 | $this->attr->value = $this->parseVerbatim($parser, $token); |
123 | - } else { |
|
128 | + } |
|
129 | + else |
|
130 | + { |
|
124 | 131 | $this->attr->value = $this->parseToken($parser, $token); |
125 | 132 | } |
126 | 133 | |
@@ -134,8 +141,10 @@ discard block |
||
134 | 141 | break; |
135 | 142 | |
136 | 143 | case HTMLGrammar::TYPE_CLOSE: |
137 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
138 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
144 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) |
|
145 | + { |
|
146 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) |
|
147 | + { |
|
139 | 148 | throw new SyntaxException( |
140 | 149 | "Invalid closing tag `{$this->node->name}`, expected `{$asm->getNode()->name}`", |
141 | 150 | $this->token |
@@ -143,11 +152,16 @@ discard block |
||
143 | 152 | } |
144 | 153 | |
145 | 154 | $asm->close(); |
146 | - } else { |
|
147 | - if (in_array($this->node->name, self::VOID_TAGS)) { |
|
155 | + } |
|
156 | + else |
|
157 | + { |
|
158 | + if (in_array($this->node->name, self::VOID_TAGS)) |
|
159 | + { |
|
148 | 160 | $this->node->void = true; |
149 | 161 | $asm->push($this->node); |
150 | - } else { |
|
162 | + } |
|
163 | + else |
|
164 | + { |
|
151 | 165 | $asm->open($this->node, 'nodes'); |
152 | 166 | } |
153 | 167 | } |
@@ -160,9 +174,11 @@ discard block |
||
160 | 174 | break; |
161 | 175 | |
162 | 176 | default: |
163 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
177 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) |
|
178 | + { |
|
164 | 179 | $node = $this->parseToken($parser, $token); |
165 | - if (is_string($node)) { |
|
180 | + if (is_string($node)) |
|
181 | + { |
|
166 | 182 | $node = new Raw($node, new Parser\Context($token, $parser->getPath())); |
167 | 183 | } |
168 | 184 | |
@@ -190,11 +206,15 @@ discard block |
||
190 | 206 | { |
191 | 207 | $verbatim = new Verbatim(new Parser\Context($token, $parser->getPath())); |
192 | 208 | |
193 | - if ($token->tokens === []) { |
|
194 | - if ($token->content) { |
|
209 | + if ($token->tokens === []) |
|
210 | + { |
|
211 | + if ($token->content) |
|
212 | + { |
|
195 | 213 | $verbatim->nodes[] = $token->content; |
196 | 214 | } |
197 | - } else { |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
198 | 218 | $parser->parseTokens( |
199 | 219 | new Assembler($verbatim, 'nodes'), |
200 | 220 | $token->tokens |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
32 | 32 | { |
33 | - switch ($token->type) { |
|
33 | + switch ($token->type){ |
|
34 | 34 | case InlineGrammar::TYPE_OPEN_TAG: |
35 | 35 | $this->inline = new Inline(new Parser\Context($token, $parser->getPath())); |
36 | 36 | $asm->push($this->inline); |
@@ -30,7 +30,8 @@ |
||
30 | 30 | */ |
31 | 31 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
32 | 32 | { |
33 | - switch ($token->type) { |
|
33 | + switch ($token->type) |
|
34 | + { |
|
34 | 35 | case InlineGrammar::TYPE_OPEN_TAG: |
35 | 36 | $this->inline = new Inline(new Parser\Context($token, $parser->getPath())); |
36 | 37 | $asm->push($this->inline); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
38 | 38 | { |
39 | - switch ($token->type) { |
|
39 | + switch ($token->type){ |
|
40 | 40 | case DynamicGrammar::TYPE_DIRECTIVE: |
41 | 41 | $this->directive = new Directive(new Parser\Context($token, $parser->getPath())); |
42 | 42 | $asm->push($this->directive); |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | break; |
62 | 62 | |
63 | 63 | case DynamicGrammar::TYPE_KEYWORD: |
64 | - if ($this->directive !== null) { |
|
64 | + if ($this->directive !== null){ |
|
65 | 65 | $this->directive->name = $token->content; |
66 | 66 | } |
67 | 67 | break; |
68 | 68 | |
69 | 69 | case DynamicGrammar::TYPE_BODY: |
70 | - if ($this->directive !== null) { |
|
70 | + if ($this->directive !== null){ |
|
71 | 71 | $this->directive->body = $token->content; |
72 | 72 | $this->directive->values = $this->fetchValues($this->directive->body); |
73 | 73 | |
74 | 74 | $this->directive = null; |
75 | 75 | } |
76 | 76 | |
77 | - if ($this->output !== null) { |
|
77 | + if ($this->output !== null){ |
|
78 | 78 | $this->output->body = $token->content; |
79 | 79 | } |
80 | 80 | |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | |
96 | 96 | $src = new StringStream($body); |
97 | 97 | |
98 | - while ($n = $src->peak()) { |
|
99 | - if (in_array($n, ['"', '"'])) { |
|
98 | + while ($n = $src->peak()){ |
|
99 | + if (in_array($n, ['"', '"'])){ |
|
100 | 100 | $values[count($values) - 1] .= $n; |
101 | - while ($nn = $src->peak()) { |
|
101 | + while ($nn = $src->peak()){ |
|
102 | 102 | $values[count($values) - 1] .= $nn; |
103 | - if ($nn === $n) { |
|
103 | + if ($nn === $n){ |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | } |
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | |
110 | - if ($n === ',' && $level === 0) { |
|
110 | + if ($n === ',' && $level === 0){ |
|
111 | 111 | $values[] = ''; |
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $values[count($values) - 1] .= $n; |
116 | 116 | |
117 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
117 | + if ($n === '(' || $n === '[' || $n === '{'){ |
|
118 | 118 | $level++; |
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | |
122 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
122 | + if ($n === ')' || $n === ']' || $n === '}'){ |
|
123 | 123 | $level--; |
124 | 124 | } |
125 | 125 | } |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
38 | 38 | { |
39 | - switch ($token->type) { |
|
39 | + switch ($token->type) |
|
40 | + { |
|
40 | 41 | case DynamicGrammar::TYPE_DIRECTIVE: |
41 | 42 | $this->directive = new Directive(new Parser\Context($token, $parser->getPath())); |
42 | 43 | $asm->push($this->directive); |
@@ -61,20 +62,23 @@ discard block |
||
61 | 62 | break; |
62 | 63 | |
63 | 64 | case DynamicGrammar::TYPE_KEYWORD: |
64 | - if ($this->directive !== null) { |
|
65 | + if ($this->directive !== null) |
|
66 | + { |
|
65 | 67 | $this->directive->name = $token->content; |
66 | 68 | } |
67 | 69 | break; |
68 | 70 | |
69 | 71 | case DynamicGrammar::TYPE_BODY: |
70 | - if ($this->directive !== null) { |
|
72 | + if ($this->directive !== null) |
|
73 | + { |
|
71 | 74 | $this->directive->body = $token->content; |
72 | 75 | $this->directive->values = $this->fetchValues($this->directive->body); |
73 | 76 | |
74 | 77 | $this->directive = null; |
75 | 78 | } |
76 | 79 | |
77 | - if ($this->output !== null) { |
|
80 | + if ($this->output !== null) |
|
81 | + { |
|
78 | 82 | $this->output->body = $token->content; |
79 | 83 | } |
80 | 84 | |
@@ -95,31 +99,38 @@ discard block |
||
95 | 99 | |
96 | 100 | $src = new StringStream($body); |
97 | 101 | |
98 | - while ($n = $src->peak()) { |
|
99 | - if (in_array($n, ['"', '"'])) { |
|
102 | + while ($n = $src->peak()) |
|
103 | + { |
|
104 | + if (in_array($n, ['"', '"'])) |
|
105 | + { |
|
100 | 106 | $values[count($values) - 1] .= $n; |
101 | - while ($nn = $src->peak()) { |
|
107 | + while ($nn = $src->peak()) |
|
108 | + { |
|
102 | 109 | $values[count($values) - 1] .= $nn; |
103 | - if ($nn === $n) { |
|
110 | + if ($nn === $n) |
|
111 | + { |
|
104 | 112 | break; |
105 | 113 | } |
106 | 114 | } |
107 | 115 | continue; |
108 | 116 | } |
109 | 117 | |
110 | - if ($n === ',' && $level === 0) { |
|
118 | + if ($n === ',' && $level === 0) |
|
119 | + { |
|
111 | 120 | $values[] = ''; |
112 | 121 | continue; |
113 | 122 | } |
114 | 123 | |
115 | 124 | $values[count($values) - 1] .= $n; |
116 | 125 | |
117 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
126 | + if ($n === '(' || $n === '[' || $n === '{') |
|
127 | + { |
|
118 | 128 | $level++; |
119 | 129 | continue; |
120 | 130 | } |
121 | 131 | |
122 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
132 | + if ($n === ')' || $n === ']' || $n === '}') |
|
133 | + { |
|
123 | 134 | $level--; |
124 | 135 | } |
125 | 136 | } |
@@ -41,16 +41,16 @@ |
||
41 | 41 | { |
42 | 42 | $result = $result ?? new Result(); |
43 | 43 | |
44 | - if (is_array($node)) { |
|
45 | - foreach ($node as $child) { |
|
44 | + if (is_array($node)){ |
|
45 | + foreach ($node as $child){ |
|
46 | 46 | $this->compile($child, $result); |
47 | 47 | } |
48 | 48 | |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - foreach ($this->renders as $renderer) { |
|
53 | - if ($renderer->render($this, $result, $node)) { |
|
52 | + foreach ($this->renders as $renderer){ |
|
53 | + if ($renderer->render($this, $result, $node)){ |
|
54 | 54 | return $result; |
55 | 55 | } |
56 | 56 | } |
@@ -41,16 +41,20 @@ |
||
41 | 41 | { |
42 | 42 | $result = $result ?? new Result(); |
43 | 43 | |
44 | - if (is_array($node)) { |
|
45 | - foreach ($node as $child) { |
|
44 | + if (is_array($node)) |
|
45 | + { |
|
46 | + foreach ($node as $child) |
|
47 | + { |
|
46 | 48 | $this->compile($child, $result); |
47 | 49 | } |
48 | 50 | |
49 | 51 | return $result; |
50 | 52 | } |
51 | 53 | |
52 | - foreach ($this->renders as $renderer) { |
|
53 | - if ($renderer->render($this, $result, $node)) { |
|
54 | + foreach ($this->renders as $renderer) |
|
55 | + { |
|
56 | + if ($renderer->render($this, $result, $node)) |
|
57 | + { |
|
54 | 58 | return $result; |
55 | 59 | } |
56 | 60 | } |
@@ -26,11 +26,11 @@ |
||
26 | 26 | */ |
27 | 27 | public function enterNode(Node $node) |
28 | 28 | { |
29 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
29 | + if ($node instanceof Node\Stmt\Namespace_){ |
|
30 | 30 | $this->namespace = implode('\\', $node->name->parts); |
31 | 31 | } |
32 | 32 | |
33 | - if ($node instanceof Node\Stmt\Class_) { |
|
33 | + if ($node instanceof Node\Stmt\Class_){ |
|
34 | 34 | $this->class = $node->name->name; |
35 | 35 | |
36 | 36 | return NodeTraverser::STOP_TRAVERSAL; |
@@ -26,11 +26,13 @@ |
||
26 | 26 | */ |
27 | 27 | public function enterNode(Node $node) |
28 | 28 | { |
29 | - if ($node instanceof Node\Stmt\Namespace_) { |
|
29 | + if ($node instanceof Node\Stmt\Namespace_) |
|
30 | + { |
|
30 | 31 | $this->namespace = implode('\\', $node->name->parts); |
31 | 32 | } |
32 | 33 | |
33 | - if ($node instanceof Node\Stmt\Class_) { |
|
34 | + if ($node instanceof Node\Stmt\Class_) |
|
35 | + { |
|
34 | 36 | $this->class = $node->name->name; |
35 | 37 | |
36 | 38 | return NodeTraverser::STOP_TRAVERSAL; |
@@ -28,26 +28,26 @@ |
||
28 | 28 | */ |
29 | 29 | public function leaveNode(Node $node) |
30 | 30 | { |
31 | - if (!$node instanceof Node\Stmt\TraitUse) { |
|
31 | + if (!$node instanceof Node\Stmt\TraitUse){ |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 | |
35 | - foreach ($node->traits as $index => $use) { |
|
36 | - if ($use instanceof Node\Name) { |
|
35 | + foreach ($node->traits as $index => $use){ |
|
36 | + if ($use instanceof Node\Name){ |
|
37 | 37 | $name = $this->trimSlashes(implode('\\', $use->parts)); |
38 | 38 | if ( |
39 | 39 | in_array($name, [ |
40 | 40 | $this->trimSlashes(PrototypeTrait::class), |
41 | 41 | Utils::shortName(PrototypeTrait::class), |
42 | 42 | ], true) |
43 | - ) { |
|
43 | + ){ |
|
44 | 44 | unset($node->traits[$index]); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | 49 | $node->traits = array_values($node->traits); |
50 | - if (empty($node->traits)) { |
|
50 | + if (empty($node->traits)){ |
|
51 | 51 | return NodeTraverser::REMOVE_NODE; |
52 | 52 | } |
53 | 53 |
@@ -28,12 +28,15 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function leaveNode(Node $node) |
30 | 30 | { |
31 | - if (!$node instanceof Node\Stmt\TraitUse) { |
|
31 | + if (!$node instanceof Node\Stmt\TraitUse) |
|
32 | + { |
|
32 | 33 | return null; |
33 | 34 | } |
34 | 35 | |
35 | - foreach ($node->traits as $index => $use) { |
|
36 | - if ($use instanceof Node\Name) { |
|
36 | + foreach ($node->traits as $index => $use) |
|
37 | + { |
|
38 | + if ($use instanceof Node\Name) |
|
39 | + { |
|
37 | 40 | $name = $this->trimSlashes(implode('\\', $use->parts)); |
38 | 41 | if ( |
39 | 42 | in_array($name, [ |
@@ -47,7 +50,8 @@ discard block |
||
47 | 50 | } |
48 | 51 | |
49 | 52 | $node->traits = array_values($node->traits); |
50 | - if (empty($node->traits)) { |
|
53 | + if (empty($node->traits)) |
|
54 | + { |
|
51 | 55 | return NodeTraverser::REMOVE_NODE; |
52 | 56 | } |
53 | 57 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | namespace Spiral\Scaffolder; |
13 | 13 | |
14 | -if (!function_exists('trimPostfix')) { |
|
14 | +if (!function_exists('trimPostfix')){ |
|
15 | 15 | /** |
16 | 16 | * @param string $name |
17 | 17 | * @param string $postfix |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -if (!function_exists('isAssociativeArray')) { |
|
29 | +if (!function_exists('isAssociativeArray')){ |
|
30 | 30 | /** |
31 | 31 | * @param array $array |
32 | 32 | * @return bool |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | function isAssociativeArray(array $array): bool |
36 | 36 | { |
37 | 37 | $keys = []; |
38 | - foreach ($array as $key => $_) { |
|
39 | - if (!is_int($key)) { |
|
38 | + foreach ($array as $key => $_){ |
|
39 | + if (!is_int($key)){ |
|
40 | 40 | return true; |
41 | 41 | } |
42 | 42 | |
43 | - if ($key !== count($keys)) { |
|
43 | + if ($key !== count($keys)){ |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -if (!function_exists('defineArrayType')) { |
|
54 | +if (!function_exists('defineArrayType')){ |
|
55 | 55 | /** |
56 | 56 | * @param array $array |
57 | 57 | * @param string|null $failureType |