Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error reported when there are none (only in CI/Jenkins, phpVersion 80000) #3943

Closed
gnutix opened this issue Oct 12, 2020 · 12 comments
Closed

Comments

@gnutix
Copy link

gnutix commented Oct 12, 2020

Hello there,

I just upgraded to 0.12.49 and started using phpVersion 80000 on our project. I fixed all inspections locally, then deployed on our Jenkins CI. It then reported the following errors on various classes :

 ------ --------------------------------------------- 
  Line   src/UI/Shared/Error/ErrorListener.php        
 ------ --------------------------------------------- 
  77     Syntax error, unexpected ',' on line 77      
  77     Syntax error, unexpected T_MATCH on line 77  
 ------ --------------------------------------------- 

There is no syntax error in none of the files (the code is running in production on PHP 7.2 fine) and we use phplint to validate the code base. I can't find something that would be broken in PHP8, but maybe there is ? Any clue what that might come from ? (sorry, I cannot share the whole code...)

@ondrejmirtes
Copy link
Member

On PHP 8 classes can no longer be named “Match” so you have that somewhere in your code or dependencies.

@gnutix
Copy link
Author

gnutix commented Oct 12, 2020

I couldn't find that word "match" in the class having the error. But as you mentioned dependencies, I'll have to look through the whole code base (on my way home now, can't do it on mobile).

Is it only classes, or methods/functions too ? Any idea why it works locally and not on the CI server ? Should there be a PhpStan inspection for that (so it could help tracking down the source of the issue) ?

@ondrejmirtes
Copy link
Member

Function too: https://3v4l.org/FfjjA

PHPStan currently doesn't know which file caused the parse error, I'll do some refactoring so that it can be reported too.

@gnutix
Copy link
Author

gnutix commented Oct 13, 2020

I found it : willdurand/Negotiation#106
I have an older version of this lib.

@ondrejmirtes
Copy link
Member

Glad you sorted it out :) I'm gonna improve the message, thanks.

@gnutix
Copy link
Author

gnutix commented Oct 13, 2020

Weird... I still have the error on the CI even after upgrading the library. :/ And I can't find any other match class nor function (tons of methods, but that seems to work just fine). I'll revert to phpVersion: 74000 until you've improved the error message so I have a chance to find the reason.

@ondrejmirtes
Copy link
Member

Alright, now you have the chance to see the real file with the parse error: phpstan/phpstan-src@8113f38

The output now looks something like this:

 ------ ----------------------------------------------------------------------
  Line   vendor/phpunit/phpunit/src/Framework/MockObject/Builder/Match.php
 ------ ----------------------------------------------------------------------
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15
  25     Syntax error, unexpected ';', expecting '{' on line 25
 ------ ----------------------------------------------------------------------

@gnutix
Copy link
Author

gnutix commented Oct 16, 2020

Awesome, I'll give it a try next Friday ! Thanks :D

@gnutix
Copy link
Author

gnutix commented Oct 23, 2020

OK, so PhpStan gave me the clue I needed indeed :

 ------ ------------------------------------------------------------------- 
  Line   vendor/phpunit/phpunit/src/Framework/MockObject/Builder/Match.php  
 ------ ------------------------------------------------------------------- 
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  15     Syntax error, unexpected T_MATCH, expecting T_STRING on line 15    
  25     Syntax error, unexpected ';', expecting '{' on line 25             
  25     Syntax error, unexpected ';', expecting '{' on line 25             
  25     Syntax error, unexpected ';', expecting '{' on line 25             
  25     Syntax error, unexpected ';', expecting '{' on line 25             
  25     Syntax error, unexpected ';', expecting '{' on line 25             
  25     Syntax error, unexpected ';', expecting '{' on line 25             
  25     Syntax error, unexpected ';', expecting '{' on line 25             
 ------ ------------------------------------------------------------------- 

(though it's a bit weird that the error line is reported many times)

However, I'm not sure how to fix it... I'm stuck on PHP 7.2 for some more months, so I can't upgrade to the new version of PHPUnit and I can't get rid of it in the CI environment. This would not happen in production as it's a dev dependency. @ondrejmirtes Any way to ignore this error ? (and I'm still not clear why this error is not reported in the local environment where PHPUnit is installed too!)

I tried installing Symfony phpunit bridge instead of requiring it in our vendors directly, but the test suite breaks and I'm not sure I'll find a way to fix it.

@ondrejmirtes
Copy link
Member

You're not supposed to run with phpVersion: 80000 until you're running on PHP 8.0 in production. This is just to give you a clue what's going to block you/what you need to fix before upgrading to PHP 8.0.

@gnutix
Copy link
Author

gnutix commented Oct 23, 2020

Oh.. that explains it all! 🙈
Okay, so I'll only put a higher version than 72000 when doing some tests locally. Thanks!

Still that leaves open the question why the PHPUnit Match class did not appear when running PhpStan locally with 80000, but appeared on the CI...

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants