@@ -196,28 +196,45 @@ private function parseAtomic(TokenIterator $tokens): Ast\Type\TypeNode
196
196
$ tokens ->dropSavePoint (); // because of ConstFetchNode
197
197
}
198
198
199
- $ exception = new ParserException (
200
- $ tokens ->currentTokenValue (),
201
- $ tokens ->currentTokenType (),
202
- $ tokens ->currentTokenOffset (),
203
- Lexer::TOKEN_IDENTIFIER ,
204
- null ,
205
- $ tokens ->currentTokenLine ()
206
- );
199
+ $ currentTokenValue = $ tokens ->currentTokenValue ();
200
+ $ currentTokenType = $ tokens ->currentTokenType ();
201
+ $ currentTokenOffset = $ tokens ->currentTokenOffset ();
202
+ $ currentTokenLine = $ tokens ->currentTokenLine ();
207
203
208
204
if ($ this ->constExprParser === null ) {
209
- throw $ exception ;
205
+ throw new ParserException (
206
+ $ currentTokenValue ,
207
+ $ currentTokenType ,
208
+ $ currentTokenOffset ,
209
+ Lexer::TOKEN_IDENTIFIER ,
210
+ null ,
211
+ $ currentTokenLine
212
+ );
210
213
}
211
214
212
215
try {
213
216
$ constExpr = $ this ->constExprParser ->parse ($ tokens , true );
214
217
if ($ constExpr instanceof Ast \ConstExpr \ConstExprArrayNode) {
215
- throw $ exception ;
218
+ throw new ParserException (
219
+ $ currentTokenValue ,
220
+ $ currentTokenType ,
221
+ $ currentTokenOffset ,
222
+ Lexer::TOKEN_IDENTIFIER ,
223
+ null ,
224
+ $ currentTokenLine
225
+ );
216
226
}
217
227
218
228
return $ this ->enrichWithAttributes ($ tokens , new Ast \Type \ConstTypeNode ($ constExpr ), $ startLine , $ startIndex );
219
229
} catch (LogicException $ e ) {
220
- throw $ exception ;
230
+ throw new ParserException (
231
+ $ currentTokenValue ,
232
+ $ currentTokenType ,
233
+ $ currentTokenOffset ,
234
+ Lexer::TOKEN_IDENTIFIER ,
235
+ null ,
236
+ $ currentTokenLine
237
+ );
221
238
}
222
239
}
223
240
@@ -600,23 +617,33 @@ private function parseCallableReturnType(TokenIterator $tokens): Ast\Type\TypeNo
600
617
}
601
618
}
602
619
603
- $ exception = new ParserException (
604
- $ tokens ->currentTokenValue (),
605
- $ tokens ->currentTokenType (),
606
- $ tokens ->currentTokenOffset (),
607
- Lexer::TOKEN_IDENTIFIER ,
608
- null ,
609
- $ tokens ->currentTokenLine ()
610
- );
620
+ $ currentTokenValue = $ tokens ->currentTokenValue ();
621
+ $ currentTokenType = $ tokens ->currentTokenType ();
622
+ $ currentTokenOffset = $ tokens ->currentTokenOffset ();
623
+ $ currentTokenLine = $ tokens ->currentTokenLine ();
611
624
612
625
if ($ this ->constExprParser === null ) {
613
- throw $ exception ;
626
+ throw new ParserException (
627
+ $ currentTokenValue ,
628
+ $ currentTokenType ,
629
+ $ currentTokenOffset ,
630
+ Lexer::TOKEN_IDENTIFIER ,
631
+ null ,
632
+ $ currentTokenLine
633
+ );
614
634
}
615
635
616
636
try {
617
637
$ constExpr = $ this ->constExprParser ->parse ($ tokens , true );
618
638
if ($ constExpr instanceof Ast \ConstExpr \ConstExprArrayNode) {
619
- throw $ exception ;
639
+ throw new ParserException (
640
+ $ currentTokenValue ,
641
+ $ currentTokenType ,
642
+ $ currentTokenOffset ,
643
+ Lexer::TOKEN_IDENTIFIER ,
644
+ null ,
645
+ $ currentTokenLine
646
+ );
620
647
}
621
648
622
649
$ type = new Ast \Type \ConstTypeNode ($ constExpr );
@@ -631,7 +658,14 @@ private function parseCallableReturnType(TokenIterator $tokens): Ast\Type\TypeNo
631
658
632
659
return $ type ;
633
660
} catch (LogicException $ e ) {
634
- throw $ exception ;
661
+ throw new ParserException (
662
+ $ currentTokenValue ,
663
+ $ currentTokenType ,
664
+ $ currentTokenOffset ,
665
+ Lexer::TOKEN_IDENTIFIER ,
666
+ null ,
667
+ $ currentTokenLine
668
+ );
635
669
}
636
670
}
637
671
0 commit comments