Skip to content

phpstan ~1.5.0 throws child process error for ignored files #7019

@bshaffer

Description

@bshaffer

Bug report

Even when my phpstan.neon is excluding the file using excludePaths, the analyze command will throw a "child process error" if there is a PHP syntax error in that file. In my case, I have a file (Cache/Item.php) which supports psr/cache:1.0, so I want to ignore it from phpstan but still keep it to maintain backwards compatiblity.

 -- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
     Error                                                                                                                                                                             
 -- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
     Child process error (exit code 255): PHP Fatal error:  Declaration of Google\Auth\Cache\Item::getKey() must be compatible with Psr\Cache\CacheItemInterface::getKey(): string in  
     /Users/betterbrent/Code/google-auth-library-php/src/Cache/Item.php on line 62                                                                                                     
     Fatal error: Declaration of Google\Auth\Cache\Item::getKey() must be compatible with Psr\Cache\CacheItemInterface::getKey(): string in                                            
     /Users/betterbrent/Code/google-auth-library-php/src/Cache/Item.php on line 62                                                                                                     
                                                                                                                                                                                       
 -- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

This is using the latest version (1.5.4), but it happens on 1.4 as well.

Code snippet that reproduces the problem

See the github actions result:

  1. On PHP 8.0, clone the repo
git clone git@github.com:googleapis/google-auth-library-php
cd google-auth-library-php
composer install
  1. Run PHPstan and see the error (using PHPstan 1.5.4, but I don't think it matters)
phpstan

Expected output

I would expect it to succeed with "[OK] No errors"

Did PHPStan help you today? Did it make you happy in any way?

Yes, it's amazing!! I'm adding it to all my repos :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions