diff --git a/src/EmailLexer.php b/src/EmailLexer.php index a7fdc2d2..4e3383ab 100644 --- a/src/EmailLexer.php +++ b/src/EmailLexer.php @@ -157,9 +157,7 @@ class EmailLexer extends AbstractLexer public function __construct() { - /** @var Token $nullToken */ - $nullToken = new Token('', self::S_EMPTY, 0); - $this->nullToken = $nullToken; + $this->nullToken = new Token('', self::S_EMPTY, 0); $this->current = $this->previous = $this->nullToken; $this->lookahead = null; diff --git a/src/Validation/DNSCheckValidation.php b/src/Validation/DNSCheckValidation.php index 469e87dc..fcfe7db1 100644 --- a/src/Validation/DNSCheckValidation.php +++ b/src/Validation/DNSCheckValidation.php @@ -85,8 +85,9 @@ public function isValid(string $email, EmailLexer $emailLexer): bool // Get the domain parts $hostParts = explode('.', $host); - $isLocalDomain = count($hostParts) <= 1; - $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], self::RESERVED_DNS_TOP_LEVEL_NAMES, true); + $countHostParts = count($hostParts); + $isLocalDomain = $countHostParts <= 1; + $isReservedTopLevel = in_array($hostParts[($countHostParts - 1)], self::RESERVED_DNS_TOP_LEVEL_NAMES, true); // Exclude reserved top level DNS names if ($isLocalDomain || $isReservedTopLevel) {