Skip to content

Commit 6e150ab

Browse files
committed
Apply feedbacks
1 parent 86933da commit 6e150ab

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src/EmailLexer.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,30 +133,23 @@ class EmailLexer extends AbstractLexer
133133

134134
/**
135135
* @var Token
136-
*
137-
* @psalm-var array{value:string, type:null|int, position:int}|array<empty, empty>
138136
*/
139137
protected $previous = null;
140138

141139
/**
142140
* The last matched/seen token.
143141
*
144-
* @var object
145-
*
146-
* @psalm-suppress NonInvariantDocblockPropertyType
147-
* @psalm-var array{value:string, type:null|int, position:int}
148-
* @psalm-suppress NonInvariantDocblockPropertyType
142+
* @var Token
149143
*/
150144
public $token;
151145

152146
/**
153147
* The next token in the input.
154148
*
155-
* @var array{position: int, type: int|null|string, value: int|string}|null
149+
* @var Token|null
156150
*/
157151
public $lookahead;
158152

159-
/** @psalm-var array{value:'', type:null, position:0} */
160153
private $nullToken = null;
161154

162155
/** @var string */
@@ -283,9 +276,9 @@ public function hasInvalidTokens(): bool
283276
/**
284277
* getPrevious
285278
*
286-
* @return object
279+
* @return Token
287280
*/
288-
public function getPrevious(): object
281+
public function getPrevious(): Token
289282
{
290283
return $this->previous;
291284
}

src/Parser/DomainPart.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Egulias\EmailValidator\Parser;
44

5+
use Doctrine\Common\Lexer\Token;
56
use Egulias\EmailValidator\EmailLexer;
67
use Egulias\EmailValidator\Warning\TLD;
78
use Egulias\EmailValidator\Result\Result;
@@ -81,11 +82,11 @@ private function checkEndOfDomain(): Result
8182
return new InvalidEmail(new DotAtEnd(), $this->lexer->token->value);
8283
}
8384
if ($prev->isA(EmailLexer::S_HYPHEN)) {
84-
return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev['value']);
85+
return new InvalidEmail(new DomainHyphened('Hypen found at the end of the domain'), $prev->value);
8586
}
8687

8788
if ($this->lexer->token->isA(EmailLexer::S_SP)) {
88-
return new InvalidEmail(new CRLFAtTheEnd(), $prev['value']);
89+
return new InvalidEmail(new CRLFAtTheEnd(), $prev->value);
8990
}
9091
return new ValidEmail();
9192
}
@@ -212,7 +213,7 @@ protected function doParseDomainPart(): Result
212213
return new ValidEmail();
213214
}
214215

215-
private function checkNotAllowedChars(object $token): Result
216+
private function checkNotAllowedChars(Token $token): Result
216217
{
217218
$notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH => true];
218219
if (isset($notAllowed[$token->type])) {
@@ -238,7 +239,7 @@ protected function parseDomainLiteral(): Result
238239
return $result;
239240
}
240241

241-
protected function checkDomainPartExceptions(object $prev, bool $hasComments): Result
242+
protected function checkDomainPartExceptions(Token $prev, bool $hasComments): Result
242243
{
243244
if ($this->lexer->token->isA(EmailLexer::S_OPENBRACKET) && $prev->type !== EmailLexer::S_AT) {
244245
return new InvalidEmail(new ExpectingATEXT('OPENBRACKET not after AT'), $this->lexer->token->value);

src/Validation/DNSCheckValidation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private function validateMxRecord($dnsRecord): bool
179179
}
180180

181181
// "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505)
182-
if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') {
182+
if (empty($dnsRecord->target) || $dnsRecord->target === '.') {
183183
$this->error = new InvalidEmail(new DomainAcceptsNoMail(), "");
184184
return false;
185185
}

0 commit comments

Comments
 (0)