@@ -314,8 +314,7 @@ discard block |
||
| 314 | 314 | return; |
| 315 | 315 | } elseif($this->multiLineOpened && $ord === AsciiChar::LINE_FEED) { |
| 316 | 316 | goto start; |
| 317 | - } |
|
| 318 | - elseif(!$this->commentOpen) { |
|
| 317 | + } elseif(!$this->commentOpen) { |
|
| 319 | 318 | // Double quotes aren't required to start a string, but if they start the string then they must also end the string |
| 320 | 319 | if($ord !== AsciiChar::DOUBLE_QUOTES) { |
| 321 | 320 | $this->stream->previous(); |
@@ -352,8 +351,7 @@ discard block |
||
| 352 | 351 | if($this->txtRecordHasQuotes) { |
| 353 | 352 | $this->stream->previous(); |
| 354 | 353 | throw new SyntaxErrorException($this->stream); |
| 355 | - } |
|
| 356 | - else { |
|
| 354 | + } else { |
|
| 357 | 355 | return; |
| 358 | 356 | } |
| 359 | 357 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function __construct(StringStream $stream, string $type) |
| 108 | 108 | { |
| 109 | - if (! self::isKnownType($type)) { |
|
| 109 | + if (!self::isKnownType($type)) { |
|
| 110 | 110 | throw new SyntaxErrorException($stream); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | protected function defaultExtractor(string $tokenName) |
| 144 | 144 | { |
| 145 | - if($this->multiLineOpened) { |
|
| 145 | + if ($this->multiLineOpened) { |
|
| 146 | 146 | $this->stream->ignoreWhitespace(); |
| 147 | 147 | } else { |
| 148 | 148 | $this->stream->ignoreHorizontalSpace(); |
@@ -156,28 +156,28 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | start: |
| 158 | 158 | |
| 159 | - if ($this->stream->isEnd()){ |
|
| 159 | + if ($this->stream->isEnd()) { |
|
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | $ord = $this->stream->ord(); |
| 163 | 163 | |
| 164 | - if($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
| 164 | + if ($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
| 165 | 165 | $this->multiLineOpened = true; |
| 166 | 166 | $this->stream->next(); |
| 167 | 167 | goto start; |
| 168 | - } elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
| 168 | + } elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
| 169 | 169 | $this->multiLineOpened = false; |
| 170 | 170 | $this->stream->next(); |
| 171 | 171 | goto start; |
| 172 | - } elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::LINE_FEED) { |
|
| 172 | + } elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::LINE_FEED) { |
|
| 173 | 173 | $this->stream->next(); |
| 174 | 174 | goto start; |
| 175 | - } elseif($ord === AsciiChar::LINE_FEED && !$this->commentOpen) { |
|
| 175 | + } elseif ($ord === AsciiChar::LINE_FEED && !$this->commentOpen) { |
|
| 176 | 176 | return; |
| 177 | 177 | } else { |
| 178 | - if($ord === AsciiChar::SEMICOLON) { |
|
| 178 | + if ($ord === AsciiChar::SEMICOLON) { |
|
| 179 | 179 | $this->stream->previous(); |
| 180 | - if($this->stream->currentAscii()->isHorizontalSpace()) { |
|
| 180 | + if ($this->stream->currentAscii()->isHorizontalSpace()) { |
|
| 181 | 181 | |
| 182 | 182 | $this->commentOpen = true; |
| 183 | 183 | $this->stream->next(); |
@@ -188,25 +188,25 @@ discard block |
||
| 188 | 188 | $this->stream->next(); |
| 189 | 189 | } |
| 190 | 190 | goto start; |
| 191 | - } elseif(($this->stream->currentAscii()->isVerticalSpace() || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
| 191 | + } elseif (($this->stream->currentAscii()->isVerticalSpace() || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
| 192 | 192 | $this->stream->next(); |
| 193 | 193 | $this->stream->ignoreHorizontalSpace(); |
| 194 | 194 | $this->commentOpen = false; |
| 195 | 195 | goto start; |
| 196 | - } elseif($this->commentOpen) { |
|
| 196 | + } elseif ($this->commentOpen) { |
|
| 197 | 197 | $this->commentOpen = true; |
| 198 | 198 | $this->ignoreComment(); |
| 199 | 199 | goto start; |
| 200 | - } elseif(!$this->commentOpen) { |
|
| 201 | - if($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === '') { |
|
| 200 | + } elseif (!$this->commentOpen) { |
|
| 201 | + if ($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === '') { |
|
| 202 | 202 | $this->stream->next(); |
| 203 | 203 | goto start; |
| 204 | - } elseif($this->stream->currentAscii()->isWhiteSpace()) { |
|
| 204 | + } elseif ($this->stream->currentAscii()->isWhiteSpace()) { |
|
| 205 | 205 | return; |
| 206 | 206 | } else { |
| 207 | 207 | $this->tokens[$tokenName] .= $this->stream->current(); |
| 208 | 208 | $this->stream->next(); |
| 209 | - if($this->stream->isEnd()) { |
|
| 209 | + if ($this->stream->isEnd()) { |
|
| 210 | 210 | $this->tokens[$tokenName] = trim($this->tokens[$tokenName]); |
| 211 | 211 | } |
| 212 | 212 | goto start; |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | return; |
| 232 | 232 | } |
| 233 | 233 | $ord = $this->stream->ord(); |
| 234 | - if($ord === AsciiChar::SEMICOLON) { |
|
| 234 | + if ($ord === AsciiChar::SEMICOLON) { |
|
| 235 | 235 | $this->stream->next(); |
| 236 | 236 | $this->commentOpen = true; |
| 237 | 237 | goto start; |
| 238 | - } elseif($this->commentOpen) { |
|
| 239 | - if($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 238 | + } elseif ($this->commentOpen) { |
|
| 239 | + if ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 240 | 240 | $this->commentOpen = false; |
| 241 | 241 | goto start; |
| 242 | 242 | } else { |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | $this->commentOpen = true; |
| 245 | 245 | goto start; |
| 246 | 246 | } |
| 247 | - } elseif(!$this->commentOpen) { |
|
| 248 | - if($this->multiLineOpened) { |
|
| 249 | - if($ord === AsciiChar::CLOSE_BRACKET) { |
|
| 247 | + } elseif (!$this->commentOpen) { |
|
| 248 | + if ($this->multiLineOpened) { |
|
| 249 | + if ($ord === AsciiChar::CLOSE_BRACKET) { |
|
| 250 | 250 | $this->multiLineOpened = false; |
| 251 | 251 | } |
| 252 | 252 | $this->stream->next(); |
| 253 | 253 | goto start; |
| 254 | - } elseif($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 254 | + } elseif ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 255 | 255 | return; |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -274,45 +274,45 @@ discard block |
||
| 274 | 274 | $this->stream->next(); |
| 275 | 275 | |
| 276 | 276 | // comment starts |
| 277 | - if($ord === AsciiChar::SEMICOLON) { |
|
| 277 | + if ($ord === AsciiChar::SEMICOLON) { |
|
| 278 | 278 | $this->commentOpen = true; |
| 279 | 279 | goto start; |
| 280 | - } elseif($this->commentOpen === true && $ord !== AsciiChar::LINE_FEED) { |
|
| 280 | + } elseif ($this->commentOpen === true && $ord !== AsciiChar::LINE_FEED) { |
|
| 281 | 281 | $this->commentOpen = true; |
| 282 | 282 | goto start; |
| 283 | - } elseif($this->commentOpen === true && ($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL)) { |
|
| 283 | + } elseif ($this->commentOpen === true && ($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL)) { |
|
| 284 | 284 | $this->stream->previous(); |
| 285 | 285 | $this->commentOpen = false; |
| 286 | 286 | goto start; |
| 287 | 287 | } else { |
| 288 | 288 | // ignore whitespace |
| 289 | - if($ord === AsciiChar::SPACE || $ord === AsciiChar::HORIZONTAL_TAB) { |
|
| 289 | + if ($ord === AsciiChar::SPACE || $ord === AsciiChar::HORIZONTAL_TAB) { |
|
| 290 | 290 | goto start; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // multi line opened |
| 294 | - if($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
| 294 | + if ($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
| 295 | 295 | $this->multiLineOpened = true; |
| 296 | 296 | goto start; |
| 297 | 297 | } |
| 298 | 298 | // multi line closed |
| 299 | - elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
| 299 | + elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
| 300 | 300 | $this->multiLineOpened = false; |
| 301 | 301 | goto start; |
| 302 | 302 | } |
| 303 | 303 | // comment end in multi line TXT record |
| 304 | - elseif($ord === AsciiChar::LINE_FEED && $this->commentOpen && $this->multiLineOpened) { |
|
| 304 | + elseif ($ord === AsciiChar::LINE_FEED && $this->commentOpen && $this->multiLineOpened) { |
|
| 305 | 305 | goto start; |
| 306 | 306 | } |
| 307 | 307 | // is record ends? |
| 308 | - elseif(!$this->multiLineOpened && ($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL)) { |
|
| 308 | + elseif (!$this->multiLineOpened && ($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL)) { |
|
| 309 | 309 | return; |
| 310 | - } elseif($this->multiLineOpened && $ord === AsciiChar::LINE_FEED) { |
|
| 310 | + } elseif ($this->multiLineOpened && $ord === AsciiChar::LINE_FEED) { |
|
| 311 | 311 | goto start; |
| 312 | 312 | } |
| 313 | - elseif(!$this->commentOpen) { |
|
| 313 | + elseif (!$this->commentOpen) { |
|
| 314 | 314 | // Double quotes aren't required to start a string, but if they start the string then they must also end the string |
| 315 | - if($ord !== AsciiChar::DOUBLE_QUOTES) { |
|
| 315 | + if ($ord !== AsciiChar::DOUBLE_QUOTES) { |
|
| 316 | 316 | $this->stream->previous(); |
| 317 | 317 | $this->txtRecordHasQuotes = false; |
| 318 | 318 | } else { |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // multi line should no longer be open |
| 326 | - if($this->multiLineOpened) { |
|
| 326 | + if ($this->multiLineOpened) { |
|
| 327 | 327 | throw new SyntaxErrorException($this->stream); |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | $ord = $this->stream->ord(); |
| 342 | 342 | $this->stream->next(); |
| 343 | 343 | |
| 344 | - if(!$escaping_open && $this->txtRecordHasQuotes && $ord === AsciiChar::DOUBLE_QUOTES) { |
|
| 344 | + if (!$escaping_open && $this->txtRecordHasQuotes && $ord === AsciiChar::DOUBLE_QUOTES) { |
|
| 345 | 345 | $this->txtExtractor($tokenName); |
| 346 | - } elseif(!$escaping_open && !$this->txtRecordHasQuotes && $ord === AsciiChar::SPACE) { |
|
| 346 | + } elseif (!$escaping_open && !$this->txtRecordHasQuotes && $ord === AsciiChar::SPACE) { |
|
| 347 | 347 | // If there aren't quotes around a character string, a space terminates the string |
| 348 | 348 | return; |
| 349 | 349 | } else { |
| 350 | - if($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::VERTICAL_TAB || $ord === AsciiChar::NULL) { |
|
| 351 | - if($this->txtRecordHasQuotes) { |
|
| 350 | + if ($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::VERTICAL_TAB || $ord === AsciiChar::NULL) { |
|
| 351 | + if ($this->txtRecordHasQuotes) { |
|
| 352 | 352 | $this->stream->previous(); |
| 353 | 353 | throw new SyntaxErrorException($this->stream); |
| 354 | 354 | } |