Bug #79920 [Asn->Nab]: Parse error doesn't emit line number in error message
| From: | nikic@php.net | Date: | Mon, 03 Aug 2020 07:56:20 +0000 |
| Subject: | Bug #79920 [Asn->Nab]: Parse error doesn't emit line number in error message | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228386@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79920&edit=1
ID: 79920
Updated by: nikic@php.net
Reported by: info at joomlager dot de
Summary: Parse error doesn't emit line number in error
message
-Status: Assigned
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Windows10
PHP Version: 8.0.0alpha3
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2020-08-03 07:38:25] 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-01 16:49:21] cmb@php.net
Also see <https://github.com/sebastianbergmann/phpunit/issues/4373>.
------------------------------------------------------------------------
[2020-08-01 15:24:15] 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-07-31 10:17:55] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79920&edit=1