@@ -50,8 +50,8 @@ public function parse() : Result
50
50
return $ domainChecks ;
51
51
}
52
52
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 ' ]);
55
55
}
56
56
57
57
$ result = $ this ->doParseDomainPart ();
@@ -69,7 +69,7 @@ public function parse() : Result
69
69
70
70
$ length = strlen ($ this ->domainPart );
71
71
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 ' ]);
73
73
}
74
74
75
75
return new ValidEmail ();
@@ -79,13 +79,13 @@ private function checkEndOfDomain() : Result
79
79
{
80
80
$ prev = $ this ->lexer ->getPrevious ();
81
81
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 ' ]);
83
83
}
84
84
if ($ prev ['type ' ] === EmailLexer::S_HYPHEN ) {
85
85
return new InvalidEmail (new DomainHyphened ('Hypen found at the end of the domain ' ), $ prev ['value ' ]);
86
86
}
87
87
88
- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_SP ) {
88
+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_SP ) {
89
89
return new InvalidEmail (new CRLFAtTheEnd (), $ prev ['value ' ]);
90
90
}
91
91
return new ValidEmail ();
@@ -98,38 +98,38 @@ private function performDomainStartChecks() : Result
98
98
if ($ invalidTokens ->isInvalid ()) {
99
99
return $ invalidTokens ;
100
100
}
101
-
101
+
102
102
$ missingDomain = $ this ->checkEmptyDomain ();
103
103
if ($ missingDomain ->isInvalid ()) {
104
104
return $ missingDomain ;
105
105
}
106
106
107
- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_OPENPARENTHESIS ) {
107
+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_OPENPARENTHESIS ) {
108
108
$ this ->warnings [DeprecatedComment::CODE ] = new DeprecatedComment ();
109
109
}
110
110
return new ValidEmail ();
111
111
}
112
112
113
113
private function checkEmptyDomain () : Result
114
114
{
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 &&
117
117
!$ this ->lexer ->isNextToken (EmailLexer::GENERIC ));
118
118
119
119
if ($ thereIsNoDomain ) {
120
- return new InvalidEmail (new NoDomainPart (), $ this ->lexer ->token ['value ' ]);
120
+ return new InvalidEmail (new NoDomainPart (), (( array ) $ this ->lexer ->token ) ['value ' ]);
121
121
}
122
122
123
123
return new ValidEmail ();
124
124
}
125
125
126
126
private function checkInvalidTokensAfterAT () : Result
127
127
{
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 ' ]);
130
130
}
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 ' ]);
133
133
}
134
134
return new ValidEmail ();
135
135
}
@@ -156,8 +156,8 @@ protected function doParseDomainPart() : Result
156
156
return $ notAllowedChars ;
157
157
}
158
158
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 ) {
161
161
$ hasComments = true ;
162
162
$ commentsResult = $ this ->parseComments ();
163
163
@@ -172,7 +172,7 @@ protected function doParseDomainPart() : Result
172
172
return $ dotsResult ;
173
173
}
174
174
175
- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_OPENBRACKET ) {
175
+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_OPENBRACKET ) {
176
176
$ literalResult = $ this ->parseDomainLiteral ();
177
177
178
178
$ this ->addTLDWarnings ($ tldMissing );
@@ -189,9 +189,9 @@ protected function doParseDomainPart() : Result
189
189
return $ FwsResult ;
190
190
}
191
191
192
- $ domain .= $ this ->lexer ->token ['value ' ];
192
+ $ domain .= (( array ) $ this ->lexer ->token ) ['value ' ];
193
193
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 )) {
195
195
$ tldMissing = false ;
196
196
}
197
197
@@ -201,7 +201,7 @@ protected function doParseDomainPart() : Result
201
201
}
202
202
$ this ->lexer ->moveNext ();
203
203
204
- } while (null !== $ this ->lexer ->token ['type ' ]);
204
+ } while (null !== (( array ) $ this ->lexer ->token ) ['type ' ]);
205
205
206
206
$ labelCheck = $ this ->checkLabelLength (true );
207
207
if ($ labelCheck ->isInvalid ()) {
@@ -219,8 +219,8 @@ protected function doParseDomainPart() : Result
219
219
private function checkNotAllowedChars ($ token ) : Result
220
220
{
221
221
$ 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 ' ]);
224
224
}
225
225
return new ValidEmail ();
226
226
}
@@ -233,7 +233,7 @@ protected function parseDomainLiteral() : Result
233
233
try {
234
234
$ this ->lexer ->find (EmailLexer::S_CLOSEBRACKET );
235
235
} catch (\RuntimeException $ e ) {
236
- return new InvalidEmail (new ExpectingDomainLiteralClose (), $ this ->lexer ->token ['value ' ]);
236
+ return new InvalidEmail (new ExpectingDomainLiteralClose (), (( array ) $ this ->lexer ->token ) ['value ' ]);
237
237
}
238
238
239
239
$ domainLiteralParser = new DomainLiteralParser ($ this ->lexer );
@@ -244,17 +244,17 @@ protected function parseDomainLiteral() : Result
244
244
245
245
protected function checkDomainPartExceptions (array $ prev , bool $ hasComments ) : Result
246
246
{
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 ' ]);
249
249
}
250
250
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 ' ]);
253
253
}
254
254
255
- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_BACKSLASH
255
+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_BACKSLASH
256
256
&& $ 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 ' ]);
258
258
}
259
259
260
260
return $ this ->validateTokens ($ hasComments );
@@ -273,22 +273,22 @@ protected function validateTokens(bool $hasComments) : Result
273
273
$ validDomainTokens [EmailLexer::S_CLOSEPARENTHESIS ] = true ;
274
274
}
275
275
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 ' ]);
278
278
}
279
279
280
280
return new ValidEmail ();
281
281
}
282
282
283
283
private function checkLabelLength (bool $ isEndOfDomain = false ) : Result
284
284
{
285
- if ($ this ->lexer ->token ['type ' ] === EmailLexer::S_DOT || $ isEndOfDomain ) {
285
+ if ((( array ) $ this ->lexer ->token ) ['type ' ] === EmailLexer::S_DOT || $ isEndOfDomain ) {
286
286
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 ' ]);
288
288
}
289
289
$ this ->label = '' ;
290
290
}
291
- $ this ->label .= $ this ->lexer ->token ['value ' ];
291
+ $ this ->label .= (( array ) $ this ->lexer ->token ) ['value ' ];
292
292
return new ValidEmail ();
293
293
}
294
294
0 commit comments