@@ -32,11 +32,11 @@ final public function __construct(string $message, int $code = 0, ?\Throwable $p
3232 * @param int<0, max> $offset
3333 * @throws SourceExceptionInterface
3434 */
35- public static function fromUnexpectedToken (string $ char , string $ statement , int $ offset ): static
35+ public static function fromUnexpectedToken (string $ token , string $ statement , int $ offset ): static
3636 {
37- $ message = \vsprintf ('Syntax error, unexpected %s in %s %s ' , [
38- Formatter::token ($ char ),
39- Formatter::source ($ statement ),
37+ $ message = \vsprintf ('Syntax error, unexpected %s%s %s ' , [
38+ Formatter::token ($ token ),
39+ $ token === $ statement ? '' : ' in ' . Formatter::source ($ statement ),
4040 Formatter::suffix ($ statement , $ offset ),
4141 ]);
4242
@@ -51,9 +51,9 @@ public static function fromUnexpectedToken(string $char, string $statement, int
5151 */
5252 public static function fromUnrecognizedToken (string $ token , string $ statement , int $ offset ): static
5353 {
54- $ message = \vsprintf ('Syntax error, unrecognized %s in %s %s ' , [
54+ $ message = \vsprintf ('Syntax error, unrecognized %s%s %s ' , [
5555 Formatter::token ($ token ),
56- Formatter::source ($ statement ),
56+ $ token === $ statement ? '' : ' in ' . Formatter::source ($ statement ),
5757 Formatter::suffix ($ statement , $ offset ),
5858 ]);
5959
0 commit comments