@@ -196,28 +196,45 @@ private function parseAtomic(TokenIterator $tokens): Ast\Type\TypeNode
196196 $ tokens ->dropSavePoint (); // because of ConstFetchNode
197197 }
198198
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 ();
207203
208204 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+ );
210213 }
211214
212215 try {
213216 $ constExpr = $ this ->constExprParser ->parse ($ tokens , true );
214217 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+ );
216226 }
217227
218228 return $ this ->enrichWithAttributes ($ tokens , new Ast \Type \ConstTypeNode ($ constExpr ), $ startLine , $ startIndex );
219229 } 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+ );
221238 }
222239 }
223240
@@ -600,23 +617,33 @@ private function parseCallableReturnType(TokenIterator $tokens): Ast\Type\TypeNo
600617 }
601618 }
602619
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 ();
611624
612625 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+ );
614634 }
615635
616636 try {
617637 $ constExpr = $ this ->constExprParser ->parse ($ tokens , true );
618638 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+ );
620647 }
621648
622649 $ type = new Ast \Type \ConstTypeNode ($ constExpr );
@@ -631,7 +658,14 @@ private function parseCallableReturnType(TokenIterator $tokens): Ast\Type\TypeNo
631658
632659 return $ type ;
633660 } 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+ );
635669 }
636670 }
637671
0 commit comments