@@ -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 | } |
@@ -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 | |
@@ -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 | } |
@@ -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 | |