@@ -63,8 +63,8 @@ |
||
63 | 63 | #[\ReturnTypeWillChange] |
64 | 64 | public function gc($maxlifetime) |
65 | 65 | { |
66 | - foreach ($this->files->getFiles($this->directory) as $filename) { |
|
67 | - if ($this->files->time($filename) < time() - $maxlifetime) { |
|
66 | + foreach ($this->files->getFiles($this->directory) as $filename){ |
|
67 | + if ($this->files->time($filename) < time() - $maxlifetime){ |
|
68 | 68 | $this->files->delete($filename); |
69 | 69 | } |
70 | 70 | } |
@@ -63,8 +63,10 @@ |
||
63 | 63 | #[\ReturnTypeWillChange] |
64 | 64 | public function gc($maxlifetime) |
65 | 65 | { |
66 | - foreach ($this->files->getFiles($this->directory) as $filename) { |
|
67 | - if ($this->files->time($filename) < time() - $maxlifetime) { |
|
66 | + foreach ($this->files->getFiles($this->directory) as $filename) |
|
67 | + { |
|
68 | + if ($this->files->time($filename) < time() - $maxlifetime) |
|
69 | + { |
|
68 | 70 | $this->files->delete($filename); |
69 | 71 | } |
70 | 72 | } |
@@ -72,7 +72,7 @@ |
||
72 | 72 | #[\ReturnTypeWillChange] |
73 | 73 | public function offsetGet($offset) |
74 | 74 | { |
75 | - if (!$this->offsetExists($offset)) { |
|
75 | + if (!$this->offsetExists($offset)){ |
|
76 | 76 | throw new ConfigException("Undefined configuration key '{$offset}'"); |
77 | 77 | } |
78 | 78 |
@@ -72,7 +72,8 @@ |
||
72 | 72 | #[\ReturnTypeWillChange] |
73 | 73 | public function offsetGet($offset) |
74 | 74 | { |
75 | - if (!$this->offsetExists($offset)) { |
|
75 | + if (!$this->offsetExists($offset)) |
|
76 | + { |
|
76 | 77 | throw new ConfigException("Undefined configuration key '{$offset}'"); |
77 | 78 | } |
78 | 79 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function getIterator(): \Traversable |
48 | 48 | { |
49 | - while ($n = $this->next()) { |
|
49 | + while ($n = $this->next()){ |
|
50 | 50 | yield $n; |
51 | 51 | } |
52 | 52 | } |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function next() |
66 | 66 | { |
67 | - if ($this->replay !== []) { |
|
67 | + if ($this->replay !== []){ |
|
68 | 68 | $n = array_shift($this->replay); |
69 | - } else { |
|
69 | + }else{ |
|
70 | 70 | $n = $this->generator->current(); |
71 | - if ($n === null) { |
|
71 | + if ($n === null){ |
|
72 | 72 | return null; |
73 | 73 | } |
74 | 74 | $this->generator->next(); |
75 | 75 | $this->buffer[] = $n; |
76 | 76 | } |
77 | 77 | |
78 | - if ($n !== null) { |
|
78 | + if ($n !== null){ |
|
79 | 79 | $this->offset = $n->offset; |
80 | 80 | } |
81 | 81 | |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | public function nextBytes(): string |
91 | 91 | { |
92 | 92 | $result = ''; |
93 | - while ($n = $this->next()) { |
|
94 | - if ($n instanceof Byte) { |
|
93 | + while ($n = $this->next()){ |
|
94 | + if ($n instanceof Byte){ |
|
95 | 95 | $result .= $n->char; |
96 | - } else { |
|
96 | + }else{ |
|
97 | 97 | break; |
98 | 98 | } |
99 | 99 | } |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function lookahead() |
108 | 108 | { |
109 | - if ($this->replay !== []) { |
|
109 | + if ($this->replay !== []){ |
|
110 | 110 | return $this->replay[0]; |
111 | 111 | } |
112 | 112 | |
113 | 113 | $n = $this->next(); |
114 | - if ($n !== null) { |
|
114 | + if ($n !== null){ |
|
115 | 115 | array_unshift($this->replay, $n); |
116 | 116 | } |
117 | 117 | |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | { |
129 | 129 | $result = ''; |
130 | 130 | $replay = []; |
131 | - for ($i = 0; $i < $size; $i++) { |
|
131 | + for ($i = 0; $i < $size; $i++){ |
|
132 | 132 | $n = $this->next(); |
133 | - if ($n !== null) { |
|
133 | + if ($n !== null){ |
|
134 | 134 | $replay[] = $n; |
135 | 135 | } |
136 | 136 | |
137 | - if (!$n instanceof Byte) { |
|
137 | + if (!$n instanceof Byte){ |
|
138 | 138 | break; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $result .= $n->char; |
142 | 142 | } |
143 | 143 | |
144 | - foreach (array_reverse($replay) as $n) { |
|
144 | + foreach (array_reverse($replay) as $n){ |
|
145 | 145 | array_unshift($this->replay, $n); |
146 | 146 | } |
147 | 147 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function replay(int $offset): void |
157 | 157 | { |
158 | - foreach ($this->buffer as $n) { |
|
159 | - if ($n->offset > $offset) { |
|
158 | + foreach ($this->buffer as $n){ |
|
159 | + if ($n->offset > $offset){ |
|
160 | 160 | $this->replay[] = $n; |
161 | 161 | } |
162 | 162 | } |
@@ -46,7 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function getIterator(): \Traversable |
48 | 48 | { |
49 | - while ($n = $this->next()) { |
|
49 | + while ($n = $this->next()) |
|
50 | + { |
|
50 | 51 | yield $n; |
51 | 52 | } |
52 | 53 | } |
@@ -64,18 +65,23 @@ discard block |
||
64 | 65 | */ |
65 | 66 | public function next() |
66 | 67 | { |
67 | - if ($this->replay !== []) { |
|
68 | + if ($this->replay !== []) |
|
69 | + { |
|
68 | 70 | $n = array_shift($this->replay); |
69 | - } else { |
|
71 | + } |
|
72 | + else |
|
73 | + { |
|
70 | 74 | $n = $this->generator->current(); |
71 | - if ($n === null) { |
|
75 | + if ($n === null) |
|
76 | + { |
|
72 | 77 | return null; |
73 | 78 | } |
74 | 79 | $this->generator->next(); |
75 | 80 | $this->buffer[] = $n; |
76 | 81 | } |
77 | 82 | |
78 | - if ($n !== null) { |
|
83 | + if ($n !== null) |
|
84 | + { |
|
79 | 85 | $this->offset = $n->offset; |
80 | 86 | } |
81 | 87 | |
@@ -90,10 +96,14 @@ discard block |
||
90 | 96 | public function nextBytes(): string |
91 | 97 | { |
92 | 98 | $result = ''; |
93 | - while ($n = $this->next()) { |
|
94 | - if ($n instanceof Byte) { |
|
99 | + while ($n = $this->next()) |
|
100 | + { |
|
101 | + if ($n instanceof Byte) |
|
102 | + { |
|
95 | 103 | $result .= $n->char; |
96 | - } else { |
|
104 | + } |
|
105 | + else |
|
106 | + { |
|
97 | 107 | break; |
98 | 108 | } |
99 | 109 | } |
@@ -106,12 +116,14 @@ discard block |
||
106 | 116 | */ |
107 | 117 | public function lookahead() |
108 | 118 | { |
109 | - if ($this->replay !== []) { |
|
119 | + if ($this->replay !== []) |
|
120 | + { |
|
110 | 121 | return $this->replay[0]; |
111 | 122 | } |
112 | 123 | |
113 | 124 | $n = $this->next(); |
114 | - if ($n !== null) { |
|
125 | + if ($n !== null) |
|
126 | + { |
|
115 | 127 | array_unshift($this->replay, $n); |
116 | 128 | } |
117 | 129 | |
@@ -128,20 +140,24 @@ discard block |
||
128 | 140 | { |
129 | 141 | $result = ''; |
130 | 142 | $replay = []; |
131 | - for ($i = 0; $i < $size; $i++) { |
|
143 | + for ($i = 0; $i < $size; $i++) |
|
144 | + { |
|
132 | 145 | $n = $this->next(); |
133 | - if ($n !== null) { |
|
146 | + if ($n !== null) |
|
147 | + { |
|
134 | 148 | $replay[] = $n; |
135 | 149 | } |
136 | 150 | |
137 | - if (!$n instanceof Byte) { |
|
151 | + if (!$n instanceof Byte) |
|
152 | + { |
|
138 | 153 | break; |
139 | 154 | } |
140 | 155 | |
141 | 156 | $result .= $n->char; |
142 | 157 | } |
143 | 158 | |
144 | - foreach (array_reverse($replay) as $n) { |
|
159 | + foreach (array_reverse($replay) as $n) |
|
160 | + { |
|
145 | 161 | array_unshift($this->replay, $n); |
146 | 162 | } |
147 | 163 | |
@@ -155,8 +171,10 @@ discard block |
||
155 | 171 | */ |
156 | 172 | public function replay(int $offset): void |
157 | 173 | { |
158 | - foreach ($this->buffer as $n) { |
|
159 | - if ($n->offset > $offset) { |
|
174 | + foreach ($this->buffer as $n) |
|
175 | + { |
|
176 | + if ($n->offset > $offset) |
|
177 | + { |
|
160 | 178 | $this->replay[] = $n; |
161 | 179 | } |
162 | 180 | } |
@@ -51,39 +51,39 @@ discard block |
||
51 | 51 | $this->body = null; |
52 | 52 | $hasWhitespace = false; |
53 | 53 | |
54 | - while ($n = $src->next()) { |
|
55 | - if (!$n instanceof Byte) { |
|
54 | + while ($n = $src->next()){ |
|
55 | + if (!$n instanceof Byte){ |
|
56 | 56 | // no other grammars are allowed |
57 | 57 | break; |
58 | 58 | } |
59 | 59 | |
60 | - switch ($n->char) { |
|
60 | + switch ($n->char){ |
|
61 | 61 | case '(': |
62 | 62 | $this->flushName(); |
63 | 63 | $this->tokens[] = new Token(DynamicGrammar::TYPE_BODY_OPEN, $n->offset, $n->char); |
64 | 64 | |
65 | 65 | return $this->parseBody($src); |
66 | 66 | default: |
67 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
67 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)){ |
|
68 | 68 | $hasWhitespace = true; |
69 | - if ($this->name !== []) { |
|
69 | + if ($this->name !== []){ |
|
70 | 70 | $this->flushName(); |
71 | 71 | $this->tokens[] = new Token(DynamicGrammar::TYPE_WHITESPACE, $n->offset, $n->char); |
72 | 72 | break; |
73 | 73 | } |
74 | 74 | |
75 | - if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE) { |
|
75 | + if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE){ |
|
76 | 76 | $this->getLastToken()->content .= $n->char; |
77 | 77 | break; |
78 | 78 | } |
79 | 79 | |
80 | 80 | // invalid directive |
81 | 81 | return false; |
82 | - } elseif ($hasWhitespace) { |
|
82 | + } elseif ($hasWhitespace){ |
|
83 | 83 | return $this->finalize(); |
84 | 84 | } |
85 | 85 | |
86 | - if (!preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
86 | + if (!preg_match(self::REGEXP_KEYWORD, $n->char)){ |
|
87 | 87 | $this->flushName(); |
88 | 88 | |
89 | 89 | return $this->finalize(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getIterator(): \Traversable |
107 | 107 | { |
108 | - if ($this->tokens === []) { |
|
108 | + if ($this->tokens === []){ |
|
109 | 109 | throw new \LogicException('Directive not parsed'); |
110 | 110 | } |
111 | 111 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getKeyword(): string |
131 | 131 | { |
132 | - foreach ($this->tokens as $token) { |
|
133 | - if ($token->type === DynamicGrammar::TYPE_KEYWORD) { |
|
132 | + foreach ($this->tokens as $token){ |
|
133 | + if ($token->type === DynamicGrammar::TYPE_KEYWORD){ |
|
134 | 134 | return $token->content; |
135 | 135 | } |
136 | 136 | } |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function getBody(): ?string |
147 | 147 | { |
148 | - foreach ($this->tokens as $token) { |
|
149 | - if ($token->type === DynamicGrammar::TYPE_BODY) { |
|
148 | + foreach ($this->tokens as $token){ |
|
149 | + if ($token->type === DynamicGrammar::TYPE_BODY){ |
|
150 | 150 | return $token->content; |
151 | 151 | } |
152 | 152 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | private function flushName(): void |
161 | 161 | { |
162 | - if ($this->name === []) { |
|
162 | + if ($this->name === []){ |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | $this->body = []; |
177 | 177 | $level = 1; |
178 | 178 | |
179 | - while ($nn = $src->next()) { |
|
180 | - if (!$nn instanceof Byte) { |
|
179 | + while ($nn = $src->next()){ |
|
180 | + if (!$nn instanceof Byte){ |
|
181 | 181 | $this->flushBody(); |
182 | 182 | return $this->finalize(); |
183 | 183 | } |
184 | 184 | |
185 | - if (in_array($nn->char, ['"', '"'])) { |
|
185 | + if (in_array($nn->char, ['"', '"'])){ |
|
186 | 186 | $this->body[] = $nn; |
187 | - while ($nnn = $src->next()) { |
|
187 | + while ($nnn = $src->next()){ |
|
188 | 188 | $this->body[] = $nnn; |
189 | - if ($nnn instanceof Byte && $nnn->char === $nn->char) { |
|
189 | + if ($nnn instanceof Byte && $nnn->char === $nn->char){ |
|
190 | 190 | break; |
191 | 191 | } |
192 | 192 | } |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | |
196 | 196 | $this->body[] = $nn; |
197 | 197 | |
198 | - if ($nn->char === '(') { |
|
198 | + if ($nn->char === '('){ |
|
199 | 199 | $level++; |
200 | 200 | continue; |
201 | 201 | } |
202 | 202 | |
203 | - if ($nn->char === ')') { |
|
203 | + if ($nn->char === ')'){ |
|
204 | 204 | $level--; |
205 | 205 | |
206 | - if ($level === 0) { |
|
206 | + if ($level === 0){ |
|
207 | 207 | $n = array_pop($this->body); |
208 | 208 | |
209 | 209 | $this->flushBody(); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | private function flushBody(): void |
226 | 226 | { |
227 | - if ($this->body === []) { |
|
227 | + if ($this->body === []){ |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | private function getLastToken(): Token |
239 | 239 | { |
240 | - if ($this->tokens === []) { |
|
240 | + if ($this->tokens === []){ |
|
241 | 241 | throw new \LogicException('Directive not parsed'); |
242 | 242 | } |
243 | 243 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | { |
254 | 254 | $tokens = $this->tokens; |
255 | 255 | |
256 | - foreach (array_reverse($tokens, true) as $i => $t) { |
|
257 | - if ($t->type !== DynamicGrammar::TYPE_WHITESPACE) { |
|
256 | + foreach (array_reverse($tokens, true) as $i => $t){ |
|
257 | + if ($t->type !== DynamicGrammar::TYPE_WHITESPACE){ |
|
258 | 258 | break; |
259 | 259 | } |
260 | 260 | |
@@ -262,19 +262,19 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | $body = null; |
265 | - foreach ($tokens as $t) { |
|
266 | - if ($t->type === DynamicGrammar::TYPE_BODY_OPEN) { |
|
265 | + foreach ($tokens as $t){ |
|
266 | + if ($t->type === DynamicGrammar::TYPE_BODY_OPEN){ |
|
267 | 267 | $body = false; |
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | |
271 | - if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE) { |
|
271 | + if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE){ |
|
272 | 272 | $body = null; |
273 | 273 | continue; |
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
277 | - if ($body !== null) { |
|
277 | + if ($body !== null){ |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 |
@@ -51,39 +51,48 @@ discard block |
||
51 | 51 | $this->body = null; |
52 | 52 | $hasWhitespace = false; |
53 | 53 | |
54 | - while ($n = $src->next()) { |
|
55 | - if (!$n instanceof Byte) { |
|
54 | + while ($n = $src->next()) |
|
55 | + { |
|
56 | + if (!$n instanceof Byte) |
|
57 | + { |
|
56 | 58 | // no other grammars are allowed |
57 | 59 | break; |
58 | 60 | } |
59 | 61 | |
60 | - switch ($n->char) { |
|
62 | + switch ($n->char) |
|
63 | + { |
|
61 | 64 | case '(': |
62 | 65 | $this->flushName(); |
63 | 66 | $this->tokens[] = new Token(DynamicGrammar::TYPE_BODY_OPEN, $n->offset, $n->char); |
64 | 67 | |
65 | 68 | return $this->parseBody($src); |
66 | 69 | default: |
67 | - if (preg_match(self::REGEXP_WHITESPACE, $n->char)) { |
|
70 | + if (preg_match(self::REGEXP_WHITESPACE, $n->char)) |
|
71 | + { |
|
68 | 72 | $hasWhitespace = true; |
69 | - if ($this->name !== []) { |
|
73 | + if ($this->name !== []) |
|
74 | + { |
|
70 | 75 | $this->flushName(); |
71 | 76 | $this->tokens[] = new Token(DynamicGrammar::TYPE_WHITESPACE, $n->offset, $n->char); |
72 | 77 | break; |
73 | 78 | } |
74 | 79 | |
75 | - if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE) { |
|
80 | + if ($this->getLastToken()->type === DynamicGrammar::TYPE_WHITESPACE) |
|
81 | + { |
|
76 | 82 | $this->getLastToken()->content .= $n->char; |
77 | 83 | break; |
78 | 84 | } |
79 | 85 | |
80 | 86 | // invalid directive |
81 | 87 | return false; |
82 | - } elseif ($hasWhitespace) { |
|
88 | + } |
|
89 | + elseif ($hasWhitespace) |
|
90 | + { |
|
83 | 91 | return $this->finalize(); |
84 | 92 | } |
85 | 93 | |
86 | - if (!preg_match(self::REGEXP_KEYWORD, $n->char)) { |
|
94 | + if (!preg_match(self::REGEXP_KEYWORD, $n->char)) |
|
95 | + { |
|
87 | 96 | $this->flushName(); |
88 | 97 | |
89 | 98 | return $this->finalize(); |
@@ -105,7 +114,8 @@ discard block |
||
105 | 114 | */ |
106 | 115 | public function getIterator(): \Traversable |
107 | 116 | { |
108 | - if ($this->tokens === []) { |
|
117 | + if ($this->tokens === []) |
|
118 | + { |
|
109 | 119 | throw new \LogicException('Directive not parsed'); |
110 | 120 | } |
111 | 121 | |
@@ -129,8 +139,10 @@ discard block |
||
129 | 139 | */ |
130 | 140 | public function getKeyword(): string |
131 | 141 | { |
132 | - foreach ($this->tokens as $token) { |
|
133 | - if ($token->type === DynamicGrammar::TYPE_KEYWORD) { |
|
142 | + foreach ($this->tokens as $token) |
|
143 | + { |
|
144 | + if ($token->type === DynamicGrammar::TYPE_KEYWORD) |
|
145 | + { |
|
134 | 146 | return $token->content; |
135 | 147 | } |
136 | 148 | } |
@@ -145,8 +157,10 @@ discard block |
||
145 | 157 | */ |
146 | 158 | public function getBody(): ?string |
147 | 159 | { |
148 | - foreach ($this->tokens as $token) { |
|
149 | - if ($token->type === DynamicGrammar::TYPE_BODY) { |
|
160 | + foreach ($this->tokens as $token) |
|
161 | + { |
|
162 | + if ($token->type === DynamicGrammar::TYPE_BODY) |
|
163 | + { |
|
150 | 164 | return $token->content; |
151 | 165 | } |
152 | 166 | } |
@@ -159,7 +173,8 @@ discard block |
||
159 | 173 | */ |
160 | 174 | private function flushName(): void |
161 | 175 | { |
162 | - if ($this->name === []) { |
|
176 | + if ($this->name === []) |
|
177 | + { |
|
163 | 178 | return; |
164 | 179 | } |
165 | 180 | |
@@ -176,17 +191,22 @@ discard block |
||
176 | 191 | $this->body = []; |
177 | 192 | $level = 1; |
178 | 193 | |
179 | - while ($nn = $src->next()) { |
|
180 | - if (!$nn instanceof Byte) { |
|
194 | + while ($nn = $src->next()) |
|
195 | + { |
|
196 | + if (!$nn instanceof Byte) |
|
197 | + { |
|
181 | 198 | $this->flushBody(); |
182 | 199 | return $this->finalize(); |
183 | 200 | } |
184 | 201 | |
185 | - if (in_array($nn->char, ['"', '"'])) { |
|
202 | + if (in_array($nn->char, ['"', '"'])) |
|
203 | + { |
|
186 | 204 | $this->body[] = $nn; |
187 | - while ($nnn = $src->next()) { |
|
205 | + while ($nnn = $src->next()) |
|
206 | + { |
|
188 | 207 | $this->body[] = $nnn; |
189 | - if ($nnn instanceof Byte && $nnn->char === $nn->char) { |
|
208 | + if ($nnn instanceof Byte && $nnn->char === $nn->char) |
|
209 | + { |
|
190 | 210 | break; |
191 | 211 | } |
192 | 212 | } |
@@ -195,15 +215,18 @@ discard block |
||
195 | 215 | |
196 | 216 | $this->body[] = $nn; |
197 | 217 | |
198 | - if ($nn->char === '(') { |
|
218 | + if ($nn->char === '(') |
|
219 | + { |
|
199 | 220 | $level++; |
200 | 221 | continue; |
201 | 222 | } |
202 | 223 | |
203 | - if ($nn->char === ')') { |
|
224 | + if ($nn->char === ')') |
|
225 | + { |
|
204 | 226 | $level--; |
205 | 227 | |
206 | - if ($level === 0) { |
|
228 | + if ($level === 0) |
|
229 | + { |
|
207 | 230 | $n = array_pop($this->body); |
208 | 231 | |
209 | 232 | $this->flushBody(); |
@@ -224,7 +247,8 @@ discard block |
||
224 | 247 | */ |
225 | 248 | private function flushBody(): void |
226 | 249 | { |
227 | - if ($this->body === []) { |
|
250 | + if ($this->body === []) |
|
251 | + { |
|
228 | 252 | return; |
229 | 253 | } |
230 | 254 | |
@@ -237,7 +261,8 @@ discard block |
||
237 | 261 | */ |
238 | 262 | private function getLastToken(): Token |
239 | 263 | { |
240 | - if ($this->tokens === []) { |
|
264 | + if ($this->tokens === []) |
|
265 | + { |
|
241 | 266 | throw new \LogicException('Directive not parsed'); |
242 | 267 | } |
243 | 268 | |
@@ -253,8 +278,10 @@ discard block |
||
253 | 278 | { |
254 | 279 | $tokens = $this->tokens; |
255 | 280 | |
256 | - foreach (array_reverse($tokens, true) as $i => $t) { |
|
257 | - if ($t->type !== DynamicGrammar::TYPE_WHITESPACE) { |
|
281 | + foreach (array_reverse($tokens, true) as $i => $t) |
|
282 | + { |
|
283 | + if ($t->type !== DynamicGrammar::TYPE_WHITESPACE) |
|
284 | + { |
|
258 | 285 | break; |
259 | 286 | } |
260 | 287 | |
@@ -262,19 +289,23 @@ discard block |
||
262 | 289 | } |
263 | 290 | |
264 | 291 | $body = null; |
265 | - foreach ($tokens as $t) { |
|
266 | - if ($t->type === DynamicGrammar::TYPE_BODY_OPEN) { |
|
292 | + foreach ($tokens as $t) |
|
293 | + { |
|
294 | + if ($t->type === DynamicGrammar::TYPE_BODY_OPEN) |
|
295 | + { |
|
267 | 296 | $body = false; |
268 | 297 | continue; |
269 | 298 | } |
270 | 299 | |
271 | - if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE) { |
|
300 | + if ($t->type === DynamicGrammar::TYPE_BODY_CLOSE) |
|
301 | + { |
|
272 | 302 | $body = null; |
273 | 303 | continue; |
274 | 304 | } |
275 | 305 | } |
276 | 306 | |
277 | - if ($body !== null) { |
|
307 | + if ($body !== null) |
|
308 | + { |
|
278 | 309 | return false; |
279 | 310 | } |
280 | 311 |