@@ -30,7 +30,7 @@ |
||
30 | 30 | { |
31 | 31 | $parser = new Parser(); |
32 | 32 | |
33 | - foreach (static::GRAMMARS as $grammar => $syntax) { |
|
33 | + foreach (static::GRAMMARS as $grammar => $syntax){ |
|
34 | 34 | $parser->addSyntax(new $grammar(), new $syntax()); |
35 | 35 | } |
36 | 36 |
@@ -30,7 +30,8 @@ |
||
30 | 30 | { |
31 | 31 | $parser = new Parser(); |
32 | 32 | |
33 | - foreach (static::GRAMMARS as $grammar => $syntax) { |
|
33 | + foreach (static::GRAMMARS as $grammar => $syntax) |
|
34 | + { |
|
34 | 35 | $parser->addSyntax(new $grammar(), new $syntax()); |
35 | 36 | } |
36 | 37 |
@@ -25,8 +25,8 @@ |
||
25 | 25 | protected function makeApp(array $env): App |
26 | 26 | { |
27 | 27 | $config = [ |
28 | - 'root' => __DIR__ . '/App', |
|
29 | - 'app' => __DIR__ . '/App', |
|
28 | + 'root' => __DIR__.'/App', |
|
29 | + 'app' => __DIR__.'/App', |
|
30 | 30 | ]; |
31 | 31 | |
32 | 32 | return App::init($config, new Environment($env), false); |
@@ -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 | } |
@@ -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 |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function starts(Buffer $src, Byte $n): bool |
121 | 121 | { |
122 | - if (!$this->active) { |
|
122 | + if (!$this->active){ |
|
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
126 | - return $this->startSequence === ($n->char . $src->lookaheadByte(strlen($this->startSequence) - 1)); |
|
126 | + return $this->startSequence === ($n->char.$src->lookaheadByte(strlen($this->startSequence) - 1)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -139,30 +139,30 @@ discard block |
||
139 | 139 | new Token( |
140 | 140 | $this->startToken, |
141 | 141 | $n->offset, |
142 | - $n->char . $this->nextBytes($src, strlen($this->startSequence) - 1) |
|
142 | + $n->char.$this->nextBytes($src, strlen($this->startSequence) - 1) |
|
143 | 143 | ), |
144 | 144 | ]; |
145 | 145 | |
146 | - while ($n = $src->next()) { |
|
147 | - if (!$n instanceof Byte) { |
|
146 | + while ($n = $src->next()){ |
|
147 | + if (!$n instanceof Byte){ |
|
148 | 148 | // no other grammars are allowed |
149 | 149 | break; |
150 | 150 | } |
151 | 151 | |
152 | - switch ($n->char) { |
|
152 | + switch ($n->char){ |
|
153 | 153 | case '"': |
154 | 154 | case "'": |
155 | 155 | $this->body[] = $n; |
156 | - while ($nn = $src->next()) { |
|
156 | + while ($nn = $src->next()){ |
|
157 | 157 | $this->body[] = $nn; |
158 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
158 | + if ($nn instanceof Byte && $nn->char === $n->char){ |
|
159 | 159 | break; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | break; |
163 | 163 | |
164 | 164 | case $this->endSequence[0]: |
165 | - if (!$this->ends($src, $n)) { |
|
165 | + if (!$this->ends($src, $n)){ |
|
166 | 166 | // still part of body |
167 | 167 | $this->body[] = $n; |
168 | 168 | break; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $this->tokens[] = new Token( |
173 | 173 | $this->endToken, |
174 | 174 | $n->offset, |
175 | - $n->char . $this->nextBytes($src, strlen($this->endSequence) - 1) |
|
175 | + $n->char.$this->nextBytes($src, strlen($this->endSequence) - 1) |
|
176 | 176 | ); |
177 | 177 | |
178 | 178 | break 2; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - if (count($this->tokens) !== 3) { |
|
184 | + if (count($this->tokens) !== 3){ |
|
185 | 185 | return null; |
186 | 186 | } |
187 | 187 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function ends(Buffer $src, Byte $n): bool |
199 | 199 | { |
200 | - return $this->endSequence === ($n->char . $src->lookaheadByte(strlen($this->endSequence) - 1)); |
|
200 | + return $this->endSequence === ($n->char.$src->lookaheadByte(strlen($this->endSequence) - 1)); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | private function nextBytes(Buffer $src, int $size): string |
211 | 211 | { |
212 | 212 | $result = ''; |
213 | - for ($i = 0; $i < $size; $i++) { |
|
213 | + for ($i = 0; $i < $size; $i++){ |
|
214 | 214 | $result .= $src->next()->char; |
215 | 215 | } |
216 | 216 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function flushBody(): void |
224 | 224 | { |
225 | - if ($this->body === []) { |
|
225 | + if ($this->body === []){ |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 |
@@ -119,7 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function starts(Buffer $src, Byte $n): bool |
121 | 121 | { |
122 | - if (!$this->active) { |
|
122 | + if (!$this->active) |
|
123 | + { |
|
123 | 124 | return false; |
124 | 125 | } |
125 | 126 | |
@@ -143,26 +144,32 @@ discard block |
||
143 | 144 | ), |
144 | 145 | ]; |
145 | 146 | |
146 | - while ($n = $src->next()) { |
|
147 | - if (!$n instanceof Byte) { |
|
147 | + while ($n = $src->next()) |
|
148 | + { |
|
149 | + if (!$n instanceof Byte) |
|
150 | + { |
|
148 | 151 | // no other grammars are allowed |
149 | 152 | break; |
150 | 153 | } |
151 | 154 | |
152 | - switch ($n->char) { |
|
155 | + switch ($n->char) |
|
156 | + { |
|
153 | 157 | case '"': |
154 | 158 | case "'": |
155 | 159 | $this->body[] = $n; |
156 | - while ($nn = $src->next()) { |
|
160 | + while ($nn = $src->next()) |
|
161 | + { |
|
157 | 162 | $this->body[] = $nn; |
158 | - if ($nn instanceof Byte && $nn->char === $n->char) { |
|
163 | + if ($nn instanceof Byte && $nn->char === $n->char) |
|
164 | + { |
|
159 | 165 | break; |
160 | 166 | } |
161 | 167 | } |
162 | 168 | break; |
163 | 169 | |
164 | 170 | case $this->endSequence[0]: |
165 | - if (!$this->ends($src, $n)) { |
|
171 | + if (!$this->ends($src, $n)) |
|
172 | + { |
|
166 | 173 | // still part of body |
167 | 174 | $this->body[] = $n; |
168 | 175 | break; |
@@ -181,7 +188,8 @@ discard block |
||
181 | 188 | } |
182 | 189 | } |
183 | 190 | |
184 | - if (count($this->tokens) !== 3) { |
|
191 | + if (count($this->tokens) !== 3) |
|
192 | + { |
|
185 | 193 | return null; |
186 | 194 | } |
187 | 195 | |
@@ -210,7 +218,8 @@ discard block |
||
210 | 218 | private function nextBytes(Buffer $src, int $size): string |
211 | 219 | { |
212 | 220 | $result = ''; |
213 | - for ($i = 0; $i < $size; $i++) { |
|
221 | + for ($i = 0; $i < $size; $i++) |
|
222 | + { |
|
214 | 223 | $result .= $src->next()->char; |
215 | 224 | } |
216 | 225 | |
@@ -222,7 +231,8 @@ discard block |
||
222 | 231 | */ |
223 | 232 | private function flushBody(): void |
224 | 233 | { |
225 | - if ($this->body === []) { |
|
234 | + if ($this->body === []) |
|
235 | + { |
|
226 | 236 | return; |
227 | 237 | } |
228 | 238 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | declare(strict_types=1); |
11 | 11 | |
12 | -if (!function_exists('inject')) { |
|
12 | +if (!function_exists('inject')){ |
|
13 | 13 | /** |
14 | 14 | * Macro function to be replaced by the injected value. |
15 | 15 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | -if (!function_exists('injected')) { |
|
26 | +if (!function_exists('injected')){ |
|
27 | 27 | /** |
28 | 28 | * Return true if block value has been defined. |
29 | 29 | * |
@@ -9,7 +9,8 @@ discard block |
||
9 | 9 | |
10 | 10 | declare(strict_types=1); |
11 | 11 | |
12 | -if (!function_exists('inject')) { |
|
12 | +if (!function_exists('inject')) |
|
13 | +{ |
|
13 | 14 | /** |
14 | 15 | * Macro function to be replaced by the injected value. |
15 | 16 | * |
@@ -23,7 +24,8 @@ discard block |
||
23 | 24 | } |
24 | 25 | } |
25 | 26 | |
26 | -if (!function_exists('injected')) { |
|
27 | +if (!function_exists('injected')) |
|
28 | +{ |
|
27 | 29 | /** |
28 | 30 | * Return true if block value has been defined. |
29 | 31 | * |