php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79920 Parse error doesn't emit line number in error message
Submitted: 2020-07-31 10:17 UTC Modified: 2020-08-03 07:56 UTC
From: info at joomlager dot de Assigned: cmb (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 8.0.0alpha3 OS: Windows10
Private report: No CVE-ID: None
 [2020-07-31 10:17 UTC] info at joomlager dot de
Description:
------------
I'm running PHPUnit 8.5.8 on our codebase and tested it with PHP8. Unfortunately it seems to fail on the newly introduced reserved token "match" somewhere. However the error message is just 

ParseError: syntax error, unexpected token "match", expecting identifier or "static" or "namespace" or "\"

without any file or line number given. I do get a stack trace, but the files and line numbers given in there, are nowhere near where the parse error seems to happen.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-01 15:24 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: *Compile Issues +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2020-08-01 15:24 UTC] cmb@php.net
Well, PHPUnit 8.5.8 is not (necessarily) compatible with PHP 8.
Can you reproduce the issue directly (i.e. without PHPUnit)?
 [2020-08-03 07:38 UTC] info at joomlager dot de
-Status: Feedback +Status: Assigned
 [2020-08-03 07:38 UTC] info at joomlager dot de
I am aware that PHPUnit 8 is not compatible to PHP8, but if it is incompatible and fails for example in this case on the newly reserved keyword "match", I would expect PHP8 to throw an error that gives me the file and line number where this invalid token is encountered. However my stack trace looks like this:

42) Joomla\Tests\Unit\Libraries\Cms\Toolbar\ToolbarTest::testLoadButtonTypeRetunsFalseForUnkownButtonTypes
ParseError: syntax error, unexpected token "match", expecting identifier or "static" or "namespace" or "\"

D:\apachefriends\xampp\htdocs\j4\libraries\src\Autoload\ClassLoader.php:56
D:\apachefriends\xampp\htdocs\j4\libraries\src\Autoload\ClassLoader.php:56
D:\apachefriends\xampp\htdocs\j4\libraries\src\Autoload\ClassLoader.php:56
D:\apachefriends\xampp\htdocs\j4\tests\Unit\Libraries\Cms\Toolbar\ToolbarTest.php:238

As you can see, there is no reference to the file that is linked in the github issue that you linked anywhere. When I look at the line of the given file, the only code I get there is 

$toolbarFactoryMock->expects($this->once())
 [2020-08-03 07:56 UTC] nikic@php.net
-Status: Assigned +Status: Not a bug
 [2020-08-03 07:56 UTC] nikic@php.net
This happens because PhpUnit helpfully cuts of the part of the stack trace that belongs to itself, so you only see the place where it originates in your code -- usually an assertion failure. Of course, that does not work out will if there is an issue in PhpUnit itself. See https://github.com/sebastianbergmann/phpunit/blob/899db927169682058ed8875c3d0c7f30c1fa4ed2/src/Util/Filter.php for the relevant code. You might want to report an issue there to make the backtrace filtering less aggressive.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 20:01:29 2024 UTC