@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | array $headers = [] |
52 | 52 | ): ResponseInterface { |
53 | 53 | $r = $this->request($uri, 'GET', [], $headers, []); |
54 | - foreach ($attributes as $k => $v) { |
|
54 | + foreach ($attributes as $k => $v){ |
|
55 | 55 | $r = $r->withAttribute($k, $v); |
56 | 56 | } |
57 | 57 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function fetchCookies(array $header) |
96 | 96 | { |
97 | 97 | $result = []; |
98 | - foreach ($header as $line) { |
|
98 | + foreach ($header as $line){ |
|
99 | 99 | $cookie = explode('=', $line); |
100 | 100 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); |
101 | 101 | } |
@@ -51,7 +51,8 @@ discard block |
||
51 | 51 | array $headers = [] |
52 | 52 | ): ResponseInterface { |
53 | 53 | $r = $this->request($uri, 'GET', [], $headers, []); |
54 | - foreach ($attributes as $k => $v) { |
|
54 | + foreach ($attributes as $k => $v) |
|
55 | + { |
|
55 | 56 | $r = $r->withAttribute($k, $v); |
56 | 57 | } |
57 | 58 | |
@@ -95,7 +96,8 @@ discard block |
||
95 | 96 | public function fetchCookies(array $header) |
96 | 97 | { |
97 | 98 | $result = []; |
98 | - foreach ($header as $line) { |
|
99 | + foreach ($header as $line) |
|
100 | + { |
|
99 | 101 | $cookie = explode('=', $line); |
100 | 102 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); |
101 | 103 | } |
@@ -28,11 +28,11 @@ |
||
28 | 28 | |
29 | 29 | public function testCache(): void |
30 | 30 | { |
31 | - $this->assertFileExists(__DIR__ . '/App/runtime/cache/routes.php'); |
|
32 | - $this->assertCount(2, include __DIR__ . '/App/runtime/cache/routes.php'); |
|
31 | + $this->assertFileExists(__DIR__.'/App/runtime/cache/routes.php'); |
|
32 | + $this->assertCount(2, include __DIR__.'/App/runtime/cache/routes.php'); |
|
33 | 33 | |
34 | 34 | $this->app->getConsole()->run('route:reset'); |
35 | 35 | |
36 | - $this->assertSame(null, include __DIR__ . '/App/runtime/cache/routes.php'); |
|
36 | + $this->assertSame(null, include __DIR__.'/App/runtime/cache/routes.php'); |
|
37 | 37 | } |
38 | 38 | } |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'index' => |
|
3 | - array ( |
|
2 | + 'index' => |
|
3 | + array ( |
|
4 | 4 | 'pattern' => '/', |
5 | 5 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
6 | 6 | 'action' => 'index', |
7 | 7 | 'group' => 'default', |
8 | 8 | 'verbs' => |
9 | 9 | array ( |
10 | - 0 => 'GET', |
|
10 | + 0 => 'GET', |
|
11 | 11 | ), |
12 | 12 | 'defaults' => |
13 | 13 | array ( |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | 'middleware' => |
16 | 16 | array ( |
17 | 17 | ), |
18 | - ), |
|
19 | - 'method' => |
|
20 | - array ( |
|
18 | + ), |
|
19 | + 'method' => |
|
20 | + array ( |
|
21 | 21 | 'pattern' => '/', |
22 | 22 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
23 | 23 | 'action' => 'method', |
24 | 24 | 'group' => 'default', |
25 | 25 | 'verbs' => |
26 | 26 | array ( |
27 | - 0 => 'POST', |
|
27 | + 0 => 'POST', |
|
28 | 28 | ), |
29 | 29 | 'defaults' => |
30 | 30 | array ( |
@@ -32,5 +32,5 @@ discard block |
||
32 | 32 | 'middleware' => |
33 | 33 | array ( |
34 | 34 | ), |
35 | - ), |
|
35 | + ), |
|
36 | 36 | ); |
37 | 37 | \ No newline at end of file |
@@ -1,36 +1,36 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'index' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pattern' => '/', |
5 | 5 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
6 | 6 | 'action' => 'index', |
7 | 7 | 'group' => 'default', |
8 | 8 | 'verbs' => |
9 | - array ( |
|
9 | + array( |
|
10 | 10 | 0 => 'GET', |
11 | 11 | ), |
12 | 12 | 'defaults' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | ), |
15 | 15 | 'middleware' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | ), |
18 | 18 | ), |
19 | 19 | 'method' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | 'pattern' => '/', |
22 | 22 | 'controller' => 'Spiral\\Tests\\Router\\App\\Controller\\HomeController', |
23 | 23 | 'action' => 'method', |
24 | 24 | 'group' => 'default', |
25 | 25 | 'verbs' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 0 => 'POST', |
28 | 28 | ), |
29 | 29 | 'defaults' => |
30 | - array ( |
|
30 | + array( |
|
31 | 31 | ), |
32 | 32 | 'middleware' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | ), |
35 | 35 | ), |
36 | 36 | ); |
37 | 37 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | ['name', InputArgument::REQUIRED, 'Entity name'], |
34 | 34 | ['format', InputArgument::OPTIONAL, 'Declaration format (annotated, xml?, yaml?, php?)', 'annotated'], |
35 | 35 | ]; |
36 | - protected const OPTIONS = [ |
|
36 | + protected const OPTIONS = [ |
|
37 | 37 | [ |
38 | 38 | 'role', |
39 | 39 | 'r', |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $declaration = $this->createDeclaration(); |
109 | 109 | |
110 | 110 | $repository = trimPostfix((string)$this->argument('name'), 'repository'); |
111 | - if ($this->option('repository')) { |
|
111 | + if ($this->option('repository')){ |
|
112 | 112 | $repositoryClass = $config->className(RepositoryCommand::ELEMENT, $repository); |
113 | 113 | $repositoryNamespace = $config->classNamespace(RepositoryCommand::ELEMENT, $repository); |
114 | 114 | $declaration->setRepository("\\$repositoryNamespace\\$repositoryClass"); |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | $declaration->setDatabase((string)$this->option('database')); |
121 | 121 | $declaration->setInflection((string)$this->option('inflection')); |
122 | 122 | |
123 | - foreach ($this->option('field') as $field) { |
|
124 | - if (strpos($field, ':') === false) { |
|
123 | + foreach ($this->option('field') as $field){ |
|
124 | + if (strpos($field, ':') === false){ |
|
125 | 125 | throw new ScaffolderException("Field definition must in 'name:type' or 'name:type' form"); |
126 | 126 | } |
127 | 127 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | $this->writeDeclaration($declaration); |
137 | 137 | |
138 | - if ($this->option('repository')) { |
|
138 | + if ($this->option('repository')){ |
|
139 | 139 | $console->run('create:repository', [ |
140 | 140 | 'name' => $repository ?? $this->argument('name'), |
141 | 141 | ]); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | AbstractDeclaration::ACCESS_PROTECTED, |
163 | 163 | AbstractDeclaration::ACCESS_PRIVATE, |
164 | 164 | ], true) |
165 | - ) { |
|
165 | + ){ |
|
166 | 166 | throw new ScaffolderException("Invalid accessibility value `$accessibility`"); |
167 | 167 | } |
168 | 168 | } |
@@ -108,7 +108,8 @@ discard block |
||
108 | 108 | $declaration = $this->createDeclaration(); |
109 | 109 | |
110 | 110 | $repository = trimPostfix((string)$this->argument('name'), 'repository'); |
111 | - if ($this->option('repository')) { |
|
111 | + if ($this->option('repository')) |
|
112 | + { |
|
112 | 113 | $repositoryClass = $config->className(RepositoryCommand::ELEMENT, $repository); |
113 | 114 | $repositoryNamespace = $config->classNamespace(RepositoryCommand::ELEMENT, $repository); |
114 | 115 | $declaration->setRepository("\\$repositoryNamespace\\$repositoryClass"); |
@@ -120,8 +121,10 @@ discard block |
||
120 | 121 | $declaration->setDatabase((string)$this->option('database')); |
121 | 122 | $declaration->setInflection((string)$this->option('inflection')); |
122 | 123 | |
123 | - foreach ($this->option('field') as $field) { |
|
124 | - if (strpos($field, ':') === false) { |
|
124 | + foreach ($this->option('field') as $field) |
|
125 | + { |
|
126 | + if (strpos($field, ':') === false) |
|
127 | + { |
|
125 | 128 | throw new ScaffolderException("Field definition must in 'name:type' or 'name:type' form"); |
126 | 129 | } |
127 | 130 | |
@@ -135,7 +138,8 @@ discard block |
||
135 | 138 | |
136 | 139 | $this->writeDeclaration($declaration); |
137 | 140 | |
138 | - if ($this->option('repository')) { |
|
141 | + if ($this->option('repository')) |
|
142 | + { |
|
139 | 143 | $console->run('create:repository', [ |
140 | 144 | 'name' => $repository ?? $this->argument('name'), |
141 | 145 | ]); |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
25 | 25 | { |
26 | - if (is_array($source)) { |
|
26 | + if (is_array($source)){ |
|
27 | 27 | $source[] = self::OUTPUT; |
28 | 28 | } |
29 | 29 |
@@ -23,7 +23,8 @@ |
||
23 | 23 | */ |
24 | 24 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
25 | 25 | { |
26 | - if (is_array($source)) { |
|
26 | + if (is_array($source)) |
|
27 | + { |
|
27 | 28 | $source[] = self::OUTPUT; |
28 | 29 | } |
29 | 30 |
@@ -52,19 +52,19 @@ |
||
52 | 52 | */ |
53 | 53 | public function leaveNode($node, VisitorContext $ctx) |
54 | 54 | { |
55 | - if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) { |
|
55 | + if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)){ |
|
56 | 56 | return null; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $inject = $this->blocks->claim($node->name); |
60 | 60 | |
61 | - if ($inject instanceof QuotedValue) { |
|
61 | + if ($inject instanceof QuotedValue){ |
|
62 | 62 | // exclude quotes |
63 | 63 | $inject = $inject->trimvalue(); |
64 | 64 | } |
65 | 65 | |
66 | 66 | // mount block:parent content |
67 | - if ($node->name !== 'parent') { |
|
67 | + if ($node->name !== 'parent'){ |
|
68 | 68 | $traverser = new Traverser(); |
69 | 69 | $traverser->addVisitor(new InjectBlocks(new BlockClaims([ |
70 | 70 | 'parent' => $node->nodes, |
@@ -52,19 +52,22 @@ |
||
52 | 52 | */ |
53 | 53 | public function leaveNode($node, VisitorContext $ctx) |
54 | 54 | { |
55 | - if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) { |
|
55 | + if (!$node instanceof Block || $node->name === null || !$this->blocks->has($node->name)) |
|
56 | + { |
|
56 | 57 | return null; |
57 | 58 | } |
58 | 59 | |
59 | 60 | $inject = $this->blocks->claim($node->name); |
60 | 61 | |
61 | - if ($inject instanceof QuotedValue) { |
|
62 | + if ($inject instanceof QuotedValue) |
|
63 | + { |
|
62 | 64 | // exclude quotes |
63 | 65 | $inject = $inject->trimvalue(); |
64 | 66 | } |
65 | 67 | |
66 | 68 | // mount block:parent content |
67 | - if ($node->name !== 'parent') { |
|
69 | + if ($node->name !== 'parent') |
|
70 | + { |
|
68 | 71 | $traverser = new Traverser(); |
69 | 72 | $traverser->addVisitor(new InjectBlocks(new BlockClaims([ |
70 | 73 | 'parent' => $node->nodes, |
@@ -58,11 +58,11 @@ |
||
58 | 58 | 'content' => $this->content, |
59 | 59 | ]; |
60 | 60 | |
61 | - if ($this->grammar !== null) { |
|
61 | + if ($this->grammar !== null){ |
|
62 | 62 | $token['type'] = call_user_func([$this->grammar, 'tokenName'], $this->type); |
63 | 63 | } |
64 | 64 | |
65 | - if ($this->tokens !== []) { |
|
65 | + if ($this->tokens !== []){ |
|
66 | 66 | $token['tokens'] = $this->tokens; |
67 | 67 | } |
68 | 68 |
@@ -58,11 +58,13 @@ |
||
58 | 58 | 'content' => $this->content, |
59 | 59 | ]; |
60 | 60 | |
61 | - if ($this->grammar !== null) { |
|
61 | + if ($this->grammar !== null) |
|
62 | + { |
|
62 | 63 | $token['type'] = call_user_func([$this->grammar, 'tokenName'], $this->type); |
63 | 64 | } |
64 | 65 | |
65 | - if ($this->tokens !== []) { |
|
66 | + if ($this->tokens !== []) |
|
67 | + { |
|
66 | 68 | $token['tokens'] = $this->tokens; |
67 | 69 | } |
68 | 70 |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function parse(Buffer $src): \Generator |
61 | 61 | { |
62 | - while ($n = $src->next()) { |
|
63 | - if (!$n instanceof Byte || $n->char !== '<') { |
|
62 | + while ($n = $src->next()){ |
|
63 | + if (!$n instanceof Byte || $n->char !== '<'){ |
|
64 | 64 | yield $n; |
65 | 65 | continue; |
66 | 66 | } |
67 | 67 | |
68 | 68 | // work with isolated token stream! |
69 | 69 | $tag = (clone $this)->parseGrammar($src); |
70 | - if ($tag === null) { |
|
70 | + if ($tag === null){ |
|
71 | 71 | yield $n; |
72 | 72 | $src->replay($n->offset); |
73 | 73 | continue; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $tagName = $this->tagName($tag); |
77 | 77 | |
78 | 78 | // todo: add support for custom tag list |
79 | - if (in_array($tagName, self::VERBATIM_TAGS)) { |
|
79 | + if (in_array($tagName, self::VERBATIM_TAGS)){ |
|
80 | 80 | yield from $tag; |
81 | 81 | yield from $this->parseVerbatim($src, $tagName); |
82 | 82 | continue; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function tokenName(int $token): string |
94 | 94 | { |
95 | - switch ($token) { |
|
95 | + switch ($token){ |
|
96 | 96 | case self::TYPE_RAW: |
97 | 97 | return 'HTML:RAW'; |
98 | 98 | case self::TYPE_KEYWORD: |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | { |
128 | 128 | $chunks = []; |
129 | 129 | |
130 | - while ($n = $src->next()) { |
|
131 | - if ($n instanceof Token) { |
|
130 | + while ($n = $src->next()){ |
|
131 | + if ($n instanceof Token){ |
|
132 | 132 | $chunks[] = $n; |
133 | 133 | continue; |
134 | 134 | } |
135 | 135 | |
136 | - switch ($n->char) { |
|
136 | + switch ($n->char){ |
|
137 | 137 | case '"': |
138 | 138 | case "'": |
139 | 139 | case '`': |
140 | 140 | $chunks[] = $n; |
141 | 141 | |
142 | 142 | // language inclusions allow nested strings |
143 | - while ($nc = $src->next()) { |
|
143 | + while ($nc = $src->next()){ |
|
144 | 144 | $chunks[] = $nc; |
145 | - if ($nc instanceof Token) { |
|
145 | + if ($nc instanceof Token){ |
|
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - if ($nc->char === $n->char) { |
|
149 | + if ($nc->char === $n->char){ |
|
150 | 150 | break; |
151 | 151 | } |
152 | 152 | } |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | $chunks[] = $n; |
158 | 158 | |
159 | 159 | $multiline = false; |
160 | - if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') { |
|
161 | - if ($src->lookaheadByte(1) === '*') { |
|
160 | + if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*'){ |
|
161 | + if ($src->lookaheadByte(1) === '*'){ |
|
162 | 162 | $multiline = true; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $chunks[] = $src->next(); |
166 | 166 | |
167 | 167 | // language inclusions allow nested strings |
168 | - while ($nc = $src->next()) { |
|
169 | - if ($nc instanceof Token) { |
|
168 | + while ($nc = $src->next()){ |
|
169 | + if ($nc instanceof Token){ |
|
170 | 170 | continue; |
171 | 171 | } |
172 | 172 | |
173 | - if ($nc->char === '<') { |
|
173 | + if ($nc->char === '<'){ |
|
174 | 174 | $tag = (clone $this)->parseGrammar($src); |
175 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
175 | + if ($tag === null || $this->tagName($tag) !== $verbatim){ |
|
176 | 176 | $src->replay($n->offset); |
177 | 177 | break; |
178 | 178 | } |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | |
184 | 184 | $chunks[] = $nc; |
185 | 185 | |
186 | - if ($multiline) { |
|
187 | - if ($nc->char === '*' && $src->lookaheadByte(1) === '/') { |
|
186 | + if ($multiline){ |
|
187 | + if ($nc->char === '*' && $src->lookaheadByte(1) === '/'){ |
|
188 | 188 | $chunks[] = $src->next(); |
189 | 189 | break; |
190 | 190 | } |
191 | - } elseif ($nc->char === "\n") { |
|
191 | + } elseif ($nc->char === "\n"){ |
|
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | case '<': |
200 | 200 | // tag beginning? |
201 | 201 | $tag = (clone $this)->parseGrammar($src); |
202 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
202 | + if ($tag === null || $this->tagName($tag) !== $verbatim){ |
|
203 | 203 | $chunks[] = $n; |
204 | 204 | $src->replay($n->offset); |
205 | 205 | break; |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | */ |
224 | 224 | private function tagName(array $tag): string |
225 | 225 | { |
226 | - foreach ($tag as $token) { |
|
227 | - if ($token->type === self::TYPE_KEYWORD) { |
|
226 | + foreach ($tag as $token){ |
|
227 | + if ($token->type === self::TYPE_KEYWORD){ |
|
228 | 228 | return strtolower($token->content); |
229 | 229 | } |
230 | 230 | } |
@@ -242,28 +242,28 @@ discard block |
||
242 | 242 | new Token(self::TYPE_OPEN, $src->getOffset(), '<'), |
243 | 243 | ]; |
244 | 244 | |
245 | - if ($src->lookaheadByte() === '/') { |
|
245 | + if ($src->lookaheadByte() === '/'){ |
|
246 | 246 | $this->tokens[0]->type = self::TYPE_OPEN_SHORT; |
247 | 247 | $this->tokens[0]->content .= $src->next()->char; |
248 | 248 | } |
249 | 249 | |
250 | - while ($n = $src->next()) { |
|
251 | - if ($this->attribute !== []) { |
|
250 | + while ($n = $src->next()){ |
|
251 | + if ($this->attribute !== []){ |
|
252 | 252 | $this->attribute[] = $n; |
253 | 253 | |
254 | - if ($n instanceof Byte && $n->char === $this->attribute[0]->char) { |
|
254 | + if ($n instanceof Byte && $n->char === $this->attribute[0]->char){ |
|
255 | 255 | $this->flushAttribute(); |
256 | 256 | } |
257 | 257 | |
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | |
261 | - if ($n instanceof Token) { |
|
261 | + if ($n instanceof Token){ |
|
262 | 262 | $this->keyword[] = $n; |
263 | 263 | continue; |
264 | 264 | } |
265 | 265 | |
266 | - switch ($n->char) { |
|
266 | + switch ($n->char){ |
|
267 | 267 | case '"': |
268 | 268 | case "'": |
269 | 269 | case '`': |
@@ -281,12 +281,12 @@ discard block |
||
281 | 281 | break; |
282 | 282 | |
283 | 283 | case '/': |
284 | - if ($src->lookaheadByte() === '>') { |
|
284 | + if ($src->lookaheadByte() === '>'){ |
|
285 | 285 | $this->flush(); |
286 | 286 | $this->tokens[] = new Token( |
287 | 287 | self::TYPE_CLOSE_SHORT, |
288 | 288 | $n->offset, |
289 | - $n->char . $src->next()->char |
|
289 | + $n->char.$src->next()->char |
|
290 | 290 | ); |
291 | 291 | |
292 | 292 | break 2; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | break 2; |
306 | 306 | |
307 | 307 | default: |
308 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
308 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
309 | 309 | $this->flushKeyword(); |
310 | 310 | $this->whitespace[] = $n; |
311 | 311 | break; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $this->flushWhitespace(); |
314 | 314 | |
315 | 315 | |
316 | - if (!preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
316 | + if (!preg_match(self::REGEXP_KEYWORD, $n->char)){ |
|
317 | 317 | // unexpected char |
318 | 318 | return null; |
319 | 319 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if (!$this->isValid()) { |
|
325 | + if (!$this->isValid()){ |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | |
@@ -335,17 +335,17 @@ discard block |
||
335 | 335 | private function isValid(): bool |
336 | 336 | { |
337 | 337 | // tag is too short or does not have name keyword |
338 | - if (count($this->tokens) < 3) { |
|
338 | + if (count($this->tokens) < 3){ |
|
339 | 339 | return false; |
340 | 340 | } |
341 | 341 | |
342 | 342 | $last = $this->tokens[count($this->tokens) - 1]; |
343 | - if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) { |
|
343 | + if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT){ |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | |
347 | - foreach ($this->tokens as $token) { |
|
348 | - switch ($token->type) { |
|
347 | + foreach ($this->tokens as $token){ |
|
348 | + switch ($token->type){ |
|
349 | 349 | case self::TYPE_WHITESPACE: |
350 | 350 | // ignore |
351 | 351 | continue 2; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | private function flushWhitespace(): void |
378 | 378 | { |
379 | - if ($this->whitespace === []) { |
|
379 | + if ($this->whitespace === []){ |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | private function flushKeyword(): void |
391 | 391 | { |
392 | - if ($this->keyword === []) { |
|
392 | + if ($this->keyword === []){ |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | private function flushAttribute(): void |
404 | 404 | { |
405 | - if ($this->attribute === []) { |
|
405 | + if ($this->attribute === []){ |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 |
@@ -59,15 +59,18 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function parse(Buffer $src): \Generator |
61 | 61 | { |
62 | - while ($n = $src->next()) { |
|
63 | - if (!$n instanceof Byte || $n->char !== '<') { |
|
62 | + while ($n = $src->next()) |
|
63 | + { |
|
64 | + if (!$n instanceof Byte || $n->char !== '<') |
|
65 | + { |
|
64 | 66 | yield $n; |
65 | 67 | continue; |
66 | 68 | } |
67 | 69 | |
68 | 70 | // work with isolated token stream! |
69 | 71 | $tag = (clone $this)->parseGrammar($src); |
70 | - if ($tag === null) { |
|
72 | + if ($tag === null) |
|
73 | + { |
|
71 | 74 | yield $n; |
72 | 75 | $src->replay($n->offset); |
73 | 76 | continue; |
@@ -76,7 +79,8 @@ discard block |
||
76 | 79 | $tagName = $this->tagName($tag); |
77 | 80 | |
78 | 81 | // todo: add support for custom tag list |
79 | - if (in_array($tagName, self::VERBATIM_TAGS)) { |
|
82 | + if (in_array($tagName, self::VERBATIM_TAGS)) |
|
83 | + { |
|
80 | 84 | yield from $tag; |
81 | 85 | yield from $this->parseVerbatim($src, $tagName); |
82 | 86 | continue; |
@@ -92,7 +96,8 @@ discard block |
||
92 | 96 | */ |
93 | 97 | public static function tokenName(int $token): string |
94 | 98 | { |
95 | - switch ($token) { |
|
99 | + switch ($token) |
|
100 | + { |
|
96 | 101 | case self::TYPE_RAW: |
97 | 102 | return 'HTML:RAW'; |
98 | 103 | case self::TYPE_KEYWORD: |
@@ -127,26 +132,32 @@ discard block |
||
127 | 132 | { |
128 | 133 | $chunks = []; |
129 | 134 | |
130 | - while ($n = $src->next()) { |
|
131 | - if ($n instanceof Token) { |
|
135 | + while ($n = $src->next()) |
|
136 | + { |
|
137 | + if ($n instanceof Token) |
|
138 | + { |
|
132 | 139 | $chunks[] = $n; |
133 | 140 | continue; |
134 | 141 | } |
135 | 142 | |
136 | - switch ($n->char) { |
|
143 | + switch ($n->char) |
|
144 | + { |
|
137 | 145 | case '"': |
138 | 146 | case "'": |
139 | 147 | case '`': |
140 | 148 | $chunks[] = $n; |
141 | 149 | |
142 | 150 | // language inclusions allow nested strings |
143 | - while ($nc = $src->next()) { |
|
151 | + while ($nc = $src->next()) |
|
152 | + { |
|
144 | 153 | $chunks[] = $nc; |
145 | - if ($nc instanceof Token) { |
|
154 | + if ($nc instanceof Token) |
|
155 | + { |
|
146 | 156 | continue; |
147 | 157 | } |
148 | 158 | |
149 | - if ($nc->char === $n->char) { |
|
159 | + if ($nc->char === $n->char) |
|
160 | + { |
|
150 | 161 | break; |
151 | 162 | } |
152 | 163 | } |
@@ -157,22 +168,28 @@ discard block |
||
157 | 168 | $chunks[] = $n; |
158 | 169 | |
159 | 170 | $multiline = false; |
160 | - if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') { |
|
161 | - if ($src->lookaheadByte(1) === '*') { |
|
171 | + if ($src->lookaheadByte(1) === '/' || $src->lookaheadByte(1) === '*') |
|
172 | + { |
|
173 | + if ($src->lookaheadByte(1) === '*') |
|
174 | + { |
|
162 | 175 | $multiline = true; |
163 | 176 | } |
164 | 177 | |
165 | 178 | $chunks[] = $src->next(); |
166 | 179 | |
167 | 180 | // language inclusions allow nested strings |
168 | - while ($nc = $src->next()) { |
|
169 | - if ($nc instanceof Token) { |
|
181 | + while ($nc = $src->next()) |
|
182 | + { |
|
183 | + if ($nc instanceof Token) |
|
184 | + { |
|
170 | 185 | continue; |
171 | 186 | } |
172 | 187 | |
173 | - if ($nc->char === '<') { |
|
188 | + if ($nc->char === '<') |
|
189 | + { |
|
174 | 190 | $tag = (clone $this)->parseGrammar($src); |
175 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
191 | + if ($tag === null || $this->tagName($tag) !== $verbatim) |
|
192 | + { |
|
176 | 193 | $src->replay($n->offset); |
177 | 194 | break; |
178 | 195 | } |
@@ -183,12 +200,16 @@ discard block |
||
183 | 200 | |
184 | 201 | $chunks[] = $nc; |
185 | 202 | |
186 | - if ($multiline) { |
|
187 | - if ($nc->char === '*' && $src->lookaheadByte(1) === '/') { |
|
203 | + if ($multiline) |
|
204 | + { |
|
205 | + if ($nc->char === '*' && $src->lookaheadByte(1) === '/') |
|
206 | + { |
|
188 | 207 | $chunks[] = $src->next(); |
189 | 208 | break; |
190 | 209 | } |
191 | - } elseif ($nc->char === "\n") { |
|
210 | + } |
|
211 | + elseif ($nc->char === "\n") |
|
212 | + { |
|
192 | 213 | break; |
193 | 214 | } |
194 | 215 | } |
@@ -199,7 +220,8 @@ discard block |
||
199 | 220 | case '<': |
200 | 221 | // tag beginning? |
201 | 222 | $tag = (clone $this)->parseGrammar($src); |
202 | - if ($tag === null || $this->tagName($tag) !== $verbatim) { |
|
223 | + if ($tag === null || $this->tagName($tag) !== $verbatim) |
|
224 | + { |
|
203 | 225 | $chunks[] = $n; |
204 | 226 | $src->replay($n->offset); |
205 | 227 | break; |
@@ -223,8 +245,10 @@ discard block |
||
223 | 245 | */ |
224 | 246 | private function tagName(array $tag): string |
225 | 247 | { |
226 | - foreach ($tag as $token) { |
|
227 | - if ($token->type === self::TYPE_KEYWORD) { |
|
248 | + foreach ($tag as $token) |
|
249 | + { |
|
250 | + if ($token->type === self::TYPE_KEYWORD) |
|
251 | + { |
|
228 | 252 | return strtolower($token->content); |
229 | 253 | } |
230 | 254 | } |
@@ -242,28 +266,34 @@ discard block |
||
242 | 266 | new Token(self::TYPE_OPEN, $src->getOffset(), '<'), |
243 | 267 | ]; |
244 | 268 | |
245 | - if ($src->lookaheadByte() === '/') { |
|
269 | + if ($src->lookaheadByte() === '/') |
|
270 | + { |
|
246 | 271 | $this->tokens[0]->type = self::TYPE_OPEN_SHORT; |
247 | 272 | $this->tokens[0]->content .= $src->next()->char; |
248 | 273 | } |
249 | 274 | |
250 | - while ($n = $src->next()) { |
|
251 | - if ($this->attribute !== []) { |
|
275 | + while ($n = $src->next()) |
|
276 | + { |
|
277 | + if ($this->attribute !== []) |
|
278 | + { |
|
252 | 279 | $this->attribute[] = $n; |
253 | 280 | |
254 | - if ($n instanceof Byte && $n->char === $this->attribute[0]->char) { |
|
281 | + if ($n instanceof Byte && $n->char === $this->attribute[0]->char) |
|
282 | + { |
|
255 | 283 | $this->flushAttribute(); |
256 | 284 | } |
257 | 285 | |
258 | 286 | continue; |
259 | 287 | } |
260 | 288 | |
261 | - if ($n instanceof Token) { |
|
289 | + if ($n instanceof Token) |
|
290 | + { |
|
262 | 291 | $this->keyword[] = $n; |
263 | 292 | continue; |
264 | 293 | } |
265 | 294 | |
266 | - switch ($n->char) { |
|
295 | + switch ($n->char) |
|
296 | + { |
|
267 | 297 | case '"': |
268 | 298 | case "'": |
269 | 299 | case '`': |
@@ -281,7 +311,8 @@ discard block |
||
281 | 311 | break; |
282 | 312 | |
283 | 313 | case '/': |
284 | - if ($src->lookaheadByte() === '>') { |
|
314 | + if ($src->lookaheadByte() === '>') |
|
315 | + { |
|
285 | 316 | $this->flush(); |
286 | 317 | $this->tokens[] = new Token( |
287 | 318 | self::TYPE_CLOSE_SHORT, |
@@ -305,7 +336,8 @@ discard block |
||
305 | 336 | break 2; |
306 | 337 | |
307 | 338 | default: |
308 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
339 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
340 | + { |
|
309 | 341 | $this->flushKeyword(); |
310 | 342 | $this->whitespace[] = $n; |
311 | 343 | break; |
@@ -313,7 +345,8 @@ discard block |
||
313 | 345 | $this->flushWhitespace(); |
314 | 346 | |
315 | 347 | |
316 | - if (!preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
348 | + if (!preg_match(self::REGEXP_KEYWORD, $n->char)) |
|
349 | + { |
|
317 | 350 | // unexpected char |
318 | 351 | return null; |
319 | 352 | } |
@@ -322,7 +355,8 @@ discard block |
||
322 | 355 | } |
323 | 356 | } |
324 | 357 | |
325 | - if (!$this->isValid()) { |
|
358 | + if (!$this->isValid()) |
|
359 | + { |
|
326 | 360 | return null; |
327 | 361 | } |
328 | 362 | |
@@ -335,17 +369,21 @@ discard block |
||
335 | 369 | private function isValid(): bool |
336 | 370 | { |
337 | 371 | // tag is too short or does not have name keyword |
338 | - if (count($this->tokens) < 3) { |
|
372 | + if (count($this->tokens) < 3) |
|
373 | + { |
|
339 | 374 | return false; |
340 | 375 | } |
341 | 376 | |
342 | 377 | $last = $this->tokens[count($this->tokens) - 1]; |
343 | - if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) { |
|
378 | + if ($last->type !== self::TYPE_CLOSE && $last->type !== self::TYPE_CLOSE_SHORT) |
|
379 | + { |
|
344 | 380 | return false; |
345 | 381 | } |
346 | 382 | |
347 | - foreach ($this->tokens as $token) { |
|
348 | - switch ($token->type) { |
|
383 | + foreach ($this->tokens as $token) |
|
384 | + { |
|
385 | + switch ($token->type) |
|
386 | + { |
|
349 | 387 | case self::TYPE_WHITESPACE: |
350 | 388 | // ignore |
351 | 389 | continue 2; |
@@ -376,7 +414,8 @@ discard block |
||
376 | 414 | */ |
377 | 415 | private function flushWhitespace(): void |
378 | 416 | { |
379 | - if ($this->whitespace === []) { |
|
417 | + if ($this->whitespace === []) |
|
418 | + { |
|
380 | 419 | return; |
381 | 420 | } |
382 | 421 | |
@@ -389,7 +428,8 @@ discard block |
||
389 | 428 | */ |
390 | 429 | private function flushKeyword(): void |
391 | 430 | { |
392 | - if ($this->keyword === []) { |
|
431 | + if ($this->keyword === []) |
|
432 | + { |
|
393 | 433 | return; |
394 | 434 | } |
395 | 435 | |
@@ -402,7 +442,8 @@ discard block |
||
402 | 442 | */ |
403 | 443 | private function flushAttribute(): void |
404 | 444 | { |
405 | - if ($this->attribute === []) { |
|
445 | + if ($this->attribute === []) |
|
446 | + { |
|
406 | 447 | return; |
407 | 448 | } |
408 | 449 |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function parse(Buffer $src): \Generator |
50 | 50 | { |
51 | - while ($n = $src->next()) { |
|
52 | - if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') { |
|
51 | + while ($n = $src->next()){ |
|
52 | + if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{'){ |
|
53 | 53 | yield $n; |
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $binding = (clone $this)->parseGrammar($src, $n->offset); |
58 | - if ($binding === null) { |
|
58 | + if ($binding === null){ |
|
59 | 59 | yield $n; |
60 | 60 | $src->replay($n->offset); |
61 | 61 | continue; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function tokenName(int $token): string |
73 | 73 | { |
74 | - switch ($token) { |
|
74 | + switch ($token){ |
|
75 | 75 | case self::TYPE_OPEN_TAG: |
76 | 76 | return 'INLINE:OPEN_TAG'; |
77 | 77 | case self::TYPE_CLOSE_TAG: |
@@ -95,27 +95,27 @@ discard block |
||
95 | 95 | private function parseGrammar(Buffer $src, int $offset): ?array |
96 | 96 | { |
97 | 97 | $this->tokens = [ |
98 | - new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char), |
|
98 | + new Token(self::TYPE_OPEN_TAG, $offset, '$'.$src->next()->char), |
|
99 | 99 | ]; |
100 | 100 | |
101 | - while ($n = $src->next()) { |
|
102 | - if (!$n instanceof Byte) { |
|
101 | + while ($n = $src->next()){ |
|
102 | + if (!$n instanceof Byte){ |
|
103 | 103 | // no other grammars are allowed |
104 | 104 | return null; |
105 | 105 | } |
106 | 106 | |
107 | - switch ($n->char) { |
|
107 | + switch ($n->char){ |
|
108 | 108 | case '"': |
109 | 109 | case "'": |
110 | - if ($this->default === null) { |
|
110 | + if ($this->default === null){ |
|
111 | 111 | // " and ' not allowed in names |
112 | 112 | return null; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $this->default[] = $n; |
116 | - while ($nn = $src->next()) { |
|
116 | + while ($nn = $src->next()){ |
|
117 | 117 | $this->default[] = $nn; |
118 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
118 | + if ($nn instanceof Byte && $nn->char === $n->char){ |
|
119 | 119 | break; |
120 | 120 | } |
121 | 121 | } |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | break; |
149 | 149 | |
150 | 150 | default: |
151 | - if ($this->default !== null) { |
|
151 | + if ($this->default !== null){ |
|
152 | 152 | // default allows spaces |
153 | 153 | $this->default[] = $n; |
154 | 154 | break; |
155 | 155 | } |
156 | 156 | |
157 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
157 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
158 | 158 | break; |
159 | 159 | } |
160 | 160 | |
161 | - if (preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
161 | + if (preg_match(self::REGEXP_KEYWORD, $n->char)){ |
|
162 | 162 | $this->name[] = $n; |
163 | 163 | break; |
164 | 164 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if (!$this->isValid()) { |
|
170 | + if (!$this->isValid()){ |
|
171 | 171 | return null; |
172 | 172 | } |
173 | 173 | |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | */ |
180 | 180 | private function isValid(): bool |
181 | 181 | { |
182 | - if (count($this->tokens) < 3) { |
|
182 | + if (count($this->tokens) < 3){ |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | |
186 | 186 | $hasName = false; |
187 | 187 | $hasDefault = null; |
188 | - foreach ($this->tokens as $token) { |
|
189 | - if ($token->type === self::TYPE_NAME) { |
|
188 | + foreach ($this->tokens as $token){ |
|
189 | + if ($token->type === self::TYPE_NAME){ |
|
190 | 190 | $hasName = true; |
191 | 191 | continue; |
192 | 192 | } |
193 | 193 | |
194 | - if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) { |
|
194 | + if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null){ |
|
195 | 195 | $hasDefault = false; |
196 | 196 | continue; |
197 | 197 | } |
198 | 198 | |
199 | - if ($token->type === self::TYPE_DEFAULT) { |
|
200 | - if ($hasDefault === true) { |
|
199 | + if ($token->type === self::TYPE_DEFAULT){ |
|
200 | + if ($hasDefault === true){ |
|
201 | 201 | // multiple default value |
202 | 202 | return false; |
203 | 203 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | private function flushName(): void |
216 | 216 | { |
217 | - if ($this->name === []) { |
|
217 | + if ($this->name === []){ |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | private function flushDefault(): void |
229 | 229 | { |
230 | - if ($this->default === [] || $this->default === null) { |
|
230 | + if ($this->default === [] || $this->default === null){ |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 |
@@ -48,14 +48,17 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function parse(Buffer $src): \Generator |
50 | 50 | { |
51 | - while ($n = $src->next()) { |
|
52 | - if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') { |
|
51 | + while ($n = $src->next()) |
|
52 | + { |
|
53 | + if (!$n instanceof Byte || $n->char !== '$' || $src->lookaheadByte() !== '{') |
|
54 | + { |
|
53 | 55 | yield $n; |
54 | 56 | continue; |
55 | 57 | } |
56 | 58 | |
57 | 59 | $binding = (clone $this)->parseGrammar($src, $n->offset); |
58 | - if ($binding === null) { |
|
60 | + if ($binding === null) |
|
61 | + { |
|
59 | 62 | yield $n; |
60 | 63 | $src->replay($n->offset); |
61 | 64 | continue; |
@@ -71,7 +74,8 @@ discard block |
||
71 | 74 | */ |
72 | 75 | public static function tokenName(int $token): string |
73 | 76 | { |
74 | - switch ($token) { |
|
77 | + switch ($token) |
|
78 | + { |
|
75 | 79 | case self::TYPE_OPEN_TAG: |
76 | 80 | return 'INLINE:OPEN_TAG'; |
77 | 81 | case self::TYPE_CLOSE_TAG: |
@@ -98,24 +102,30 @@ discard block |
||
98 | 102 | new Token(self::TYPE_OPEN_TAG, $offset, '$' . $src->next()->char), |
99 | 103 | ]; |
100 | 104 | |
101 | - while ($n = $src->next()) { |
|
102 | - if (!$n instanceof Byte) { |
|
105 | + while ($n = $src->next()) |
|
106 | + { |
|
107 | + if (!$n instanceof Byte) |
|
108 | + { |
|
103 | 109 | // no other grammars are allowed |
104 | 110 | return null; |
105 | 111 | } |
106 | 112 | |
107 | - switch ($n->char) { |
|
113 | + switch ($n->char) |
|
114 | + { |
|
108 | 115 | case '"': |
109 | 116 | case "'": |
110 | - if ($this->default === null) { |
|
117 | + if ($this->default === null) |
|
118 | + { |
|
111 | 119 | // " and ' not allowed in names |
112 | 120 | return null; |
113 | 121 | } |
114 | 122 | |
115 | 123 | $this->default[] = $n; |
116 | - while ($nn = $src->next()) { |
|
124 | + while ($nn = $src->next()) |
|
125 | + { |
|
117 | 126 | $this->default[] = $nn; |
118 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
127 | + if ($nn instanceof Byte && $nn->char === $n->char) |
|
128 | + { |
|
119 | 129 | break; |
120 | 130 | } |
121 | 131 | } |
@@ -148,17 +158,20 @@ discard block |
||
148 | 158 | break; |
149 | 159 | |
150 | 160 | default: |
151 | - if ($this->default !== null) { |
|
161 | + if ($this->default !== null) |
|
162 | + { |
|
152 | 163 | // default allows spaces |
153 | 164 | $this->default[] = $n; |
154 | 165 | break; |
155 | 166 | } |
156 | 167 | |
157 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
168 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
169 | + { |
|
158 | 170 | break; |
159 | 171 | } |
160 | 172 | |
161 | - if (preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
173 | + if (preg_match(self::REGEXP_KEYWORD, $n->char)) |
|
174 | + { |
|
162 | 175 | $this->name[] = $n; |
163 | 176 | break; |
164 | 177 | } |
@@ -167,7 +180,8 @@ discard block |
||
167 | 180 | } |
168 | 181 | } |
169 | 182 | |
170 | - if (!$this->isValid()) { |
|
183 | + if (!$this->isValid()) |
|
184 | + { |
|
171 | 185 | return null; |
172 | 186 | } |
173 | 187 | |
@@ -179,25 +193,31 @@ discard block |
||
179 | 193 | */ |
180 | 194 | private function isValid(): bool |
181 | 195 | { |
182 | - if (count($this->tokens) < 3) { |
|
196 | + if (count($this->tokens) < 3) |
|
197 | + { |
|
183 | 198 | return false; |
184 | 199 | } |
185 | 200 | |
186 | 201 | $hasName = false; |
187 | 202 | $hasDefault = null; |
188 | - foreach ($this->tokens as $token) { |
|
189 | - if ($token->type === self::TYPE_NAME) { |
|
203 | + foreach ($this->tokens as $token) |
|
204 | + { |
|
205 | + if ($token->type === self::TYPE_NAME) |
|
206 | + { |
|
190 | 207 | $hasName = true; |
191 | 208 | continue; |
192 | 209 | } |
193 | 210 | |
194 | - if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) { |
|
211 | + if ($token->type === self::TYPE_SEPARATOR && $hasDefault === null) |
|
212 | + { |
|
195 | 213 | $hasDefault = false; |
196 | 214 | continue; |
197 | 215 | } |
198 | 216 | |
199 | - if ($token->type === self::TYPE_DEFAULT) { |
|
200 | - if ($hasDefault === true) { |
|
217 | + if ($token->type === self::TYPE_DEFAULT) |
|
218 | + { |
|
219 | + if ($hasDefault === true) |
|
220 | + { |
|
201 | 221 | // multiple default value |
202 | 222 | return false; |
203 | 223 | } |
@@ -214,7 +234,8 @@ discard block |
||
214 | 234 | */ |
215 | 235 | private function flushName(): void |
216 | 236 | { |
217 | - if ($this->name === []) { |
|
237 | + if ($this->name === []) |
|
238 | + { |
|
218 | 239 | return; |
219 | 240 | } |
220 | 241 | |
@@ -227,7 +248,8 @@ discard block |
||
227 | 248 | */ |
228 | 249 | private function flushDefault(): void |
229 | 250 | { |
230 | - if ($this->default === [] || $this->default === null) { |
|
251 | + if ($this->default === [] || $this->default === null) |
|
252 | + { |
|
231 | 253 | return; |
232 | 254 | } |
233 | 255 |