@@ -147,7 +147,7 @@ |
||
147 | 147 | private function extractRecord() |
148 | 148 | { |
149 | 149 | $isFirst = $this->recordsAmmount === 0; |
150 | - if(! $isFirst ) { |
|
150 | + if (!$isFirst) { |
|
151 | 151 | $lastParsedRecord = end($this->tokens); |
152 | 152 | $previousName = $lastParsedRecord['NAME']; |
153 | 153 | } else { |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * @param bool $isFirst |
54 | 54 | * @param string $previousName |
55 | 55 | */ |
56 | - public function __construct |
|
57 | - ( |
|
56 | + public function __construct( |
|
58 | 57 | StringStream $stream, |
59 | 58 | string $globalOrigin = NULL, |
60 | 59 | string $globalTtl = NULL, |
@@ -112,8 +111,8 @@ discard block |
||
112 | 111 | $this->stream->ignoreHorizontalSpace(); |
113 | 112 | $this->extractRData(); |
114 | 113 | |
115 | - if($this->globalOrigin && substr($this->tokens['NAME'], -1) !== '.' && $this->tokens['NAME'] !== '@') { |
|
116 | - if($this->globalOrigin === '.') { |
|
114 | + if ($this->globalOrigin && substr($this->tokens['NAME'], -1) !== '.' && $this->tokens['NAME'] !== '@') { |
|
115 | + if ($this->globalOrigin === '.') { |
|
117 | 116 | $this->tokens['NAME'] .= $this->globalOrigin; |
118 | 117 | } else { |
119 | 118 | $this->tokens['NAME'] .= '.'.$this->globalOrigin; |
@@ -179,33 +178,33 @@ discard block |
||
179 | 178 | throw new SyntaxErrorException($this->stream); |
180 | 179 | } |
181 | 180 | } else { |
182 | - if($this->isFirst) { |
|
181 | + if ($this->isFirst) { |
|
183 | 182 | throw new SyntaxErrorException($this->stream); |
184 | 183 | } else { |
185 | - if(RData::isKnownType($this->tokens['NAME']) && ! RData::isKnownType($this->tokens['TTL'])) { |
|
184 | + if (RData::isKnownType($this->tokens['NAME']) && !RData::isKnownType($this->tokens['TTL'])) { |
|
186 | 185 | // no ttl and no origin in record, and in TTL Rdata |
187 | 186 | last_chance: |
188 | - if($this->previousName && $this->globalTtl) { |
|
187 | + if ($this->previousName && $this->globalTtl) { |
|
189 | 188 | $this->tokens['TYPE'] = $this->tokens['NAME']; |
190 | 189 | $this->tokens['NAME'] = $this->previousName; |
191 | 190 | $this->tokens['TTL'] = $this->globalTtl; |
192 | 191 | } else { |
193 | 192 | throw new SyntaxErrorException($this->stream); |
194 | 193 | } |
195 | - } elseif(!RData::isKnownType($this->tokens['NAME']) && RData::isKnownType($this->tokens['TTL'])) { |
|
194 | + } elseif (!RData::isKnownType($this->tokens['NAME']) && RData::isKnownType($this->tokens['TTL'])) { |
|
196 | 195 | $this->tokens['TYPE'] = $this->tokens['TTL']; |
197 | - if($this->previousName && ! $this->globalTtl) { |
|
198 | - $this->tokens['TTL'] = $this->tokens['NAME']; |
|
196 | + if ($this->previousName && !$this->globalTtl) { |
|
197 | + $this->tokens['TTL'] = $this->tokens['NAME']; |
|
199 | 198 | $this->tokens['NAME'] = $this->previousName; |
200 | - } elseif(! $this->previousName && $this->globalTtl) { |
|
201 | - $this->tokens['TTL'] = $this->globalTtl; |
|
202 | - } elseif($this->previousName && $this->globalTtl) { |
|
199 | + } elseif (!$this->previousName && $this->globalTtl) { |
|
200 | + $this->tokens['TTL'] = $this->globalTtl; |
|
201 | + } elseif ($this->previousName && $this->globalTtl) { |
|
203 | 202 | $this->tokens['TTL'] = $this->globalTtl; |
204 | 203 | } else { |
205 | 204 | throw new SyntaxErrorException($this->stream); |
206 | 205 | } |
207 | 206 | |
208 | - } elseif(RData::isKnownType($this->tokens['NAME']) && RData::isKnownType($this->tokens['TTL'])) { |
|
207 | + } elseif (RData::isKnownType($this->tokens['NAME']) && RData::isKnownType($this->tokens['TTL'])) { |
|
209 | 208 | goto last_chance; |
210 | 209 | } else { |
211 | 210 | throw new SyntaxErrorException($this->stream); |
@@ -214,12 +213,12 @@ discard block |
||
214 | 213 | do { |
215 | 214 | $char = $this->stream->currentAscii(); |
216 | 215 | $this->stream->previous(); |
217 | - } while($char->isWhiteSpace()); |
|
216 | + } while ($char->isWhiteSpace()); |
|
218 | 217 | |
219 | 218 | do { |
220 | 219 | $char = $this->stream->currentAscii(); |
221 | 220 | $this->stream->previous(); |
222 | - } while($char->isPrintableChar() && ! $char->isHorizontalSpace()); |
|
221 | + } while ($char->isPrintableChar() && !$char->isHorizontalSpace()); |
|
223 | 222 | } |
224 | 223 | } |
225 | 224 | } |
@@ -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(!$this->txtRecordHasQuotes && $ord === AsciiChar::SPACE) { |
|
346 | + } elseif (!$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 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $this->tokens[$tokenName] .= chr($ord); |
361 | 361 | |
362 | 362 | // Escaping open is only set for one iteration so that it doesn't break on double slashes ie. \\ |
363 | - if($ord === AsciiChar::BACKSLASH) { |
|
363 | + if ($ord === AsciiChar::BACKSLASH) { |
|
364 | 364 | $escaping_open = true; |
365 | 365 | } else { |
366 | 366 | $escaping_open = false; |