@@ -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 | } |
@@ -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 { |
@@ -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,19 +170,19 @@ discard block |
||
| 170 | 170 | $this->stream->next(); |
| 171 | 171 | } |
| 172 | 172 | goto start; |
| 173 | - } elseif(($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
| 173 | + } elseif (($ord === AsciiChar::LINE_FEED || $ord === AsciiChar::NULL) && $this->commentOpen) { |
|
| 174 | 174 | $this->stream->next(); |
| 175 | 175 | $this->commentOpen = false; |
| 176 | 176 | goto start; |
| 177 | - } elseif($this->commentOpen) { |
|
| 177 | + } elseif ($this->commentOpen) { |
|
| 178 | 178 | $this->commentOpen = true; |
| 179 | 179 | $this->stream->next(); |
| 180 | 180 | goto start; |
| 181 | - } elseif(!$this->commentOpen) { |
|
| 182 | - if($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === "") { |
|
| 181 | + } elseif (!$this->commentOpen) { |
|
| 182 | + if ($ord === AsciiChar::SPACE && $this->tokens[$tokenName] === "") { |
|
| 183 | 183 | $this->stream->next(); |
| 184 | 184 | goto start; |
| 185 | - } elseif($this->stream->currentAscii()->isHorizontalSpace()) { |
|
| 185 | + } elseif ($this->stream->currentAscii()->isHorizontalSpace()) { |
|
| 186 | 186 | return; |
| 187 | 187 | } else { |
| 188 | 188 | $this->tokens[$tokenName] .= $this->stream->current(); |
@@ -197,15 +197,15 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | start: |
| 199 | 199 | $ord = $this->stream->ord(); |
| 200 | - if($ord == AsciiChar::NULL) { |
|
| 200 | + if ($ord == AsciiChar::NULL) { |
|
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | - if($ord === AsciiChar::SEMICOLON) { |
|
| 203 | + if ($ord === AsciiChar::SEMICOLON) { |
|
| 204 | 204 | $this->stream->next(); |
| 205 | 205 | $this->commentOpen = true; |
| 206 | 206 | goto start; |
| 207 | - } elseif($this->commentOpen) { |
|
| 208 | - if($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 207 | + } elseif ($this->commentOpen) { |
|
| 208 | + if ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 209 | 209 | $this->commentOpen = false; |
| 210 | 210 | goto start; |
| 211 | 211 | } else { |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | $this->commentOpen = true; |
| 214 | 214 | goto start; |
| 215 | 215 | } |
| 216 | - } elseif(!$this->commentOpen) { |
|
| 217 | - if($this->multiLineOpened) { |
|
| 218 | - if($ord === AsciiChar::CLOSE_BRACKET) { |
|
| 216 | + } elseif (!$this->commentOpen) { |
|
| 217 | + if ($this->multiLineOpened) { |
|
| 218 | + if ($ord === AsciiChar::CLOSE_BRACKET) { |
|
| 219 | 219 | $this->multiLineOpened = false; |
| 220 | 220 | } |
| 221 | 221 | $this->stream->next(); |
| 222 | 222 | goto start; |
| 223 | - } elseif($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 223 | + } elseif ($ord === AsciiChar::NULL() || $ord === AsciiChar::LINE_FEED) { |
|
| 224 | 224 | return; |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -239,53 +239,53 @@ discard block |
||
| 239 | 239 | $ord = $this->stream->ord(); |
| 240 | 240 | $this->stream->next(); |
| 241 | 241 | |
| 242 | - if($ord == 0) { // if end of record |
|
| 242 | + if ($ord == 0) { // if end of record |
|
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // comment starts |
| 247 | - if($ord === 59) { |
|
| 247 | + if ($ord === 59) { |
|
| 248 | 248 | $this->commentOpen = true; |
| 249 | 249 | goto start; |
| 250 | - } elseif($this->commentOpen == true && $ord !== 10) { |
|
| 250 | + } elseif ($this->commentOpen == true && $ord !== 10) { |
|
| 251 | 251 | $this->commentOpen = true; |
| 252 | 252 | goto start; |
| 253 | - } elseif($this->commentOpen == true && ($ord === 10 || $ord === 0)) { |
|
| 253 | + } elseif ($this->commentOpen == true && ($ord === 10 || $ord === 0)) { |
|
| 254 | 254 | $this->stream->previous(); |
| 255 | 255 | $this->commentOpen = false; |
| 256 | 256 | goto start; |
| 257 | 257 | } else { |
| 258 | 258 | // ignore blanck line |
| 259 | - if($ord === 32) { |
|
| 259 | + if ($ord === 32) { |
|
| 260 | 260 | goto start; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // Find starts of char set |
| 264 | - if($ord === 34 && !$this->commentOpen) { // " |
|
| 264 | + if ($ord === 34 && !$this->commentOpen) { // " |
|
| 265 | 265 | $this->extractCharSet($tokenName); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // multi line opened |
| 269 | - if($ord === 40 && !$this->commentOpen) { |
|
| 269 | + if ($ord === 40 && !$this->commentOpen) { |
|
| 270 | 270 | $this->multiLineOpened = true; |
| 271 | 271 | goto start; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // multi line closed |
| 275 | - if($this->multiLineOpened && !$this->commentOpen && $ord === 41) { |
|
| 275 | + if ($this->multiLineOpened && !$this->commentOpen && $ord === 41) { |
|
| 276 | 276 | $this->multiLineOpened = false; |
| 277 | 277 | goto start; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // comment end in multi line TXT record |
| 281 | - if($ord === 10 && $this->commentOpen && $this->multiLineOpened) { |
|
| 281 | + if ($ord === 10 && $this->commentOpen && $this->multiLineOpened) { |
|
| 282 | 282 | goto start; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // is record ends? |
| 286 | - if(!$this->multiLineOpened && ($ord === 10 || $ord === 0)) { |
|
| 286 | + if (!$this->multiLineOpened && ($ord === 10 || $ord === 0)) { |
|
| 287 | 287 | return; |
| 288 | - } elseif($this->multiLineOpened && $ord === 10) { |
|
| 288 | + } elseif ($this->multiLineOpened && $ord === 10) { |
|
| 289 | 289 | goto start; |
| 290 | 290 | } |
| 291 | 291 | } |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | $ord = $this->stream->ord(); |
| 302 | 302 | $this->stream->next(); |
| 303 | 303 | |
| 304 | - if($ord == 0) { // if end of record |
|
| 304 | + if ($ord == 0) { // if end of record |
|
| 305 | 305 | return; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if(!$escaping_open && $ord === 34) { |
|
| 308 | + if (!$escaping_open && $ord === 34) { |
|
| 309 | 309 | $this->txtExtractor($tokenName); |
| 310 | 310 | } else { |
| 311 | 311 | $this->tokens[$tokenName] .= chr($ord); |