@@ -29,6 +29,7 @@ public function __construct(TokenStream $tokenStream)
2929 $ this ->tokenStream = $ tokenStream ;
3030 }
3131
32+ /** @throws ParserException */
3233 abstract public function getNode (): BaseToken ;
3334
3435 protected function hasMethodCall (): bool
@@ -61,6 +62,7 @@ protected function hasMethodCall(): bool
6162 return $ hasMethod ;
6263 }
6364
65+ /** @throws ParserException */
6466 protected function getMethod (BaseToken $ token ): CallableUserFunctionInterface
6567 {
6668 $ this ->tokenStream ->getStack ()->seek ($ this ->methodOffset );
@@ -73,21 +75,24 @@ private function getMethodName(): string
7375 return (string ) preg_replace ('~\W~ ' , '' , $ this ->methodName );
7476 }
7577
78+ /** @throws ParserException */
7679 protected function getFunction (): Closure
7780 {
7881 return $ this ->tokenStream ->getFunction ($ this ->getFunctionName ());
7982 }
8083
8184 private function getFunctionName (): string
8285 {
83- return preg_replace ('~\W~ ' , '' , $ this ->getCurrentNode ()->getValue ());
86+ return ( string ) preg_replace ('~\W~ ' , '' , $ this ->getCurrentNode ()->getValue ());
8487 }
8588
89+ /** @throws ParserException */
8690 protected function getArrayItems (): TokenCollection
8791 {
8892 return $ this ->getCommaSeparatedValues (TokenType::SQUARE_BRACKET );
8993 }
9094
95+ /** @throws ParserException */
9196 protected function getArguments (): TokenCollection
9297 {
9398 return $ this ->getCommaSeparatedValues (TokenType::PARENTHESIS );
@@ -98,6 +103,7 @@ protected function getCurrentNode(): BaseToken
98103 return $ this ->tokenStream ->getStack ()->current ();
99104 }
100105
106+ /** @throws ParserException */
101107 private function getCommaSeparatedValues (int $ stopAt ): TokenCollection
102108 {
103109 $ items = new TokenCollection ();
@@ -132,17 +138,19 @@ private function getCommaSeparatedValues(int $stopAt): TokenCollection
132138 return $ items ;
133139 }
134140
141+ /** @throws ParserException */
135142 private function getNextToken (): BaseToken
136143 {
137144 $ this ->tokenStream ->next ();
138145
139146 if (!$ this ->tokenStream ->valid ()) {
140- throw new ParserException ( ' Unexpected end of string ' );
147+ throw ParserException:: unexpectedEndOfString ( );
141148 }
142149
143150 return $ this ->tokenStream ->current ();
144151 }
145152
153+ /** @throws ParserException */
146154 private function assertNoTrailingComma (bool $ commaExpected , TokenCollection $ items , BaseToken $ token ): void
147155 {
148156 if (!$ commaExpected && $ items ->count () > 0 ) {
0 commit comments