File tree Expand file tree Collapse file tree 2 files changed +63
-5
lines changed
Expand file tree Collapse file tree 2 files changed +63
-5
lines changed Original file line number Diff line number Diff line change 22
33namespace PHPStan \PhpDocParser \Parser ;
44
5+ use PHPStan \PhpDocParser \Lexer \Lexer ;
6+
57class ParserException extends \Exception
68{
79
10+ /** @var string */
11+ private $ currentTokenValue ;
12+
13+ /** @var int */
14+ private $ currentTokenType ;
15+
16+ /** @var int */
17+ private $ currentOffset ;
18+
19+ /** @var int */
20+ private $ expectedTokenType ;
21+
22+ public function __construct (
23+ string $ currentTokenValue ,
24+ int $ currentTokenType ,
25+ int $ currentOffset ,
26+ int $ expectedTokenType
27+ )
28+ {
29+ $ this ->currentTokenValue = $ currentTokenValue ;
30+ $ this ->currentTokenType = $ currentTokenType ;
31+ $ this ->currentOffset = $ currentOffset ;
32+ $ this ->expectedTokenType = $ expectedTokenType ;
33+
34+ parent ::__construct (sprintf (
35+ 'Unexpected token \'%s \', expected %s at offset %d ' ,
36+ $ currentTokenValue ,
37+ Lexer::TOKEN_LABELS [$ expectedTokenType ],
38+ $ currentOffset
39+ ));
40+ }
41+
42+
43+ public function getCurrentTokenValue (): string
44+ {
45+ return $ this ->currentTokenValue ;
46+ }
47+
48+
49+ public function getCurrentTokenType (): int
50+ {
51+ return $ this ->currentTokenType ;
52+ }
53+
54+
55+ public function getCurrentOffset (): int
56+ {
57+ return $ this ->currentOffset ;
58+ }
59+
60+
61+ public function getExpectedTokenType (): int
62+ {
63+ return $ this ->expectedTokenType ;
64+ }
65+
866}
Original file line number Diff line number Diff line change @@ -172,12 +172,12 @@ public function rollback()
172172 */
173173 private function throwError (int $ expectedTokenType )
174174 {
175- throw new ParserException (sprintf (
176- 'Unexpected token \'%s \', expected %s at offset %d ' ,
175+ throw new ParserException (
177176 $ this ->currentTokenValue (),
178- Lexer::TOKEN_LABELS [$ expectedTokenType ],
179- $ this ->currentTokenOffset ()
180- ));
177+ $ this ->currentTokenType (),
178+ $ this ->currentTokenOffset (),
179+ $ expectedTokenType
180+ );
181181 }
182182
183183}
You can’t perform that action at this time.
0 commit comments