@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
26 | 26 | { |
27 | - switch ($token->type) { |
|
27 | + switch ($token->type){ |
|
28 | 28 | case DynamicGrammar::TYPE_DIRECTIVE: |
29 | 29 | $this->directive = new Directive(new Context($token, $parser->getPath())); |
30 | 30 | $asm->push($this->directive); |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | break; |
50 | 50 | |
51 | 51 | case DynamicGrammar::TYPE_KEYWORD: |
52 | - if ($this->directive !== null) { |
|
52 | + if ($this->directive !== null){ |
|
53 | 53 | $this->directive->name = $token->content; |
54 | 54 | } |
55 | 55 | break; |
56 | 56 | |
57 | 57 | case DynamicGrammar::TYPE_BODY: |
58 | - if ($this->directive !== null) { |
|
58 | + if ($this->directive !== null){ |
|
59 | 59 | $this->directive->body = $token->content; |
60 | 60 | $this->directive->values = $this->fetchValues($this->directive->body); |
61 | 61 | |
62 | 62 | $this->directive = null; |
63 | 63 | } |
64 | 64 | |
65 | - if ($this->output !== null) { |
|
65 | + if ($this->output !== null){ |
|
66 | 66 | $this->output->body = $token->content; |
67 | 67 | } |
68 | 68 | |
@@ -80,31 +80,31 @@ discard block |
||
80 | 80 | |
81 | 81 | $src = new StringStream($body); |
82 | 82 | |
83 | - while ($n = $src->peak()) { |
|
84 | - if (\in_array($n, ['"', "'"], true)) { |
|
83 | + while ($n = $src->peak()){ |
|
84 | + if (\in_array($n, ['"', "'"], true)){ |
|
85 | 85 | $values[\count($values) - 1] .= $n; |
86 | - while (($nn = $src->peak()) !== null) { |
|
86 | + while (($nn = $src->peak()) !== null){ |
|
87 | 87 | $values[\count($values) - 1] .= $nn; |
88 | - if ($nn === $n) { |
|
88 | + if ($nn === $n){ |
|
89 | 89 | break; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | |
95 | - if ($n === ',' && $level === 0) { |
|
95 | + if ($n === ',' && $level === 0){ |
|
96 | 96 | $values[] = ''; |
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
100 | 100 | $values[\count($values) - 1] .= $n; |
101 | 101 | |
102 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
102 | + if ($n === '(' || $n === '[' || $n === '{'){ |
|
103 | 103 | $level++; |
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
107 | + if ($n === ')' || $n === ']' || $n === '}'){ |
|
108 | 108 | $level--; |
109 | 109 | } |
110 | 110 | } |
@@ -24,7 +24,8 @@ discard block |
||
24 | 24 | |
25 | 25 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
26 | 26 | { |
27 | - switch ($token->type) { |
|
27 | + switch ($token->type) |
|
28 | + { |
|
28 | 29 | case DynamicGrammar::TYPE_DIRECTIVE: |
29 | 30 | $this->directive = new Directive(new Context($token, $parser->getPath())); |
30 | 31 | $asm->push($this->directive); |
@@ -49,20 +50,23 @@ discard block |
||
49 | 50 | break; |
50 | 51 | |
51 | 52 | case DynamicGrammar::TYPE_KEYWORD: |
52 | - if ($this->directive !== null) { |
|
53 | + if ($this->directive !== null) |
|
54 | + { |
|
53 | 55 | $this->directive->name = $token->content; |
54 | 56 | } |
55 | 57 | break; |
56 | 58 | |
57 | 59 | case DynamicGrammar::TYPE_BODY: |
58 | - if ($this->directive !== null) { |
|
60 | + if ($this->directive !== null) |
|
61 | + { |
|
59 | 62 | $this->directive->body = $token->content; |
60 | 63 | $this->directive->values = $this->fetchValues($this->directive->body); |
61 | 64 | |
62 | 65 | $this->directive = null; |
63 | 66 | } |
64 | 67 | |
65 | - if ($this->output !== null) { |
|
68 | + if ($this->output !== null) |
|
69 | + { |
|
66 | 70 | $this->output->body = $token->content; |
67 | 71 | } |
68 | 72 | |
@@ -80,31 +84,38 @@ discard block |
||
80 | 84 | |
81 | 85 | $src = new StringStream($body); |
82 | 86 | |
83 | - while ($n = $src->peak()) { |
|
84 | - if (\in_array($n, ['"', "'"], true)) { |
|
87 | + while ($n = $src->peak()) |
|
88 | + { |
|
89 | + if (\in_array($n, ['"', "'"], true)) |
|
90 | + { |
|
85 | 91 | $values[\count($values) - 1] .= $n; |
86 | - while (($nn = $src->peak()) !== null) { |
|
92 | + while (($nn = $src->peak()) !== null) |
|
93 | + { |
|
87 | 94 | $values[\count($values) - 1] .= $nn; |
88 | - if ($nn === $n) { |
|
95 | + if ($nn === $n) |
|
96 | + { |
|
89 | 97 | break; |
90 | 98 | } |
91 | 99 | } |
92 | 100 | continue; |
93 | 101 | } |
94 | 102 | |
95 | - if ($n === ',' && $level === 0) { |
|
103 | + if ($n === ',' && $level === 0) |
|
104 | + { |
|
96 | 105 | $values[] = ''; |
97 | 106 | continue; |
98 | 107 | } |
99 | 108 | |
100 | 109 | $values[\count($values) - 1] .= $n; |
101 | 110 | |
102 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
111 | + if ($n === '(' || $n === '[' || $n === '{') |
|
112 | + { |
|
103 | 113 | $level++; |
104 | 114 | continue; |
105 | 115 | } |
106 | 116 | |
107 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
117 | + if ($n === ')' || $n === ']' || $n === '}') |
|
118 | + { |
|
108 | 119 | $level--; |
109 | 120 | } |
110 | 121 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
58 | 58 | { |
59 | - switch ($token->type) { |
|
59 | + switch ($token->type){ |
|
60 | 60 | case HTMLGrammar::TYPE_OPEN: |
61 | 61 | case HTMLGrammar::TYPE_OPEN_SHORT: |
62 | 62 | $this->node = new Tag(new Context($token, $parser->getPath())); |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | break; |
66 | 66 | |
67 | 67 | case HTMLGrammar::TYPE_KEYWORD: |
68 | - if ($this->node->name === null) { |
|
68 | + if ($this->node->name === null){ |
|
69 | 69 | $this->node->name = $this->parseToken($parser, $token); |
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
73 | + if ($this->attr !== null && !$this->attr->value instanceof Nil){ |
|
74 | 74 | $this->attr->value = $this->parseToken($parser, $token); |
75 | 75 | $this->attr = null; |
76 | 76 | break; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | break; |
87 | 87 | |
88 | 88 | case HTMLGrammar::TYPE_EQUAL: |
89 | - if ($this->attr === null) { |
|
89 | + if ($this->attr === null){ |
|
90 | 90 | throw new SyntaxException('unexpected attribute token', $token); |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | break; |
96 | 96 | |
97 | 97 | case HTMLGrammar::TYPE_ATTRIBUTE: |
98 | - if ($this->attr === null) { |
|
98 | + if ($this->attr === null){ |
|
99 | 99 | throw new SyntaxException('unexpected attribute token', $token); |
100 | 100 | } |
101 | 101 | |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | \str_starts_with($this->attr->name, 'on') |
106 | 106 | || \in_array($this->attr->name, self::VERBATIM_ATTRIBUTES, true) |
107 | 107 | ) |
108 | - ) { |
|
108 | + ){ |
|
109 | 109 | $this->attr->value = $this->parseVerbatim($parser, $token); |
110 | - } else { |
|
110 | + }else{ |
|
111 | 111 | $this->attr->value = $this->parseToken($parser, $token); |
112 | 112 | } |
113 | 113 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | break; |
122 | 122 | |
123 | 123 | case HTMLGrammar::TYPE_CLOSE: |
124 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
125 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
124 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT){ |
|
125 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name){ |
|
126 | 126 | /** |
127 | 127 | * TODO issue #767 |
128 | 128 | * @link https://github.com/spiral/framework/issues/767 |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | $asm->close(); |
138 | - } elseif (\in_array($this->node->name, self::VOID_TAGS)) { |
|
138 | + } elseif (\in_array($this->node->name, self::VOID_TAGS)){ |
|
139 | 139 | $this->node->void = true; |
140 | 140 | $asm->push($this->node); |
141 | - } else { |
|
141 | + }else{ |
|
142 | 142 | $asm->open($this->node, 'nodes'); |
143 | 143 | } |
144 | 144 | $this->flush(); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | break; |
151 | 151 | |
152 | 152 | default: |
153 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
153 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim){ |
|
154 | 154 | $node = $this->parseToken($parser, $token); |
155 | - if (\is_string($node)) { |
|
155 | + if (\is_string($node)){ |
|
156 | 156 | $node = new Raw($node, new Context($token, $parser->getPath())); |
157 | 157 | } |
158 | 158 | |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | { |
176 | 176 | $verbatim = new Verbatim(new Context($token, $parser->getPath())); |
177 | 177 | |
178 | - if ($token->tokens === []) { |
|
179 | - if ($token->content) { |
|
178 | + if ($token->tokens === []){ |
|
179 | + if ($token->content){ |
|
180 | 180 | $verbatim->nodes[] = $token->content; |
181 | 181 | } |
182 | - } else { |
|
182 | + }else{ |
|
183 | 183 | /** |
184 | 184 | * TODO issue #767 |
185 | 185 | * @link https://github.com/spiral/framework/issues/767 |
@@ -56,7 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
58 | 58 | { |
59 | - switch ($token->type) { |
|
59 | + switch ($token->type) |
|
60 | + { |
|
60 | 61 | case HTMLGrammar::TYPE_OPEN: |
61 | 62 | case HTMLGrammar::TYPE_OPEN_SHORT: |
62 | 63 | $this->node = new Tag(new Context($token, $parser->getPath())); |
@@ -65,12 +66,14 @@ discard block |
||
65 | 66 | break; |
66 | 67 | |
67 | 68 | case HTMLGrammar::TYPE_KEYWORD: |
68 | - if ($this->node->name === null) { |
|
69 | + if ($this->node->name === null) |
|
70 | + { |
|
69 | 71 | $this->node->name = $this->parseToken($parser, $token); |
70 | 72 | return; |
71 | 73 | } |
72 | 74 | |
73 | - if ($this->attr !== null && !$this->attr->value instanceof Nil) { |
|
75 | + if ($this->attr !== null && !$this->attr->value instanceof Nil) |
|
76 | + { |
|
74 | 77 | $this->attr->value = $this->parseToken($parser, $token); |
75 | 78 | $this->attr = null; |
76 | 79 | break; |
@@ -86,7 +89,8 @@ discard block |
||
86 | 89 | break; |
87 | 90 | |
88 | 91 | case HTMLGrammar::TYPE_EQUAL: |
89 | - if ($this->attr === null) { |
|
92 | + if ($this->attr === null) |
|
93 | + { |
|
90 | 94 | throw new SyntaxException('unexpected attribute token', $token); |
91 | 95 | } |
92 | 96 | |
@@ -95,7 +99,8 @@ discard block |
||
95 | 99 | break; |
96 | 100 | |
97 | 101 | case HTMLGrammar::TYPE_ATTRIBUTE: |
98 | - if ($this->attr === null) { |
|
102 | + if ($this->attr === null) |
|
103 | + { |
|
99 | 104 | throw new SyntaxException('unexpected attribute token', $token); |
100 | 105 | } |
101 | 106 | |
@@ -107,7 +112,9 @@ discard block |
||
107 | 112 | ) |
108 | 113 | ) { |
109 | 114 | $this->attr->value = $this->parseVerbatim($parser, $token); |
110 | - } else { |
|
115 | + } |
|
116 | + else |
|
117 | + { |
|
111 | 118 | $this->attr->value = $this->parseToken($parser, $token); |
112 | 119 | } |
113 | 120 | |
@@ -121,8 +128,10 @@ discard block |
||
121 | 128 | break; |
122 | 129 | |
123 | 130 | case HTMLGrammar::TYPE_CLOSE: |
124 | - if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) { |
|
125 | - if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) { |
|
131 | + if ($this->token->type == HTMLGrammar::TYPE_OPEN_SHORT) |
|
132 | + { |
|
133 | + if (!$asm->getNode() instanceof Tag || $asm->getNode()->name !== $this->node->name) |
|
134 | + { |
|
126 | 135 | /** |
127 | 136 | * TODO issue #767 |
128 | 137 | * @link https://github.com/spiral/framework/issues/767 |
@@ -135,10 +144,14 @@ discard block |
||
135 | 144 | } |
136 | 145 | |
137 | 146 | $asm->close(); |
138 | - } elseif (\in_array($this->node->name, self::VOID_TAGS)) { |
|
147 | + } |
|
148 | + elseif (\in_array($this->node->name, self::VOID_TAGS)) |
|
149 | + { |
|
139 | 150 | $this->node->void = true; |
140 | 151 | $asm->push($this->node); |
141 | - } else { |
|
152 | + } |
|
153 | + else |
|
154 | + { |
|
142 | 155 | $asm->open($this->node, 'nodes'); |
143 | 156 | } |
144 | 157 | $this->flush(); |
@@ -150,9 +163,11 @@ discard block |
||
150 | 163 | break; |
151 | 164 | |
152 | 165 | default: |
153 | - if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) { |
|
166 | + if ($asm->getNode() instanceof Mixin || $asm->getNode() instanceof Verbatim) |
|
167 | + { |
|
154 | 168 | $node = $this->parseToken($parser, $token); |
155 | - if (\is_string($node)) { |
|
169 | + if (\is_string($node)) |
|
170 | + { |
|
156 | 171 | $node = new Raw($node, new Context($token, $parser->getPath())); |
157 | 172 | } |
158 | 173 | |
@@ -175,11 +190,15 @@ discard block |
||
175 | 190 | { |
176 | 191 | $verbatim = new Verbatim(new Context($token, $parser->getPath())); |
177 | 192 | |
178 | - if ($token->tokens === []) { |
|
179 | - if ($token->content) { |
|
193 | + if ($token->tokens === []) |
|
194 | + { |
|
195 | + if ($token->content) |
|
196 | + { |
|
180 | 197 | $verbatim->nodes[] = $token->content; |
181 | 198 | } |
182 | - } else { |
|
199 | + } |
|
200 | + else |
|
201 | + { |
|
183 | 202 | /** |
184 | 203 | * TODO issue #767 |
185 | 204 | * @link https://github.com/spiral/framework/issues/767 |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
23 | 23 | { |
24 | - switch ($token->type) { |
|
24 | + switch ($token->type){ |
|
25 | 25 | case InlineGrammar::TYPE_OPEN_TAG: |
26 | 26 | $this->inline = new Inline(new Context($token, $parser->getPath())); |
27 | 27 | $asm->push($this->inline); |
@@ -21,7 +21,8 @@ |
||
21 | 21 | |
22 | 22 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
23 | 23 | { |
24 | - switch ($token->type) { |
|
24 | + switch ($token->type) |
|
25 | + { |
|
25 | 26 | case InlineGrammar::TYPE_OPEN_TAG: |
26 | 27 | $this->inline = new Inline(new Context($token, $parser->getPath())); |
27 | 28 | $asm->push($this->inline); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | public function render(Compiler $compiler, Result $result, NodeInterface $node): bool |
16 | 16 | { |
17 | - if ($node instanceof PHP) { |
|
17 | + if ($node instanceof PHP){ |
|
18 | 18 | $result->push($node->content, $node->getContext()); |
19 | 19 | return true; |
20 | 20 | } |
@@ -14,7 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | public function render(Compiler $compiler, Result $result, NodeInterface $node): bool |
16 | 16 | { |
17 | - if ($node instanceof PHP) { |
|
17 | + if ($node instanceof PHP) |
|
18 | + { |
|
18 | 19 | $result->push($node->content, $node->getContext()); |
19 | 20 | return true; |
20 | 21 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function render(Compiler $compiler, Result $result, NodeInterface $node): bool |
19 | 19 | { |
20 | - switch (true) { |
|
20 | + switch (true){ |
|
21 | 21 | case $node instanceof Tag: |
22 | 22 | $this->tag($compiler, $result, $node); |
23 | 23 | return true; |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | { |
37 | 37 | $result->push(\sprintf('<%s', $node->name), $node->getContext()); |
38 | 38 | |
39 | - foreach ($node->attrs as $attr) { |
|
40 | - if (!$attr instanceof Attr) { |
|
39 | + foreach ($node->attrs as $attr){ |
|
40 | + if (!$attr instanceof Attr){ |
|
41 | 41 | $compiler->compile($attr, $result); |
42 | 42 | continue; |
43 | 43 | } |
@@ -47,30 +47,30 @@ discard block |
||
47 | 47 | |
48 | 48 | $result->push(\sprintf('%s>', $node->void ? '/' : ''), null); |
49 | 49 | |
50 | - foreach ($node->nodes as $child) { |
|
50 | + foreach ($node->nodes as $child){ |
|
51 | 51 | $compiler->compile($child, $result); |
52 | 52 | } |
53 | 53 | |
54 | - if (!$node->void) { |
|
54 | + if (!$node->void){ |
|
55 | 55 | $result->push(\sprintf('</%s>', $node->name), null); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | private function attribute(Compiler $compiler, Result $result, Attr $node): void |
60 | 60 | { |
61 | - if ($node->name instanceof NodeInterface) { |
|
61 | + if ($node->name instanceof NodeInterface){ |
|
62 | 62 | $result->push(' ', null); |
63 | 63 | $compiler->compile($node->name, $result); |
64 | - } else { |
|
64 | + }else{ |
|
65 | 65 | $result->push(\sprintf(' %s', $node->name), $node->getContext()); |
66 | 66 | } |
67 | 67 | |
68 | 68 | $value = $node->value; |
69 | - if ($value instanceof Nil) { |
|
69 | + if ($value instanceof Nil){ |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | - if ($value instanceof NodeInterface) { |
|
73 | + if ($value instanceof NodeInterface){ |
|
74 | 74 | $result->push('=', null); |
75 | 75 | $compiler->compile($value, $result); |
76 | 76 | return; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | |
82 | 82 | private function verbatim(Compiler $compiler, Result $result, Verbatim $node): void |
83 | 83 | { |
84 | - foreach ($node->nodes as $child) { |
|
85 | - if (\is_string($child)) { |
|
84 | + foreach ($node->nodes as $child){ |
|
85 | + if (\is_string($child)){ |
|
86 | 86 | $result->push($child, null); |
87 | 87 | continue; |
88 | 88 | } |
@@ -17,7 +17,8 @@ discard block |
||
17 | 17 | { |
18 | 18 | public function render(Compiler $compiler, Result $result, NodeInterface $node): bool |
19 | 19 | { |
20 | - switch (true) { |
|
20 | + switch (true) |
|
21 | + { |
|
21 | 22 | case $node instanceof Tag: |
22 | 23 | $this->tag($compiler, $result, $node); |
23 | 24 | return true; |
@@ -36,8 +37,10 @@ discard block |
||
36 | 37 | { |
37 | 38 | $result->push(\sprintf('<%s', $node->name), $node->getContext()); |
38 | 39 | |
39 | - foreach ($node->attrs as $attr) { |
|
40 | - if (!$attr instanceof Attr) { |
|
40 | + foreach ($node->attrs as $attr) |
|
41 | + { |
|
42 | + if (!$attr instanceof Attr) |
|
43 | + { |
|
41 | 44 | $compiler->compile($attr, $result); |
42 | 45 | continue; |
43 | 46 | } |
@@ -47,30 +50,37 @@ discard block |
||
47 | 50 | |
48 | 51 | $result->push(\sprintf('%s>', $node->void ? '/' : ''), null); |
49 | 52 | |
50 | - foreach ($node->nodes as $child) { |
|
53 | + foreach ($node->nodes as $child) |
|
54 | + { |
|
51 | 55 | $compiler->compile($child, $result); |
52 | 56 | } |
53 | 57 | |
54 | - if (!$node->void) { |
|
58 | + if (!$node->void) |
|
59 | + { |
|
55 | 60 | $result->push(\sprintf('</%s>', $node->name), null); |
56 | 61 | } |
57 | 62 | } |
58 | 63 | |
59 | 64 | private function attribute(Compiler $compiler, Result $result, Attr $node): void |
60 | 65 | { |
61 | - if ($node->name instanceof NodeInterface) { |
|
66 | + if ($node->name instanceof NodeInterface) |
|
67 | + { |
|
62 | 68 | $result->push(' ', null); |
63 | 69 | $compiler->compile($node->name, $result); |
64 | - } else { |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
65 | 73 | $result->push(\sprintf(' %s', $node->name), $node->getContext()); |
66 | 74 | } |
67 | 75 | |
68 | 76 | $value = $node->value; |
69 | - if ($value instanceof Nil) { |
|
77 | + if ($value instanceof Nil) |
|
78 | + { |
|
70 | 79 | return; |
71 | 80 | } |
72 | 81 | |
73 | - if ($value instanceof NodeInterface) { |
|
82 | + if ($value instanceof NodeInterface) |
|
83 | + { |
|
74 | 84 | $result->push('=', null); |
75 | 85 | $compiler->compile($value, $result); |
76 | 86 | return; |
@@ -81,8 +91,10 @@ discard block |
||
81 | 91 | |
82 | 92 | private function verbatim(Compiler $compiler, Result $result, Verbatim $node): void |
83 | 93 | { |
84 | - foreach ($node->nodes as $child) { |
|
85 | - if (\is_string($child)) { |
|
94 | + foreach ($node->nodes as $child) |
|
95 | + { |
|
96 | + if (\is_string($child)) |
|
97 | + { |
|
86 | 98 | $result->push($child, null); |
87 | 99 | continue; |
88 | 100 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | Result $result, |
23 | 23 | NodeInterface $node |
24 | 24 | ): bool { |
25 | - switch (true) { |
|
25 | + switch (true){ |
|
26 | 26 | case $node instanceof Hidden: |
27 | 27 | return true; |
28 | 28 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | $result->withinContext( |
31 | 31 | $node->getContext(), |
32 | 32 | function (Result $source) use ($node, $compiler): void { |
33 | - foreach ($node->nodes as $child) { |
|
33 | + foreach ($node->nodes as $child){ |
|
34 | 34 | $compiler->compile($child, $source); |
35 | 35 | } |
36 | 36 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $result->withinContext( |
43 | 43 | $node->getContext(), |
44 | 44 | function (Result $source) use ($node, $compiler): void { |
45 | - foreach ($node->nodes as $child) { |
|
46 | - if (\is_string($child)) { |
|
45 | + foreach ($node->nodes as $child){ |
|
46 | + if (\is_string($child)){ |
|
47 | 47 | $source->push($child, null); |
48 | 48 | continue; |
49 | 49 | } |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | Result $result, |
23 | 23 | NodeInterface $node |
24 | 24 | ): bool { |
25 | - switch (true) { |
|
25 | + switch (true) |
|
26 | + { |
|
26 | 27 | case $node instanceof Hidden: |
27 | 28 | return true; |
28 | 29 | |
@@ -30,7 +31,8 @@ discard block |
||
30 | 31 | $result->withinContext( |
31 | 32 | $node->getContext(), |
32 | 33 | function (Result $source) use ($node, $compiler): void { |
33 | - foreach ($node->nodes as $child) { |
|
34 | + foreach ($node->nodes as $child) |
|
35 | + { |
|
34 | 36 | $compiler->compile($child, $source); |
35 | 37 | } |
36 | 38 | } |
@@ -42,8 +44,10 @@ discard block |
||
42 | 44 | $result->withinContext( |
43 | 45 | $node->getContext(), |
44 | 46 | function (Result $source) use ($node, $compiler): void { |
45 | - foreach ($node->nodes as $child) { |
|
46 | - if (\is_string($child)) { |
|
47 | + foreach ($node->nodes as $child) |
|
48 | + { |
|
49 | + if (\is_string($child)) |
|
50 | + { |
|
47 | 51 | $source->push($child, null); |
48 | 52 | continue; |
49 | 53 | } |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | public function __construct( |
22 | 22 | private readonly ?DirectiveRendererInterface $directiveRenderer = null, |
23 | 23 | private readonly string $defaultFilter = self::DEFAULT_FILTER |
24 | - ) { |
|
24 | + ){ |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function render(Compiler $compiler, Result $result, NodeInterface $node): bool |
28 | 28 | { |
29 | - switch (true) { |
|
29 | + switch (true){ |
|
30 | 30 | case $node instanceof Output: |
31 | 31 | $this->output($result, $node); |
32 | 32 | return true; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | private function directive(Result $source, Directive $directive): void |
45 | 45 | { |
46 | - if ($this->directiveRenderer !== null) { |
|
46 | + if ($this->directiveRenderer !== null){ |
|
47 | 47 | $result = $this->directiveRenderer->render($directive); |
48 | - if ($result !== null) { |
|
48 | + if ($result !== null){ |
|
49 | 49 | $source->push($result, $directive->getContext()); |
50 | 50 | return; |
51 | 51 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | private function output(Result $source, Output $output): void |
61 | 61 | { |
62 | - if ($output->rawOutput) { |
|
62 | + if ($output->rawOutput){ |
|
63 | 63 | $source->push(\sprintf('<?php echo %s; ?>', \trim($output->body)), $output->getContext()); |
64 | 64 | return; |
65 | 65 | } |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | public function render(Compiler $compiler, Result $result, NodeInterface $node): bool |
28 | 28 | { |
29 | - switch (true) { |
|
29 | + switch (true) |
|
30 | + { |
|
30 | 31 | case $node instanceof Output: |
31 | 32 | $this->output($result, $node); |
32 | 33 | return true; |
@@ -43,9 +44,11 @@ discard block |
||
43 | 44 | */ |
44 | 45 | private function directive(Result $source, Directive $directive): void |
45 | 46 | { |
46 | - if ($this->directiveRenderer !== null) { |
|
47 | + if ($this->directiveRenderer !== null) |
|
48 | + { |
|
47 | 49 | $result = $this->directiveRenderer->render($directive); |
48 | - if ($result !== null) { |
|
50 | + if ($result !== null) |
|
51 | + { |
|
49 | 52 | $source->push($result, $directive->getContext()); |
50 | 53 | return; |
51 | 54 | } |
@@ -59,7 +62,8 @@ discard block |
||
59 | 62 | |
60 | 63 | private function output(Result $source, Output $output): void |
61 | 64 | { |
62 | - if ($output->rawOutput) { |
|
65 | + if ($output->rawOutput) |
|
66 | + { |
|
63 | 67 | $source->push(\sprintf('<?php echo %s; ?>', \trim($output->body)), $output->getContext()); |
64 | 68 | return; |
65 | 69 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | private readonly ConfiguratorInterface $config, |
35 | 35 | private readonly ContainerInterface $container, |
36 | 36 | private readonly FactoryInterface $factory |
37 | - ) { |
|
37 | + ){ |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function init(EnvironmentInterface $env): void |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'json' => new JsonSerializer(), |
61 | 61 | 'serializer' => new PhpSerializer(), |
62 | 62 | ]; |
63 | - if (\class_exists(Message::class)) { |
|
63 | + if (\class_exists(Message::class)){ |
|
64 | 64 | $serializers['proto'] = new ProtoSerializer(); |
65 | 65 | } |
66 | 66 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @throws ContainerExceptionInterface |
75 | 75 | * @throws NotFoundExceptionInterface |
76 | 76 | */ |
77 | - private function wire(string|Autowire|SerializerInterface $serializer): SerializerInterface |
|
77 | + private function wire(string | Autowire | SerializerInterface $serializer): SerializerInterface |
|
78 | 78 | { |
79 | 79 | return match (true) { |
80 | 80 | $serializer instanceof SerializerInterface => $serializer, |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function __construct( |
50 | 50 | private readonly ConfiguratorInterface $configs |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function init(): void |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | FinalizerInterface $finalizer, |
73 | 73 | ?EventDispatcherInterface $eventDispatcher = null |
74 | 74 | ): void { |
75 | - if ($eventDispatcher !== null) { |
|
75 | + if ($eventDispatcher !== null){ |
|
76 | 76 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
77 | 77 | } |
78 | 78 | |
79 | - foreach ($config->getProcessors() as $processor) { |
|
79 | + foreach ($config->getProcessors() as $processor){ |
|
80 | 80 | $processor = $this->autowire($processor, $container, $factory); |
81 | 81 | |
82 | 82 | \assert($processor instanceof ProcessorInterface); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $registry->process(); |
88 | 88 | }); |
89 | 89 | |
90 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
90 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null){ |
|
91 | 91 | $finalizer->setEventDispatcher($eventDispatcher); |
92 | 92 | } |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param TInterceptor $interceptor |
97 | 97 | */ |
98 | 98 | public function addInterceptor( |
99 | - string|InterceptorInterface|CoreInterceptorInterface|Autowire $interceptor, |
|
99 | + string | InterceptorInterface | CoreInterceptorInterface | Autowire $interceptor, |
|
100 | 100 | ): void { |
101 | 101 | $this->configs->modify(EventsConfig::CONFIG, new Append('interceptors', null, $interceptor)); |
102 | 102 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | ): void { |
110 | 110 | $builder = new CompatiblePipelineBuilder(); |
111 | 111 | $list = []; |
112 | - foreach ($config->getInterceptors() as $interceptor) { |
|
112 | + foreach ($config->getInterceptors() as $interceptor){ |
|
113 | 113 | $list[] = $this->autowire($interceptor, $container, $factory); |
114 | 114 | } |
115 | 115 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @throws ContainerExceptionInterface |
129 | 129 | */ |
130 | - private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
130 | + private function autowire(string | object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
131 | 131 | { |
132 | 132 | return match (true) { |
133 | 133 | \is_string($id) => $container->get($id), |