Search code examples
phplaravelphpstan

PHPStan excludePaths is not working on vendor files


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

Solution

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