0

I am having this PHPStan error on our vendor files Command and Logger:

 ------ ---------------------------------------------
  Line   ../www-vendor/symfony/console/Command/Command.php
 ------ ---------------------------------------------
  378    Syntax error, unexpected ')' on line 378
 ------ --------------------------------------------

 ------ --------------------------------------------
  Line   ../www-vendor/symfony/http-kernel/Log/Logger.php
 ------ --------------------------------------------
  81     Syntax error, unexpected ')' on line 81
 ------ --------------------------------------------

And when I try to add these files on the excludePaths, it still not excludes those paths.

parameters:
    bootstrapFiles:
        - ../www-vendor/autoload.php
    paths:
        - app
        - Rex
        - tests/Rex
        - tests/acceptance
        - tests/development
        - tests/helpers
        - utils
    excludePaths:
          // other excluded paths
        - ../www-vendor/symfony/console/Command/Command.php
        - ../www-vendor/symfony/http-kernel/Log/Logger.php

I also tried to add the error messages to the ignoreErrors but PHPStan won't allow this kind of error to be ignored

 -- -------------------------------------------------------------------------------------------------------
     Error
 -- -------------------------------------------------------------------------------------------------------
     Error message "Syntax error, unexpected ')' on line 378" cannot be ignored, use excludePaths instead.
 -- -------------------------------------------------------------------------------------------------------

This is our file structure:

- src
    // other project files
  - phpstan.neon
- www-vendor // our vendor files
  • 2
    I don't think you can ignore files that are directly required by files you are not ignoring. Also the error is indicative that your dependency installation was not done correctly, i.e., you installed a version of Command that requires PHP 8.1 and you have a lower version of PHP (at least PHPStan uses a lower version, or does not recognise PHP 8.1 syntax for some other reason) – apokryfos Jul 27 '23 at 04:32
  • @apokryfos It seems like it did not recognise PHP 8.1 syntax because I use a lower version of PHPStan. But is there any way to ignore it on lower versions of PHPStan? – Mark Joshua Fajardo Jul 27 '23 at 05:46
  • @apokryfos or can I create a custom rule to ignore these errors? – Mark Joshua Fajardo Jul 27 '23 at 06:07
  • 2
    If it doesn't recognise the `$callable(...)` syntax then it thinks this is a syntax error and you'd have to ignore all syntax errors to ignore this, which is probably not a good idea. Is here a good reason for not just upgrading PHPStan? The version of PHPStan that supports PHP 8.1 is almost 2 years old at this point. – apokryfos Jul 27 '23 at 06:41
  • Thanks for that @apokryfos. We'll proceed with the PHPStan. – Mark Joshua Fajardo Jul 28 '23 at 00:27

1 Answers1

0

Upgrade PHPStan to support PHP 8.1 syntax. Thanks to @apokryfos