|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80365 Nonsensical error message says "expecting end of file"
Submitted: 2020-11-13 18:49 UTC Modified: 2021-02-05 21:44 UTC
From: php4fan at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 8.0.0RC4 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php4fan at gmail dot com
New email:
PHP Version: OS:


 [2020-11-13 18:49 UTC] php4fan at gmail dot com
The script below rightfully results in a parse error, but the error message is garbage.

It says 'unexpected token "<"' (so far so good) but then it adds "expecting end of file".

End of file is only one out of a pile of possible valid tokens there.

I appreciate that you tried to improve on previous versions which would only say "unexpected token [...]" without specifying what valid thing was expected. I myself complained many times about that. It's necessary to always specify not only the unexpected thing but also what was expected instead, at least when the range of possibilities can be reasonably narrowed down.

But it makes no sense to name only one random possible valid token and to say you are expecting that one. If the range of valid possibilities is too big to list, just say so.

Test script:

echo 3+2;
// I'll forget a closing php tag ("? >") now


// ...


Expected result:
   Parse error: syntax error, unexpected token "<", ...

and there you could end with something like:

 "expecting end of file among other valid possibilities", 


 "expecting something else (too many possibilities to list them exhaustively)"

(and of course "on line 7")

Actual result:
Parse error: syntax error, unexpected token "<", expecting end of file in [...] on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-13 18:49 UTC] php4fan at gmail dot com
Similar issue:
 [2021-02-05 21:44 UTC]
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2021-02-05 21:44 UTC]
Duplicate of feature request #47883.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 04:01:29 2024 UTC