@@ -50,8 +50,8 @@ public function parse() : Result
5050 return $ domainChecks ;
5151 }
5252
53- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_AT ) {
54- return new InvalidEmail (new ConsecutiveAt (), $ this ->lexer ->token ['value ' ]);
53+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_AT ) {
54+ return new InvalidEmail (new ConsecutiveAt (), (( array ) $ this ->lexer ->token ) ['value ' ]);
5555 }
5656
5757 $ result = $ this ->doParseDomainPart ();
@@ -69,7 +69,7 @@ public function parse() : Result
6969
7070 $ length = strlen ($ this ->domainPart );
7171 if ($ length > self ::DOMAIN_MAX_LENGTH ) {
72- return new InvalidEmail (new DomainTooLong (), $ this ->lexer ->token ['value ' ]);
72+ return new InvalidEmail (new DomainTooLong (), (( array ) $ this ->lexer ->token ) ['value ' ]);
7373 }
7474
7575 return new ValidEmail ();
@@ -79,13 +79,13 @@ private function checkEndOfDomain() : Result
7979 {
8080 $ prev = $ this ->lexer ->getPrevious ();
8181 if ($ prev ['type ' ] === EmailLexer::S_DOT ) {
82- return new InvalidEmail (new DotAtEnd (), $ this ->lexer ->token ['value ' ]);
82+ return new InvalidEmail (new DotAtEnd (), (( array ) $ this ->lexer ->token ) ['value ' ]);
8383 }
8484 if ($ prev ['type ' ] === EmailLexer::S_HYPHEN ) {
8585 return new InvalidEmail (new DomainHyphened ('Hypen found at the end of the domain ' ), $ prev ['value ' ]);
8686 }
8787
88- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_SP ) {
88+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_SP ) {
8989 return new InvalidEmail (new CRLFAtTheEnd (), $ prev ['value ' ]);
9090 }
9191 return new ValidEmail ();
@@ -98,38 +98,38 @@ private function performDomainStartChecks() : Result
9898 if ($ invalidTokens ->isInvalid ()) {
9999 return $ invalidTokens ;
100100 }
101-
101+
102102 $ missingDomain = $ this ->checkEmptyDomain ();
103103 if ($ missingDomain ->isInvalid ()) {
104104 return $ missingDomain ;
105105 }
106106
107- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_OPENPARENTHESIS ) {
107+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_OPENPARENTHESIS ) {
108108 $ this ->warnings [DeprecatedComment::CODE ] = new DeprecatedComment ();
109109 }
110110 return new ValidEmail ();
111111 }
112112
113113 private function checkEmptyDomain () : Result
114114 {
115- $ thereIsNoDomain = $ this ->lexer ->token ['type ' ] === EmailLexer::S_EMPTY ||
116- ($ this ->lexer ->token ['type ' ] === EmailLexer::S_SP &&
115+ $ thereIsNoDomain = (( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_EMPTY ||
116+ ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_SP &&
117117 !$ this ->lexer ->isNextToken (EmailLexer::GENERIC ));
118118
119119 if ($ thereIsNoDomain ) {
120- return new InvalidEmail (new NoDomainPart (), $ this ->lexer ->token ['value ' ]);
120+ return new InvalidEmail (new NoDomainPart (), (( array ) $ this ->lexer ->token ) ['value ' ]);
121121 }
122122
123123 return new ValidEmail ();
124124 }
125125
126126 private function checkInvalidTokensAfterAT () : Result
127127 {
128- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_DOT ) {
129- return new InvalidEmail (new DotAtStart (), $ this ->lexer ->token ['value ' ]);
128+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_DOT ) {
129+ return new InvalidEmail (new DotAtStart (), (( array ) $ this ->lexer ->token ) ['value ' ]);
130130 }
131- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_HYPHEN ) {
132- return new InvalidEmail (new DomainHyphened ('After AT ' ), $ this ->lexer ->token ['value ' ]);
131+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_HYPHEN ) {
132+ return new InvalidEmail (new DomainHyphened ('After AT ' ), (( array ) $ this ->lexer ->token ) ['value ' ]);
133133 }
134134 return new ValidEmail ();
135135 }
@@ -156,8 +156,8 @@ protected function doParseDomainPart() : Result
156156 return $ notAllowedChars ;
157157 }
158158
159- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_OPENPARENTHESIS ||
160- $ this ->lexer ->token ['type ' ] === EmailLexer::S_CLOSEPARENTHESIS ) {
159+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_OPENPARENTHESIS ||
160+ (( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_CLOSEPARENTHESIS ) {
161161 $ hasComments = true ;
162162 $ commentsResult = $ this ->parseComments ();
163163
@@ -172,7 +172,7 @@ protected function doParseDomainPart() : Result
172172 return $ dotsResult ;
173173 }
174174
175- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_OPENBRACKET ) {
175+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_OPENBRACKET ) {
176176 $ literalResult = $ this ->parseDomainLiteral ();
177177
178178 $ this ->addTLDWarnings ($ tldMissing );
@@ -189,9 +189,9 @@ protected function doParseDomainPart() : Result
189189 return $ FwsResult ;
190190 }
191191
192- $ domain .= $ this ->lexer ->token ['value ' ];
192+ $ domain .= (( array ) $ this ->lexer ->token ) ['value ' ];
193193
194- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_DOT && $ this ->lexer ->isNextToken (EmailLexer::GENERIC )) {
194+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_DOT && $ this ->lexer ->isNextToken (EmailLexer::GENERIC )) {
195195 $ tldMissing = false ;
196196 }
197197
@@ -201,7 +201,7 @@ protected function doParseDomainPart() : Result
201201 }
202202 $ this ->lexer ->moveNext ();
203203
204- } while (null !== $ this ->lexer ->token ['type ' ]);
204+ } while (null !== (( array ) $ this ->lexer ->token ) ['type ' ]);
205205
206206 $ labelCheck = $ this ->checkLabelLength (true );
207207 if ($ labelCheck ->isInvalid ()) {
@@ -219,8 +219,8 @@ protected function doParseDomainPart() : Result
219219 private function checkNotAllowedChars ($ token ) : Result
220220 {
221221 $ notAllowed = [EmailLexer::S_BACKSLASH => true , EmailLexer::S_SLASH => true ];
222- if (isset ($ notAllowed [$ token ['type ' ]])) {
223- return new InvalidEmail (new CharNotAllowed (), $ token ['value ' ]);
222+ if (isset ($ notAllowed [(( array ) $ token) ['type ' ]])) {
223+ return new InvalidEmail (new CharNotAllowed (), (( array ) $ token) ['value ' ]);
224224 }
225225 return new ValidEmail ();
226226 }
@@ -233,7 +233,7 @@ protected function parseDomainLiteral() : Result
233233 try {
234234 $ this ->lexer ->find (EmailLexer::S_CLOSEBRACKET );
235235 } catch (\RuntimeException $ e ) {
236- return new InvalidEmail (new ExpectingDomainLiteralClose (), $ this ->lexer ->token ['value ' ]);
236+ return new InvalidEmail (new ExpectingDomainLiteralClose (), (( array ) $ this ->lexer ->token ) ['value ' ]);
237237 }
238238
239239 $ domainLiteralParser = new DomainLiteralParser ($ this ->lexer );
@@ -244,17 +244,17 @@ protected function parseDomainLiteral() : Result
244244
245245 protected function checkDomainPartExceptions (array $ prev , bool $ hasComments ) : Result
246246 {
247- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_OPENBRACKET && $ prev ['type ' ] !== EmailLexer::S_AT ) {
248- return new InvalidEmail (new ExpectingATEXT ('OPENBRACKET not after AT ' ), $ this ->lexer ->token ['value ' ]);
247+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_OPENBRACKET && $ prev ['type ' ] !== EmailLexer::S_AT ) {
248+ return new InvalidEmail (new ExpectingATEXT ('OPENBRACKET not after AT ' ), (( array ) $ this ->lexer ->token ) ['value ' ]);
249249 }
250250
251- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_HYPHEN && $ this ->lexer ->isNextToken (EmailLexer::S_DOT )) {
252- return new InvalidEmail (new DomainHyphened ('Hypen found near DOT ' ), $ this ->lexer ->token ['value ' ]);
251+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_HYPHEN && $ this ->lexer ->isNextToken (EmailLexer::S_DOT )) {
252+ return new InvalidEmail (new DomainHyphened ('Hypen found near DOT ' ), (( array ) $ this ->lexer ->token ) ['value ' ]);
253253 }
254254
255- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_BACKSLASH
255+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_BACKSLASH
256256 && $ this ->lexer ->isNextToken (EmailLexer::GENERIC )) {
257- return new InvalidEmail (new ExpectingATEXT ('Escaping following "ATOM" ' ), $ this ->lexer ->token ['value ' ]);
257+ return new InvalidEmail (new ExpectingATEXT ('Escaping following "ATOM" ' ), (( array ) $ this ->lexer ->token ) ['value ' ]);
258258 }
259259
260260 return $ this ->validateTokens ($ hasComments );
@@ -273,22 +273,22 @@ protected function validateTokens(bool $hasComments) : Result
273273 $ validDomainTokens [EmailLexer::S_CLOSEPARENTHESIS ] = true ;
274274 }
275275
276- if (!isset ($ validDomainTokens [$ this ->lexer ->token ['type ' ]])) {
277- return new InvalidEmail (new ExpectingATEXT ('Invalid token in domain: ' . $ this ->lexer ->token ['value ' ]), $ this ->lexer ->token ['value ' ]);
276+ if (!isset ($ validDomainTokens [(( array ) $ this ->lexer ->token ) ['type ' ]])) {
277+ return new InvalidEmail (new ExpectingATEXT ('Invalid token in domain: ' . (( array ) $ this ->lexer ->token ) ['value ' ]), (( array ) $ this ->lexer ->token ) ['value ' ]);
278278 }
279279
280280 return new ValidEmail ();
281281 }
282282
283283 private function checkLabelLength (bool $ isEndOfDomain = false ) : Result
284284 {
285- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_DOT || $ isEndOfDomain ) {
285+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_DOT || $ isEndOfDomain ) {
286286 if ($ this ->isLabelTooLong ($ this ->label )) {
287- return new InvalidEmail (new LabelTooLong (), $ this ->lexer ->token ['value ' ]);
287+ return new InvalidEmail (new LabelTooLong (), (( array ) $ this ->lexer ->token ) ['value ' ]);
288288 }
289289 $ this ->label = '' ;
290290 }
291- $ this ->label .= $ this ->lexer ->token ['value ' ];
291+ $ this ->label .= (( array ) $ this ->lexer ->token ) ['value ' ];
292292 return new ValidEmail ();
293293 }
294294
0 commit comments