phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

Is there a way to specify which directories to scan with PhpStan when using it with GrumPHP? #397

Closed aloupfor closed 7 years ago

aloupfor commented 7 years ago
Q A
Version 0.11.6
Bug? no
New feature? no
Question? yes
Documentation? no
Related tickets #393

My question is exactly the same as the one that someone posted here: https://stackoverflow.com/q/44613493.

So I am quoting it:

Is there a way to specify which directories to scan with PhpStan when using it with GrumPHP?

When running PhpStan directly, you do this via:

vendor/bin/phpstan analyse src

But GrumPHP only provides the following options for PhpStan:

# grumphp.yml
parameters:
    tasks:
        phpstan:
            autoload_file: ~
            configuration: ~
            level: 0
            triggered_by: ['php']

I would like to only scan the 'src' directory, is there a way to do this?

veewee commented 7 years ago

Probably the only way to do this is by using the excludes_analyse in the phpstan configuration: https://github.com/phpstan/phpstan#exclude-files-from-analysis

Another option is to add an additional parameter to the grumphp task, but that isn't possible at this moment.

aloupfor commented 7 years ago

@veewee Thank you for the answer.

Another option is to add an additional parameter to the grumphp task, but that isn't possible at this moment.

Can you tell me why that isn't possible at this moment? Is it because nobody is available to work on this or that it isn't in the current planning or is it for another reason.

jyggen commented 7 years ago

@aloupfor The reason GrumPHP can't do it is because there's no option in PHPStan to exclude files directly from the command line. PHPStan currently only supports exclusion of files through the phpstan.neon file, and GrumPHP don't fiddle with other tools' config files (for good reason).

veewee commented 7 years ago

@aloupfor, Thanks for reporting. Currently this is indeed not possible. Since the phpstan task is rather new, I created a ticket to improve the phpstan task (#400). We'll continue the discussion from there.