@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | |
23 | 23 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
24 | 24 | { |
25 | - if ($node instanceof Tag) { |
|
25 | + if ($node instanceof Tag){ |
|
26 | 26 | return $this->makeBlock($node); |
27 | 27 | } |
28 | 28 | |
29 | - if ($node instanceof Inline) { |
|
29 | + if ($node instanceof Inline){ |
|
30 | 30 | $block = new Block($node->name, $node->getContext()); |
31 | - if ($node->value !== null) { |
|
31 | + if ($node->value !== null){ |
|
32 | 32 | $block->nodes[] = new Raw($node->value); |
33 | 33 | } |
34 | 34 | |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | private function makeBlock(Tag $node): ?NodeInterface |
50 | 50 | { |
51 | 51 | $name = null; |
52 | - foreach ($this->prefix as $prefix) { |
|
53 | - if (\str_starts_with($node->name, (string) $prefix)) { |
|
54 | - $name = \substr($node->name, \strlen((string) $prefix)); |
|
52 | + foreach ($this->prefix as $prefix){ |
|
53 | + if (\str_starts_with($node->name, (string)$prefix)){ |
|
54 | + $name = \substr($node->name, \strlen((string)$prefix)); |
|
55 | 55 | break; |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - if ($name === null) { |
|
59 | + if ($name === null){ |
|
60 | 60 | return null; |
61 | 61 | } |
62 | 62 |
@@ -22,13 +22,16 @@ discard block |
||
22 | 22 | |
23 | 23 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
24 | 24 | { |
25 | - if ($node instanceof Tag) { |
|
25 | + if ($node instanceof Tag) |
|
26 | + { |
|
26 | 27 | return $this->makeBlock($node); |
27 | 28 | } |
28 | 29 | |
29 | - if ($node instanceof Inline) { |
|
30 | + if ($node instanceof Inline) |
|
31 | + { |
|
30 | 32 | $block = new Block($node->name, $node->getContext()); |
31 | - if ($node->value !== null) { |
|
33 | + if ($node->value !== null) |
|
34 | + { |
|
32 | 35 | $block->nodes[] = new Raw($node->value); |
33 | 36 | } |
34 | 37 | |
@@ -49,14 +52,17 @@ discard block |
||
49 | 52 | private function makeBlock(Tag $node): ?NodeInterface |
50 | 53 | { |
51 | 54 | $name = null; |
52 | - foreach ($this->prefix as $prefix) { |
|
53 | - if (\str_starts_with($node->name, (string) $prefix)) { |
|
55 | + foreach ($this->prefix as $prefix) |
|
56 | + { |
|
57 | + if (\str_starts_with($node->name, (string) $prefix)) |
|
58 | + { |
|
54 | 59 | $name = \substr($node->name, \strlen((string) $prefix)); |
55 | 60 | break; |
56 | 61 | } |
57 | 62 | } |
58 | 63 | |
59 | - if ($name === null) { |
|
64 | + if ($name === null) |
|
65 | + { |
|
60 | 66 | return null; |
61 | 67 | } |
62 | 68 |
@@ -22,8 +22,10 @@ discard block |
||
22 | 22 | { |
23 | 23 | $replace = []; |
24 | 24 | |
25 | - foreach ($this->blocks as $block) { |
|
26 | - for ($i = $block['start']; $i <= $block['end']; $i++) { |
|
25 | + foreach ($this->blocks as $block) |
|
26 | + { |
|
27 | + for ($i = $block['start']; $i <= $block['end']; $i++) |
|
28 | + { |
|
27 | 29 | $replace[$i] = ''; |
28 | 30 | } |
29 | 31 | |
@@ -31,13 +33,16 @@ discard block |
||
31 | 33 | } |
32 | 34 | |
33 | 35 | $result = ''; |
34 | - foreach ($this->tokens as $position => $token) { |
|
35 | - if (\array_key_exists($position, $replace)) { |
|
36 | + foreach ($this->tokens as $position => $token) |
|
37 | + { |
|
38 | + if (\array_key_exists($position, $replace)) |
|
39 | + { |
|
36 | 40 | $result .= $replace[$position]; |
37 | 41 | continue; |
38 | 42 | } |
39 | 43 | |
40 | - if (\is_string($token)) { |
|
44 | + if (\is_string($token)) |
|
45 | + { |
|
41 | 46 | $result .= $token; |
42 | 47 | continue; |
43 | 48 | } |
@@ -55,8 +60,10 @@ discard block |
||
55 | 60 | { |
56 | 61 | $replace = []; |
57 | 62 | |
58 | - foreach ($this->blocks as $block) { |
|
59 | - for ($i = $block['start']; $i <= $block['end']; ++$i) { |
|
63 | + foreach ($this->blocks as $block) |
|
64 | + { |
|
65 | + for ($i = $block['start']; $i <= $block['end']; ++$i) |
|
66 | + { |
|
60 | 67 | $replace[$i] = ''; |
61 | 68 | } |
62 | 69 | |
@@ -64,18 +71,22 @@ discard block |
||
64 | 71 | } |
65 | 72 | |
66 | 73 | $result = ''; |
67 | - foreach ($this->tokens as $position => $token) { |
|
68 | - if (\array_key_exists($position, $replace)) { |
|
74 | + foreach ($this->tokens as $position => $token) |
|
75 | + { |
|
76 | + if (\array_key_exists($position, $replace)) |
|
77 | + { |
|
69 | 78 | $result .= $replace[$position]; |
70 | 79 | continue; |
71 | 80 | } |
72 | 81 | |
73 | - if (\is_string($token)) { |
|
82 | + if (\is_string($token)) |
|
83 | + { |
|
74 | 84 | $result .= $token; |
75 | 85 | continue; |
76 | 86 | } |
77 | 87 | |
78 | - if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) { |
|
88 | + if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) |
|
89 | + { |
|
79 | 90 | continue; |
80 | 91 | } |
81 | 92 | |
@@ -91,7 +102,8 @@ discard block |
||
91 | 102 | public function getBlocks(): array |
92 | 103 | { |
93 | 104 | $result = []; |
94 | - foreach ($this->blocks as $name => $macro) { |
|
105 | + foreach ($this->blocks as $name => $macro) |
|
106 | + { |
|
95 | 107 | $result[$name] = $macro['value']; |
96 | 108 | } |
97 | 109 | |
@@ -105,7 +117,8 @@ discard block |
||
105 | 117 | |
106 | 118 | public function set(string $block, string $value): void |
107 | 119 | { |
108 | - if (!isset($this->blocks[$block])) { |
|
120 | + if (!isset($this->blocks[$block])) |
|
121 | + { |
|
109 | 122 | return; |
110 | 123 | } |
111 | 124 | |
@@ -116,26 +129,32 @@ discard block |
||
116 | 129 | { |
117 | 130 | $level = 0; |
118 | 131 | $start = $name = $value = null; |
119 | - foreach ($this->tokens as $position => $token) { |
|
120 | - if (!\is_array($token)) { |
|
132 | + foreach ($this->tokens as $position => $token) |
|
133 | + { |
|
134 | + if (!\is_array($token)) |
|
135 | + { |
|
121 | 136 | $token = [$token, $token, 0]; |
122 | 137 | } |
123 | 138 | |
124 | - switch ($token[0]) { |
|
139 | + switch ($token[0]) |
|
140 | + { |
|
125 | 141 | case '(': |
126 | - if ($start !== null) { |
|
142 | + if ($start !== null) |
|
143 | + { |
|
127 | 144 | $level++; |
128 | 145 | $value .= $token[1]; |
129 | 146 | } |
130 | 147 | break; |
131 | 148 | case ')': |
132 | - if ($start === null) { |
|
149 | + if ($start === null) |
|
150 | + { |
|
133 | 151 | break; |
134 | 152 | } |
135 | 153 | |
136 | 154 | $level--; |
137 | 155 | $value .= $token[1]; |
138 | - if ($level === 0) { |
|
156 | + if ($level === 0) |
|
157 | + { |
|
139 | 158 | $this->blocks[$name] = [ |
140 | 159 | 'start' => $start, |
141 | 160 | 'value' => trim($value), |
@@ -147,22 +166,26 @@ discard block |
||
147 | 166 | } |
148 | 167 | break; |
149 | 168 | case T_STRING: |
150 | - if ($token[1] === $func) { |
|
169 | + if ($token[1] === $func) |
|
170 | + { |
|
151 | 171 | $start = $position; |
152 | 172 | $value = $token[1]; |
153 | 173 | break; |
154 | 174 | } |
155 | 175 | |
156 | - if ($start !== null) { |
|
176 | + if ($start !== null) |
|
177 | + { |
|
157 | 178 | $value .= $token[1]; |
158 | 179 | } |
159 | 180 | break; |
160 | 181 | case T_CONSTANT_ENCAPSED_STRING: |
161 | - if ($start === null) { |
|
182 | + if ($start === null) |
|
183 | + { |
|
162 | 184 | break; |
163 | 185 | } |
164 | 186 | |
165 | - if ($name === null) { |
|
187 | + if ($name === null) |
|
188 | + { |
|
166 | 189 | $name = \stripcslashes(\substr((string) $token[1], 1, -1)); |
167 | 190 | } |
168 | 191 | $value .= $token[1]; |
@@ -171,7 +194,8 @@ discard block |
||
171 | 194 | $value .= $token[1]; |
172 | 195 | break; |
173 | 196 | default: |
174 | - if ($start !== null) { |
|
197 | + if ($start !== null) |
|
198 | + { |
|
175 | 199 | $value .= $token[1]; |
176 | 200 | } |
177 | 201 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct( |
15 | 15 | private readonly array $tokens, |
16 | 16 | string $func, |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | $this->parse($func); |
19 | 19 | } |
20 | 20 | |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | { |
23 | 23 | $replace = []; |
24 | 24 | |
25 | - foreach ($this->blocks as $block) { |
|
26 | - for ($i = $block['start']; $i <= $block['end']; $i++) { |
|
25 | + foreach ($this->blocks as $block){ |
|
26 | + for ($i = $block['start']; $i <= $block['end']; $i++){ |
|
27 | 27 | $replace[$i] = ''; |
28 | 28 | } |
29 | 29 | |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | $result = ''; |
34 | - foreach ($this->tokens as $position => $token) { |
|
35 | - if (\array_key_exists($position, $replace)) { |
|
34 | + foreach ($this->tokens as $position => $token){ |
|
35 | + if (\array_key_exists($position, $replace)){ |
|
36 | 36 | $result .= $replace[$position]; |
37 | 37 | continue; |
38 | 38 | } |
39 | 39 | |
40 | - if (\is_string($token)) { |
|
40 | + if (\is_string($token)){ |
|
41 | 41 | $result .= $token; |
42 | 42 | continue; |
43 | 43 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | { |
56 | 56 | $replace = []; |
57 | 57 | |
58 | - foreach ($this->blocks as $block) { |
|
59 | - for ($i = $block['start']; $i <= $block['end']; ++$i) { |
|
58 | + foreach ($this->blocks as $block){ |
|
59 | + for ($i = $block['start']; $i <= $block['end']; ++$i){ |
|
60 | 60 | $replace[$i] = ''; |
61 | 61 | } |
62 | 62 | |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | $result = ''; |
67 | - foreach ($this->tokens as $position => $token) { |
|
68 | - if (\array_key_exists($position, $replace)) { |
|
67 | + foreach ($this->tokens as $position => $token){ |
|
68 | + if (\array_key_exists($position, $replace)){ |
|
69 | 69 | $result .= $replace[$position]; |
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | |
73 | - if (\is_string($token)) { |
|
73 | + if (\is_string($token)){ |
|
74 | 74 | $result .= $token; |
75 | 75 | continue; |
76 | 76 | } |
77 | 77 | |
78 | - if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])) { |
|
78 | + if (\in_array($token[0], [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG, T_ECHO])){ |
|
79 | 79 | continue; |
80 | 80 | } |
81 | 81 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function getBlocks(): array |
92 | 92 | { |
93 | 93 | $result = []; |
94 | - foreach ($this->blocks as $name => $macro) { |
|
94 | + foreach ($this->blocks as $name => $macro){ |
|
95 | 95 | $result[$name] = $macro['value']; |
96 | 96 | } |
97 | 97 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | public function set(string $block, string $value): void |
107 | 107 | { |
108 | - if (!isset($this->blocks[$block])) { |
|
108 | + if (!isset($this->blocks[$block])){ |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | { |
117 | 117 | $level = 0; |
118 | 118 | $start = $name = $value = null; |
119 | - foreach ($this->tokens as $position => $token) { |
|
120 | - if (!\is_array($token)) { |
|
119 | + foreach ($this->tokens as $position => $token){ |
|
120 | + if (!\is_array($token)){ |
|
121 | 121 | $token = [$token, $token, 0]; |
122 | 122 | } |
123 | 123 | |
124 | - switch ($token[0]) { |
|
124 | + switch ($token[0]){ |
|
125 | 125 | case '(': |
126 | - if ($start !== null) { |
|
126 | + if ($start !== null){ |
|
127 | 127 | $level++; |
128 | 128 | $value .= $token[1]; |
129 | 129 | } |
130 | 130 | break; |
131 | 131 | case ')': |
132 | - if ($start === null) { |
|
132 | + if ($start === null){ |
|
133 | 133 | break; |
134 | 134 | } |
135 | 135 | |
136 | 136 | $level--; |
137 | 137 | $value .= $token[1]; |
138 | - if ($level === 0) { |
|
138 | + if ($level === 0){ |
|
139 | 139 | $this->blocks[$name] = [ |
140 | 140 | 'start' => $start, |
141 | 141 | 'value' => trim($value), |
@@ -147,23 +147,23 @@ discard block |
||
147 | 147 | } |
148 | 148 | break; |
149 | 149 | case T_STRING: |
150 | - if ($token[1] === $func) { |
|
150 | + if ($token[1] === $func){ |
|
151 | 151 | $start = $position; |
152 | 152 | $value = $token[1]; |
153 | 153 | break; |
154 | 154 | } |
155 | 155 | |
156 | - if ($start !== null) { |
|
156 | + if ($start !== null){ |
|
157 | 157 | $value .= $token[1]; |
158 | 158 | } |
159 | 159 | break; |
160 | 160 | case T_CONSTANT_ENCAPSED_STRING: |
161 | - if ($start === null) { |
|
161 | + if ($start === null){ |
|
162 | 162 | break; |
163 | 163 | } |
164 | 164 | |
165 | - if ($name === null) { |
|
166 | - $name = \stripcslashes(\substr((string) $token[1], 1, -1)); |
|
165 | + if ($name === null){ |
|
166 | + $name = \stripcslashes(\substr((string)$token[1], 1, -1)); |
|
167 | 167 | } |
168 | 168 | $value .= $token[1]; |
169 | 169 | break; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $value .= $token[1]; |
172 | 172 | break; |
173 | 173 | default: |
174 | - if ($start !== null) { |
|
174 | + if ($start !== null){ |
|
175 | 175 | $value .= $token[1]; |
176 | 176 | } |
177 | 177 | } |
@@ -67,13 +67,16 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function parse(Buffer $src): \Generator |
69 | 69 | { |
70 | - while ($n = $src->next()) { |
|
71 | - if (!$n instanceof Byte) { |
|
70 | + while ($n = $src->next()) |
|
71 | + { |
|
72 | + if (!$n instanceof Byte) |
|
73 | + { |
|
72 | 74 | yield $n; |
73 | 75 | continue; |
74 | 76 | } |
75 | 77 | |
76 | - if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR) { |
|
78 | + if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR) |
|
79 | + { |
|
77 | 80 | if ( |
78 | 81 | $this->echo->nextToken($src) || |
79 | 82 | $this->raw->nextToken($src) || |
@@ -85,11 +88,15 @@ discard block |
||
85 | 88 | } |
86 | 89 | |
87 | 90 | $directive = new DirectiveGrammar(); |
88 | - if ($directive->parse($src, $n->offset)) { |
|
89 | - if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE) { |
|
91 | + if ($directive->parse($src, $n->offset)) |
|
92 | + { |
|
93 | + if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE) |
|
94 | + { |
|
90 | 95 | // configure braces syntax |
91 | 96 | $this->declare($directive->getBody()); |
92 | - } else { |
|
97 | + } |
|
98 | + else |
|
99 | + { |
|
93 | 100 | if ( |
94 | 101 | $this->directiveRenderer !== null |
95 | 102 | && !$this->directiveRenderer->hasDirective($directive->getKeyword()) |
@@ -114,15 +121,20 @@ discard block |
||
114 | 121 | |
115 | 122 | /** @var BracesGrammar|null $braces */ |
116 | 123 | $braces = null; |
117 | - if ($this->echo->starts($src, $n)) { |
|
124 | + if ($this->echo->starts($src, $n)) |
|
125 | + { |
|
118 | 126 | $braces = clone $this->echo; |
119 | - } elseif ($this->raw->starts($src, $n)) { |
|
127 | + } |
|
128 | + elseif ($this->raw->starts($src, $n)) |
|
129 | + { |
|
120 | 130 | $braces = clone $this->raw; |
121 | 131 | } |
122 | 132 | |
123 | - if ($braces !== null) { |
|
133 | + if ($braces !== null) |
|
134 | + { |
|
124 | 135 | $echo = $braces->parse($src, $n); |
125 | - if ($echo !== null) { |
|
136 | + if ($echo !== null) |
|
137 | + { |
|
126 | 138 | yield from $echo; |
127 | 139 | continue; |
128 | 140 | } |
@@ -156,18 +168,22 @@ discard block |
||
156 | 168 | |
157 | 169 | private function declare(?string $body): void |
158 | 170 | { |
159 | - if ($body === null) { |
|
171 | + if ($body === null) |
|
172 | + { |
|
160 | 173 | return; |
161 | 174 | } |
162 | 175 | |
163 | - foreach ($this->fetchOptions($body) as $option => $value) { |
|
176 | + foreach ($this->fetchOptions($body) as $option => $value) |
|
177 | + { |
|
164 | 178 | $value = \trim((string) $value, '\'" '); |
165 | - switch ($option) { |
|
179 | + switch ($option) |
|
180 | + { |
|
166 | 181 | case 'syntax': |
167 | 182 | $this->echo->setActive($value !== 'off'); |
168 | 183 | $this->raw->setActive($value !== 'off'); |
169 | 184 | |
170 | - if ($value === 'default') { |
|
185 | + if ($value === 'default') |
|
186 | + { |
|
171 | 187 | $this->echo->setStartSequence('{{'); |
172 | 188 | $this->echo->setEndSequence('}}'); |
173 | 189 | $this->raw->setStartSequence('{!!'); |
@@ -204,10 +220,13 @@ discard block |
||
204 | 220 | $keyword = null; |
205 | 221 | |
206 | 222 | /** @var Token $token */ |
207 | - foreach ($lexer->parse(new StringStream($body)) as $token) { |
|
208 | - switch ($token->type) { |
|
223 | + foreach ($lexer->parse(new StringStream($body)) as $token) |
|
224 | + { |
|
225 | + switch ($token->type) |
|
226 | + { |
|
209 | 227 | case DeclareGrammar::TYPE_KEYWORD: |
210 | - if ($keyword !== null) { |
|
228 | + if ($keyword !== null) |
|
229 | + { |
|
211 | 230 | $options[$keyword] = $token->content; |
212 | 231 | $keyword = null; |
213 | 232 | break; |
@@ -215,7 +234,8 @@ discard block |
||
215 | 234 | $keyword = $token->content; |
216 | 235 | break; |
217 | 236 | case DeclareGrammar::TYPE_QUOTED: |
218 | - if ($keyword !== null) { |
|
237 | + if ($keyword !== null) |
|
238 | + { |
|
219 | 239 | $options[$keyword] = \trim($token->content, $token->content[0]); |
220 | 240 | $keyword = null; |
221 | 241 | break; |
@@ -224,7 +244,8 @@ discard block |
||
224 | 244 | $keyword = \trim($token->content, $token->content[0]); |
225 | 245 | break; |
226 | 246 | case DeclareGrammar::TYPE_COMMA: |
227 | - if ($keyword !== null) { |
|
247 | + if ($keyword !== null) |
|
248 | + { |
|
228 | 249 | $options[$keyword] = null; |
229 | 250 | $keyword = null; |
230 | 251 | break; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | public function __construct( |
48 | 48 | private readonly ?DirectiveRendererInterface $directiveRenderer = null, |
49 | - ) { |
|
49 | + ){ |
|
50 | 50 | $this->echo = new BracesGrammar( |
51 | 51 | '{{', |
52 | 52 | '}}', |
@@ -85,33 +85,33 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function parse(Buffer $src): \Generator |
87 | 87 | { |
88 | - while ($n = $src->next()) { |
|
89 | - if (!$n instanceof Byte) { |
|
88 | + while ($n = $src->next()){ |
|
89 | + if (!$n instanceof Byte){ |
|
90 | 90 | yield $n; |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | - if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR) { |
|
94 | + if ($n->char === DirectiveGrammar::DIRECTIVE_CHAR){ |
|
95 | 95 | if ( |
96 | 96 | $this->echo->nextToken($src) || |
97 | 97 | $this->raw->nextToken($src) || |
98 | 98 | $src->lookaheadByte() === DirectiveGrammar::DIRECTIVE_CHAR |
99 | - ) { |
|
99 | + ){ |
|
100 | 100 | // escaped echo sequence, hide directive byte |
101 | 101 | yield $src->next(); |
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | |
105 | 105 | $directive = new DirectiveGrammar(); |
106 | - if ($directive->parse($src, $n->offset)) { |
|
107 | - if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE) { |
|
106 | + if ($directive->parse($src, $n->offset)){ |
|
107 | + if (\strtolower($directive->getKeyword()) === self::DECLARE_DIRECTIVE){ |
|
108 | 108 | // configure braces syntax |
109 | 109 | $this->declare($directive->getBody()); |
110 | - } else { |
|
110 | + }else{ |
|
111 | 111 | if ( |
112 | 112 | $this->directiveRenderer !== null |
113 | 113 | && !$this->directiveRenderer->hasDirective($directive->getKeyword()) |
114 | - ) { |
|
114 | + ){ |
|
115 | 115 | // directive opening char |
116 | 116 | yield $n; |
117 | 117 | |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | |
137 | 137 | /** @var BracesGrammar|null $braces */ |
138 | 138 | $braces = null; |
139 | - if ($this->echo->starts($src, $n)) { |
|
139 | + if ($this->echo->starts($src, $n)){ |
|
140 | 140 | $braces = clone $this->echo; |
141 | - } elseif ($this->raw->starts($src, $n)) { |
|
141 | + } elseif ($this->raw->starts($src, $n)){ |
|
142 | 142 | $braces = clone $this->raw; |
143 | 143 | } |
144 | 144 | |
145 | - if ($braces !== null) { |
|
145 | + if ($braces !== null){ |
|
146 | 146 | $echo = $braces->parse($src, $n); |
147 | - if ($echo !== null) { |
|
147 | + if ($echo !== null){ |
|
148 | 148 | yield from $echo; |
149 | 149 | continue; |
150 | 150 | } |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | yield from $src; |
159 | 159 | } |
160 | 160 | |
161 | - private function declare(?string $body): void |
|
161 | + private function declare(?string$body) : void |
|
162 | 162 | { |
163 | - if ($body === null) { |
|
163 | + if ($body === null){ |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | - foreach ($this->fetchOptions($body) as $option => $value) { |
|
168 | - $value = \trim((string) $value, '\'" '); |
|
169 | - switch ($option) { |
|
167 | + foreach ($this->fetchOptions($body) as $option => $value){ |
|
168 | + $value = \trim((string)$value, '\'" '); |
|
169 | + switch ($option){ |
|
170 | 170 | case 'syntax': |
171 | 171 | $this->echo->setActive($value !== 'off'); |
172 | 172 | $this->raw->setActive($value !== 'off'); |
173 | 173 | |
174 | - if ($value === 'default') { |
|
174 | + if ($value === 'default'){ |
|
175 | 175 | $this->echo->setStartSequence('{{'); |
176 | 176 | $this->echo->setEndSequence('}}'); |
177 | 177 | $this->raw->setStartSequence('{!!'); |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | $keyword = null; |
209 | 209 | |
210 | 210 | /** @var Token $token */ |
211 | - foreach ($lexer->parse(new StringStream($body)) as $token) { |
|
212 | - switch ($token->type) { |
|
211 | + foreach ($lexer->parse(new StringStream($body)) as $token){ |
|
212 | + switch ($token->type){ |
|
213 | 213 | case DeclareGrammar::TYPE_KEYWORD: |
214 | - if ($keyword !== null) { |
|
214 | + if ($keyword !== null){ |
|
215 | 215 | $options[$keyword] = $token->content; |
216 | 216 | $keyword = null; |
217 | 217 | break; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $keyword = $token->content; |
220 | 220 | break; |
221 | 221 | case DeclareGrammar::TYPE_QUOTED: |
222 | - if ($keyword !== null) { |
|
222 | + if ($keyword !== null){ |
|
223 | 223 | $options[$keyword] = \trim($token->content, $token->content[0]); |
224 | 224 | $keyword = null; |
225 | 225 | break; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $keyword = \trim($token->content, $token->content[0]); |
229 | 229 | break; |
230 | 230 | case DeclareGrammar::TYPE_COMMA: |
231 | - if ($keyword !== null) { |
|
231 | + if ($keyword !== null){ |
|
232 | 232 | $options[$keyword] = null; |
233 | 233 | $keyword = null; |
234 | 234 | break; |
@@ -39,14 +39,14 @@ |
||
39 | 39 | { |
40 | 40 | $declaration = $this->createDeclaration(CommandDeclaration::class, [ |
41 | 41 | 'description' => $this->description, |
42 | - 'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
|
42 | + 'alias' => $this->alias ?? \strtolower((string)\preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
|
43 | 43 | ]); |
44 | 44 | |
45 | - foreach ($this->arguments as $argument) { |
|
45 | + foreach ($this->arguments as $argument){ |
|
46 | 46 | $declaration->addArgument($argument); |
47 | 47 | } |
48 | 48 | |
49 | - foreach ($this->options as $option) { |
|
49 | + foreach ($this->options as $option){ |
|
50 | 50 | $declaration->addOption($option); |
51 | 51 | } |
52 | 52 |
@@ -42,11 +42,13 @@ |
||
42 | 42 | 'alias' => $this->alias ?? \strtolower((string) \preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)), |
43 | 43 | ]); |
44 | 44 | |
45 | - foreach ($this->arguments as $argument) { |
|
45 | + foreach ($this->arguments as $argument) |
|
46 | + { |
|
46 | 47 | $declaration->addArgument($argument); |
47 | 48 | } |
48 | 49 | |
49 | - foreach ($this->options as $option) { |
|
50 | + foreach ($this->options as $option) |
|
51 | + { |
|
50 | 52 | $declaration->addOption($option); |
51 | 53 | } |
52 | 54 |
@@ -40,22 +40,22 @@ |
||
40 | 40 | public function resolveDomain(UriInterface $uri): ?string |
41 | 41 | { |
42 | 42 | $host = $uri->getHost(); |
43 | - if (empty($host)) { |
|
43 | + if (empty($host)){ |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $pattern = $this->config['domain']; |
48 | - if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) { |
|
48 | + if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)){ |
|
49 | 49 | // remove port |
50 | 50 | $host = $matches[1]; |
51 | 51 | } |
52 | 52 | |
53 | - if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)) { |
|
53 | + if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)){ |
|
54 | 54 | //We can't use sub-domains when website required by IP |
55 | - $pattern = \ltrim((string) $pattern, '.'); |
|
55 | + $pattern = \ltrim((string)$pattern, '.'); |
|
56 | 56 | } |
57 | 57 | |
58 | - if (!str_contains((string) $pattern, '%s')) { |
|
58 | + if (!str_contains((string)$pattern, '%s')){ |
|
59 | 59 | //Forced domain |
60 | 60 | return $pattern; |
61 | 61 | } |
@@ -40,22 +40,26 @@ |
||
40 | 40 | public function resolveDomain(UriInterface $uri): ?string |
41 | 41 | { |
42 | 42 | $host = $uri->getHost(); |
43 | - if (empty($host)) { |
|
43 | + if (empty($host)) |
|
44 | + { |
|
44 | 45 | return null; |
45 | 46 | } |
46 | 47 | |
47 | 48 | $pattern = $this->config['domain']; |
48 | - if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) { |
|
49 | + if (\preg_match("/^(\d{1,3}){4}:\d+$/", $host, $matches)) |
|
50 | + { |
|
49 | 51 | // remove port |
50 | 52 | $host = $matches[1]; |
51 | 53 | } |
52 | 54 | |
53 | - if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)) { |
|
55 | + if ($host === 'localhost' || \filter_var($host, FILTER_VALIDATE_IP)) |
|
56 | + { |
|
54 | 57 | //We can't use sub-domains when website required by IP |
55 | 58 | $pattern = \ltrim((string) $pattern, '.'); |
56 | 59 | } |
57 | 60 | |
58 | - if (!str_contains((string) $pattern, '%s')) { |
|
61 | + if (!str_contains((string) $pattern, '%s')) |
|
62 | + { |
|
59 | 63 | //Forced domain |
60 | 64 | return $pattern; |
61 | 65 | } |
@@ -27,22 +27,28 @@ discard block |
||
27 | 27 | MagicCallTrait::class, |
28 | 28 | ] : []; |
29 | 29 | |
30 | - if (\str_contains($className, '\\')) { |
|
30 | + if (\str_contains($className, '\\')) |
|
31 | + { |
|
31 | 32 | $classShortName = \substr($className, \strrpos($className, '\\') + 1); |
32 | 33 | $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';'; |
33 | - } else { |
|
34 | + } |
|
35 | + else |
|
36 | + { |
|
34 | 37 | $classShortName = $className; |
35 | 38 | $classNamespaceStr = ''; |
36 | 39 | } |
37 | 40 | |
38 | 41 | $interface = $type->getName(); |
39 | 42 | $classBody = []; |
40 | - foreach ($type->getMethods() as $method) { |
|
41 | - if ($method->isConstructor()) { |
|
43 | + foreach ($type->getMethods() as $method) |
|
44 | + { |
|
45 | + if ($method->isConstructor()) |
|
46 | + { |
|
42 | 47 | throw new \LogicException('Constructor is not allowed in a proxy.'); |
43 | 48 | } |
44 | 49 | |
45 | - if ($method->isDestructor()) { |
|
50 | + if ($method->isDestructor()) |
|
51 | + { |
|
46 | 52 | $classBody[] = self::renderMethod($method); |
47 | 53 | continue; |
48 | 54 | } |
@@ -69,12 +75,14 @@ discard block |
||
69 | 75 | PHP; |
70 | 76 | |
71 | 77 | $args = []; |
72 | - foreach ($method->getParameters() as $param) { |
|
78 | + foreach ($method->getParameters() as $param) |
|
79 | + { |
|
73 | 80 | $hasRefs = $hasRefs || $param->isPassedByReference(); |
74 | 81 | $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName(); |
75 | 82 | } |
76 | 83 | |
77 | - if (!$hasRefs && !$method->isVariadic()) { |
|
84 | + if (!$hasRefs && !$method->isVariadic()) |
|
85 | + { |
|
78 | 86 | $classBody[] = self::renderMethod( |
79 | 87 | $method, |
80 | 88 | <<<PHP |
@@ -86,7 +94,8 @@ discard block |
||
86 | 94 | |
87 | 95 | $argsStr = \implode(', ', $args); |
88 | 96 | |
89 | - if ($method->isVariadic()) { |
|
97 | + if ($method->isVariadic()) |
|
98 | + { |
|
90 | 99 | $classBody[] = self::renderMethod( |
91 | 100 | $method, |
92 | 101 | <<<PHP |
@@ -154,7 +163,8 @@ discard block |
||
154 | 163 | |
155 | 164 | public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string |
156 | 165 | { |
157 | - if ($types instanceof \ReflectionNamedType) { |
|
166 | + if ($types instanceof \ReflectionNamedType) |
|
167 | + { |
|
158 | 168 | return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin() |
159 | 169 | ? $types->getName() |
160 | 170 | : self::normalizeClassType($types, $class)); |
@@ -167,7 +177,8 @@ discard block |
||
167 | 177 | }; |
168 | 178 | |
169 | 179 | $result = []; |
170 | - foreach ($types as $type) { |
|
180 | + foreach ($types as $type) |
|
181 | + { |
|
171 | 182 | $result[] = $type->isBuiltin() |
172 | 183 | ? $type->getName() |
173 | 184 | : self::normalizeClassType($type, $class); |
@@ -178,7 +189,8 @@ discard block |
||
178 | 189 | |
179 | 190 | public static function renderDefaultValue(\ReflectionParameter $param): string |
180 | 191 | { |
181 | - if ($param->isDefaultValueConstant()) { |
|
192 | + if ($param->isDefaultValueConstant()) |
|
193 | + { |
|
182 | 194 | $result = $param->getDefaultValueConstantName(); |
183 | 195 | |
184 | 196 | return \explode('::', (string) $result)[0] === 'self' |
@@ -27,29 +27,29 @@ discard block |
||
27 | 27 | MagicCallTrait::class, |
28 | 28 | ] : []; |
29 | 29 | |
30 | - if (\str_contains($className, '\\')) { |
|
30 | + if (\str_contains($className, '\\')){ |
|
31 | 31 | $classShortName = \substr($className, \strrpos($className, '\\') + 1); |
32 | - $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';'; |
|
33 | - } else { |
|
32 | + $classNamespaceStr = 'namespace '.\substr($className, 0, \strrpos($className, '\\')).';'; |
|
33 | + }else{ |
|
34 | 34 | $classShortName = $className; |
35 | 35 | $classNamespaceStr = ''; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $interface = $type->getName(); |
39 | 39 | $classBody = []; |
40 | - foreach ($type->getMethods() as $method) { |
|
41 | - if ($method->isConstructor()) { |
|
40 | + foreach ($type->getMethods() as $method){ |
|
41 | + if ($method->isConstructor()){ |
|
42 | 42 | throw new \LogicException('Constructor is not allowed in a proxy.'); |
43 | 43 | } |
44 | 44 | |
45 | - if ($method->isDestructor()) { |
|
45 | + if ($method->isDestructor()){ |
|
46 | 46 | $classBody[] = self::renderMethod($method); |
47 | 47 | continue; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $hasRefs = false; |
51 | - $return = $method->hasReturnType() && (string) $method->getReturnType() === 'void' ? '' : 'return '; |
|
52 | - $call = ($method->isStatic() ? '::' : '->') . $method->getName(); |
|
51 | + $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return '; |
|
52 | + $call = ($method->isStatic() ? '::' : '->').$method->getName(); |
|
53 | 53 | $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context'; |
54 | 54 | $containerStr = match (false) { |
55 | 55 | $attachContainer => 'null', |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | PHP; |
70 | 70 | |
71 | 71 | $args = []; |
72 | - foreach ($method->getParameters() as $param) { |
|
72 | + foreach ($method->getParameters() as $param){ |
|
73 | 73 | $hasRefs = $hasRefs || $param->isPassedByReference(); |
74 | - $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName(); |
|
74 | + $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName(); |
|
75 | 75 | } |
76 | 76 | |
77 | - if (!$hasRefs && !$method->isVariadic()) { |
|
77 | + if (!$hasRefs && !$method->isVariadic()){ |
|
78 | 78 | $classBody[] = self::renderMethod( |
79 | 79 | $method, |
80 | 80 | <<<PHP |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $argsStr = \implode(', ', $args); |
88 | 88 | |
89 | - if ($method->isVariadic()) { |
|
89 | + if ($method->isVariadic()){ |
|
90 | 90 | $classBody[] = self::renderMethod( |
91 | 91 | $method, |
92 | 92 | <<<PHP |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $traitsStr = $traits === [] ? '' : \implode( |
110 | 110 | "\n ", |
111 | - \array_map(fn(string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits), |
|
111 | + \array_map(fn(string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits), |
|
112 | 112 | ); |
113 | 113 | return <<<PHP |
114 | 114 | $classNamespaceStr |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $m->getName(), |
132 | 132 | \implode(', ', \array_map(self::renderParameter(...), $m->getParameters())), |
133 | 133 | $m->hasReturnType() |
134 | - ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass()) |
|
134 | + ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass()) |
|
135 | 135 | : '', |
136 | 136 | $body, |
137 | 137 | ); |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | $param->hasType() ? 'mixed' : '', |
146 | 146 | $param->isPassedByReference() ? '&' : '', |
147 | 147 | $param->isVariadic() ? '...' : '', |
148 | - '$' . $param->getName(), |
|
149 | - $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '', |
|
148 | + '$'.$param->getName(), |
|
149 | + $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '', |
|
150 | 150 | ), |
151 | 151 | ' ', |
152 | 152 | ); |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | |
155 | 155 | public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string |
156 | 156 | { |
157 | - if ($types instanceof \ReflectionNamedType) { |
|
158 | - return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin() |
|
157 | + if ($types instanceof \ReflectionNamedType){ |
|
158 | + return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin() |
|
159 | 159 | ? $types->getName() |
160 | 160 | : self::normalizeClassType($types, $class)); |
161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | }; |
168 | 168 | |
169 | 169 | $result = []; |
170 | - foreach ($types as $type) { |
|
170 | + foreach ($types as $type){ |
|
171 | 171 | $result[] = $type->isBuiltin() |
172 | 172 | ? $type->getName() |
173 | 173 | : self::normalizeClassType($type, $class); |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | |
179 | 179 | public static function renderDefaultValue(\ReflectionParameter $param): string |
180 | 180 | { |
181 | - if ($param->isDefaultValueConstant()) { |
|
181 | + if ($param->isDefaultValueConstant()){ |
|
182 | 182 | $result = $param->getDefaultValueConstantName(); |
183 | 183 | |
184 | - return \explode('::', (string) $result)[0] === 'self' |
|
184 | + return \explode('::', (string)$result)[0] === 'self' |
|
185 | 185 | ? $result |
186 | - : '\\' . $result; |
|
186 | + : '\\'.$result; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $cut = self::cutDefaultValue($param); |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | |
196 | 196 | public static function normalizeClassType(\ReflectionNamedType $type, \ReflectionClass $class): string |
197 | 197 | { |
198 | - return '\\' . ($type->getName() === 'self' ? $class->getName() : $type->getName()); |
|
198 | + return '\\'.($type->getName() === 'self' ? $class->getName() : $type->getName()); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | private static function cutDefaultValue(\ReflectionParameter $param): string |
202 | 202 | { |
203 | - $string = (string) $param; |
|
203 | + $string = (string)$param; |
|
204 | 204 | |
205 | 205 | return \trim(\substr($string, \strpos($string, '=') + 1, -1)); |
206 | 206 | } |
@@ -18,23 +18,23 @@ discard block |
||
18 | 18 | { |
19 | 19 | $lines = \explode("\n", $comment); |
20 | 20 | |
21 | - foreach ($lines as $line) { |
|
21 | + foreach ($lines as $line){ |
|
22 | 22 | // strip up comment prefix |
23 | 23 | /** @var string $line */ |
24 | 24 | $line = \preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line); |
25 | 25 | |
26 | - if (\preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) { |
|
26 | + if (\preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)){ |
|
27 | 27 | $this->lines[] = new Line($matches[2], $matches[1]); |
28 | - } else { |
|
28 | + }else{ |
|
29 | 29 | $this->lines[] = new Line($line); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | - if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) { |
|
33 | + if (isset($this->lines[0]) && $this->lines[0]->isEmpty()){ |
|
34 | 34 | \array_shift($this->lines); |
35 | 35 | } |
36 | 36 | |
37 | - if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()) { |
|
37 | + if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()){ |
|
38 | 38 | \array_pop($this->lines); |
39 | 39 | } |
40 | 40 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | $result[] = '/**'; |
46 | 46 | |
47 | 47 | // skip first and last tokens |
48 | - foreach ($this->lines as $line) { |
|
49 | - if ($line->type === null) { |
|
48 | + foreach ($this->lines as $line){ |
|
49 | + if ($line->type === null){ |
|
50 | 50 | $result[] = \sprintf(' * %s', $line->value); |
51 | 51 | continue; |
52 | 52 | } |
@@ -18,23 +18,29 @@ discard block |
||
18 | 18 | { |
19 | 19 | $lines = \explode("\n", $comment); |
20 | 20 | |
21 | - foreach ($lines as $line) { |
|
21 | + foreach ($lines as $line) |
|
22 | + { |
|
22 | 23 | // strip up comment prefix |
23 | 24 | /** @var string $line */ |
24 | 25 | $line = \preg_replace('/[\t ]*[\/]?\*[\/]? ?/', '', $line); |
25 | 26 | |
26 | - if (\preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) { |
|
27 | + if (\preg_match('/ *@([^ ]+) (.*)/u', $line, $matches)) |
|
28 | + { |
|
27 | 29 | $this->lines[] = new Line($matches[2], $matches[1]); |
28 | - } else { |
|
30 | + } |
|
31 | + else |
|
32 | + { |
|
29 | 33 | $this->lines[] = new Line($line); |
30 | 34 | } |
31 | 35 | } |
32 | 36 | |
33 | - if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) { |
|
37 | + if (isset($this->lines[0]) && $this->lines[0]->isEmpty()) |
|
38 | + { |
|
34 | 39 | \array_shift($this->lines); |
35 | 40 | } |
36 | 41 | |
37 | - if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()) { |
|
42 | + if (isset($this->lines[\count($this->lines) - 1]) && $this->lines[\count($this->lines) - 1]->isEmpty()) |
|
43 | + { |
|
38 | 44 | \array_pop($this->lines); |
39 | 45 | } |
40 | 46 | } |
@@ -45,8 +51,10 @@ discard block |
||
45 | 51 | $result[] = '/**'; |
46 | 52 | |
47 | 53 | // skip first and last tokens |
48 | - foreach ($this->lines as $line) { |
|
49 | - if ($line->type === null) { |
|
54 | + foreach ($this->lines as $line) |
|
55 | + { |
|
56 | + if ($line->type === null) |
|
57 | + { |
|
50 | 58 | $result[] = \sprintf(' * %s', $line->value); |
51 | 59 | continue; |
52 | 60 | } |
@@ -14,13 +14,13 @@ |
||
14 | 14 | public function configure(Command $command, \ReflectionClass $reflection): void |
15 | 15 | { |
16 | 16 | $command->setName($reflection->getConstant('NAME')); |
17 | - $command->setDescription((string) $reflection->getConstant('DESCRIPTION')); |
|
17 | + $command->setDescription((string)$reflection->getConstant('DESCRIPTION')); |
|
18 | 18 | |
19 | - foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) { |
|
19 | + foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option){ |
|
20 | 20 | $command->addOption(...$option); |
21 | 21 | } |
22 | 22 | |
23 | - foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) { |
|
23 | + foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument){ |
|
24 | 24 | $command->addArgument(...$argument); |
25 | 25 | } |
26 | 26 | } |
@@ -16,11 +16,13 @@ |
||
16 | 16 | $command->setName($reflection->getConstant('NAME')); |
17 | 17 | $command->setDescription((string) $reflection->getConstant('DESCRIPTION')); |
18 | 18 | |
19 | - foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) { |
|
19 | + foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) |
|
20 | + { |
|
20 | 21 | $command->addOption(...$option); |
21 | 22 | } |
22 | 23 | |
23 | - foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) { |
|
24 | + foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) |
|
25 | + { |
|
24 | 26 | $command->addArgument(...$argument); |
25 | 27 | } |
26 | 28 | } |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | { |
29 | 29 | $scope = self::getAccessor($container)->scope; |
30 | 30 | $result = []; |
31 | - do { |
|
31 | + do{ |
|
32 | 32 | $result[] = $scope->getScopeName(); |
33 | 33 | $scope = $scope->getParentScope(); |
34 | - } while ($scope !== null); |
|
34 | + }while ($scope !== null); |
|
35 | 35 | |
36 | 36 | return $result; |
37 | 37 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | Proxy::isProxy($container) => ContainerScope::getContainer() ?? throw new \RuntimeException( |
47 | 47 | 'Container Proxy is out of scope.', |
48 | 48 | ), |
49 | - default => throw new \InvalidArgumentException('Container must be an instance of ' . Container::class), |
|
49 | + default => throw new \InvalidArgumentException('Container must be an instance of '.Container::class), |
|
50 | 50 | }; |
51 | 51 | |
52 | 52 | $container ??= ContainerScope::getContainer(); |
53 | 53 | |
54 | - if (!$container instanceof Container) { |
|
54 | + if (!$container instanceof Container){ |
|
55 | 55 | throw new \RuntimeException('Container is not available.'); |
56 | 56 | } |
57 | 57 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | { |
29 | 29 | $scope = self::getAccessor($container)->scope; |
30 | 30 | $result = []; |
31 | - do { |
|
31 | + do |
|
32 | + { |
|
32 | 33 | $result[] = $scope->getScopeName(); |
33 | 34 | $scope = $scope->getParentScope(); |
34 | 35 | } while ($scope !== null); |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | |
52 | 53 | $container ??= ContainerScope::getContainer(); |
53 | 54 | |
54 | - if (!$container instanceof Container) { |
|
55 | + if (!$container instanceof Container) |
|
56 | + { |
|
55 | 57 | throw new \RuntimeException('Container is not available.'); |
56 | 58 | } |
57 | 59 |