GrumPHP's phpstan task doesn't get paths to analyse
Good day! I have a Yii2 PHP: v8.0.30 project with the configs below. Since the last project reinstall, GrumPHP is not provide paths to phpstan no more. Before reinstall it worked correctly. composer.json
"require-dev": { "phpstan/phpstan": "^1.6", "phpro/grumphp": "^1.12" },
grumphp.yml
tasks: phpstan: configuration: "phpstan.neon" triggered_by: ["php"] memory_limit: "-1" use_grumphp_paths: true
phpstan.neon
includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon
parameters: tmpDir: runtime/ bootstrapFiles: - vendor/yiisoft/yii2/Yii.php - vendor/autoload.php - defines.php level: 8 ignoreErrors - '#Some errors here#' scanDirectories: - Some dirs here excludePaths: - some paths here
After "composer install" I get PHPStan: v1.12.28 and GrumPHP: v1.13.0. When I make some changes at SomeClass.php (that not in excludePaths), and then "git commit", I get the following error:
Running task 2/5: phpstan... ✘ phpstan
Note: Using configuration file C:\OSPanel629\home\myproject\phpstan.neon. At least one path must be specified to analyse.
What am I doing wrong? Isn't the GrumPHP have to pass changed files to phpstan task as a path param?
Grumphp V1.13 is quite old. Have you tried with latest?
@veewee In 2.16.0, seems same behavior :
$ git commit -m "Upgrade composer components"
GrumPHP detected a pre-commit command.
GrumPHP is sniffing your code!
Running tasks with priority 0!
==============================
Running task 1/3: phplint... ✔
Running task 2/3: phpcs... ✔
Running task 3/3: phpstan... ✘
phpstan
=======
Note: Using configuration file /my/project/phpstan.neon.dist.
[ERROR] No files found to analyse.
grumphp.yml :
grumphp:
git_hook_variables:
EXEC_GRUMPHP_COMMAND: 'php8.2'
ascii:
failed: ~
succeeded: ~
parallel:
enabled: true
max_workers: 32
tasks:
phplint: ~
#behat: ~
phpcs: ~
phpstan:
level: 6
phpstan.neon.dist content :
parameters:
level: 6
treatPhpDocTypesAsCertain: false
dynamicConstantNames:
- PROJECT_DEBUG
paths:
- ./
- ./src
excludePaths:
- vendor/*
- lib/*
bootstrapFiles:
- config.php
If i call phpstan directly, it's ok.
$ ./vendor/bin/phpstan
Note: Using configuration file /my/project/phpstan.neon.dist.
32/32 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ ----------------------------------------------------------------------
Line src/Model/MyClass.php
------ ----------------------------------------------------------------------
1192 Function getRessource not found.
🪪 function.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ----------------------------------------------------------------------
[ERROR] Found 1 error
@apohutenumera Can you disable parallel execution in grumphp.yaml and debug the actual php command that is being sent to phpstan?
Hi,
Have you tried setting the use_grumphp_paths parameter to false?
In my case, I’m using the following GrumPHP configuration for PHPStan and everything seems to work as expected:
phpstan:
use_grumphp_paths: false
Note that I’m also using parallel.
My phpstan.neon:
parameters:
level: 10
reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
inferPrivatePropertyTypeFromConstructor: true
paths:
- web
excludePaths:
- **/tests/*
shipmonkDeadCode:
detect:
deadMethods: true
deadConstants: true
deadEnumCases: true
usageProviders:
phpunit:
enabled: false