@@ -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 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct(StringStream $stream, string $type) |
89 | 89 | { |
90 | - if (! self::isKnownType($type)) { |
|
90 | + if (!self::isKnownType($type)) { |
|
91 | 91 | throw new SyntaxErrorException($stream); |
92 | 92 | } |
93 | 93 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function defaultExtractor(string $tokenName) |
125 | 125 | { |
126 | - if($this->multiLineOpened) { |
|
126 | + if ($this->multiLineOpened) { |
|
127 | 127 | $this->stream->ignoreWhitespace(); |
128 | 128 | } else { |
129 | 129 | $this->stream->ignoreHorizontalSpace(); |
@@ -139,27 +139,27 @@ discard block |
||
139 | 139 | |
140 | 140 | $ord = $this->stream->ord(); |
141 | 141 | |
142 | - if($ord === AsciiChar::NULL) { |
|
142 | + if ($ord === AsciiChar::NULL) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
146 | - if($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
146 | + if ($ord === AsciiChar::OPEN_BRACKET && !$this->commentOpen) { |
|
147 | 147 | $this->multiLineOpened = true; |
148 | 148 | $this->stream->next(); |
149 | 149 | goto start; |
150 | - } elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
150 | + } elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::CLOSE_BRACKET) { |
|
151 | 151 | $this->multiLineOpened = false; |
152 | 152 | $this->stream->next(); |
153 | 153 | goto start; |
154 | - } elseif($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::LINE_FEED) { |
|
154 | + } elseif ($this->multiLineOpened && !$this->commentOpen && $ord === AsciiChar::LINE_FEED) { |
|
155 | 155 | $this->stream->next(); |
156 | 156 | goto start; |
157 | - } elseif($ord === AsciiChar::LINE_FEED && !$this->commentOpen) { |
|
157 | + } elseif ($ord === AsciiChar::LINE_FEED && !$this->commentOpen) { |
|
158 | 158 | return; |
159 | 159 | } else { |
160 | - if($ord === AsciiChar::SEMICOLON) { |
|
160 | + if ($ord === AsciiChar::SEMICOLON) { |
|
161 | 161 | $this->stream->previous(); |
162 | - if($this->stream->currentAscii()->isHorizontalSpace()) { |
|
162 | + if ($this->stream->currentAscii()->isHorizontalSpace()) { |
|
163 | 163 | |
164 | 164 | $this->commentOpen = true; |
165 | 165 | $this->stream->next(); |
@@ -170,25 +170,25 @@ discard block |
||
170 | 170 | $this->stream->next(); |
171 | 171 | } |
172 | 172 | goto start; |
173 | - } elseif(($this->stream->currentAscii()->isVerticalSpace() || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
173 | + } elseif (($this->stream->currentAscii()->isVerticalSpace() || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
174 | 174 | $this->stream->next(); |
175 | 175 | $this->stream->ignoreHorizontalSpace(); |
176 | 176 | $this->commentOpen = false; |
177 | 177 | goto start; |
178 | - } elseif($this->commentOpen) { |
|
178 | + } elseif ($this->commentOpen) { |
|
179 | 179 | $this->commentOpen = true; |
180 | 180 | $this->ignoreComment(); |
181 | 181 | goto start; |
182 | - } elseif(!$this->commentOpen) { |
|
183 | - if($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === '') { |
|
182 | + } elseif (!$this->commentOpen) { |
|
183 | + if ($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === '') { |
|
184 | 184 | $this->stream->next(); |
185 | 185 | goto start; |
186 | - } elseif($this->stream->currentAscii()->isWhiteSpace()) { |
|
186 | + } elseif ($this->stream->currentAscii()->isWhiteSpace()) { |
|
187 | 187 | return; |
188 | 188 | } else { |
189 | 189 | $this->tokens[$tokenName] .= $this->stream->current(); |
190 | 190 | $this->stream->next(); |
191 | - if($this->stream->isEnd()) { |
|
191 | + if ($this->stream->isEnd()) { |
|
192 | 192 | $this->tokens[$tokenName] = trim($this->tokens[$tokenName]); |
193 | 193 | } |
194 | 194 | goto start; |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | { |
211 | 211 | start: |
212 | 212 | $ord = $this->stream->ord(); |
213 | - if($ord === AsciiChar::NULL) { |
|
213 | + if ($ord === AsciiChar::NULL) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | - if($ord === AsciiChar::SEMICOLON) { |
|
216 | + if ($ord === AsciiChar::SEMICOLON) { |
|
217 | 217 | $this->stream->next(); |
218 | 218 | $this->commentOpen = true; |
219 | 219 | goto start; |
220 | - } elseif($this->commentOpen) { |
|
221 | - if($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
220 | + } elseif ($this->commentOpen) { |
|
221 | + if ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
222 | 222 | $this->commentOpen = false; |
223 | 223 | goto start; |
224 | 224 | } else { |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | $this->commentOpen = true; |
227 | 227 | goto start; |
228 | 228 | } |
229 | - } elseif(!$this->commentOpen) { |
|
230 | - if($this->multiLineOpened) { |
|
231 | - if($ord === AsciiChar::CLOSE_BRACKET) { |
|
229 | + } elseif (!$this->commentOpen) { |
|
230 | + if ($this->multiLineOpened) { |
|
231 | + if ($ord === AsciiChar::CLOSE_BRACKET) { |
|
232 | 232 | $this->multiLineOpened = false; |
233 | 233 | } |
234 | 234 | $this->stream->next(); |
235 | 235 | goto start; |
236 | - } elseif($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
236 | + } elseif ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | } |
@@ -252,53 +252,53 @@ discard block |
||
252 | 252 | $ord = $this->stream->ord(); |
253 | 253 | $this->stream->next(); |
254 | 254 | |
255 | - if($ord === 0) { // if end of record |
|
255 | + if ($ord === 0) { // if end of record |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | // comment starts |
260 | - if($ord === 59) { |
|
260 | + if ($ord === 59) { |
|
261 | 261 | $this->commentOpen = true; |
262 | 262 | goto start; |
263 | - } elseif($this->commentOpen === true && $ord !== 10) { |
|
263 | + } elseif ($this->commentOpen === true && $ord !== 10) { |
|
264 | 264 | $this->commentOpen = true; |
265 | 265 | goto start; |
266 | - } elseif($this->commentOpen === true && ($ord === 10 || $ord === 0)) { |
|
266 | + } elseif ($this->commentOpen === true && ($ord === 10 || $ord === 0)) { |
|
267 | 267 | $this->stream->previous(); |
268 | 268 | $this->commentOpen = false; |
269 | 269 | goto start; |
270 | 270 | } else { |
271 | 271 | // ignore blanck line |
272 | - if($ord === 32) { |
|
272 | + if ($ord === 32) { |
|
273 | 273 | goto start; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Find starts of char set |
277 | - if($ord === 34 && !$this->commentOpen) { // " |
|
277 | + if ($ord === 34 && !$this->commentOpen) { // " |
|
278 | 278 | $this->extractCharSet($tokenName); |
279 | 279 | } |
280 | 280 | |
281 | 281 | // multi line opened |
282 | - if($ord === 40 && !$this->commentOpen) { |
|
282 | + if ($ord === 40 && !$this->commentOpen) { |
|
283 | 283 | $this->multiLineOpened = true; |
284 | 284 | goto start; |
285 | 285 | } |
286 | 286 | |
287 | 287 | // multi line closed |
288 | - if($this->multiLineOpened && !$this->commentOpen && $ord === 41) { |
|
288 | + if ($this->multiLineOpened && !$this->commentOpen && $ord === 41) { |
|
289 | 289 | $this->multiLineOpened = false; |
290 | 290 | goto start; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // comment end in multi line TXT record |
294 | - if($ord === 10 && $this->commentOpen && $this->multiLineOpened) { |
|
294 | + if ($ord === 10 && $this->commentOpen && $this->multiLineOpened) { |
|
295 | 295 | goto start; |
296 | 296 | } |
297 | 297 | |
298 | 298 | // is record ends? |
299 | - if(!$this->multiLineOpened && ($ord === 10 || $ord === 0)) { |
|
299 | + if (!$this->multiLineOpened && ($ord === 10 || $ord === 0)) { |
|
300 | 300 | return; |
301 | - } elseif($this->multiLineOpened && $ord === 10) { |
|
301 | + } elseif ($this->multiLineOpened && $ord === 10) { |
|
302 | 302 | goto start; |
303 | 303 | } |
304 | 304 | } |
@@ -314,14 +314,14 @@ discard block |
||
314 | 314 | $ord = $this->stream->ord(); |
315 | 315 | $this->stream->next(); |
316 | 316 | |
317 | - if($ord === AsciiChar::NULL) { // if end of record |
|
317 | + if ($ord === AsciiChar::NULL) { // if end of record |
|
318 | 318 | throw new SyntaxErrorException($this->stream); |
319 | 319 | } |
320 | 320 | |
321 | - if(!$escaping_open && $ord === 34) { |
|
321 | + if (!$escaping_open && $ord === 34) { |
|
322 | 322 | $this->txtExtractor($tokenName); |
323 | 323 | } else { |
324 | - if($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::VERTICAL_TAB || $ord === AsciiChar::NULL) { |
|
324 | + if ($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::VERTICAL_TAB || $ord === AsciiChar::NULL) { |
|
325 | 325 | $this->stream->previous(); |
326 | 326 | throw new SyntaxErrorException($this->stream); |
327 | 327 | } |