SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
47 stars 8 forks source link

PHPStan process exited with error filteredErr=Invalid configuration: #110

Closed momala454 closed 2 weeks ago

momala454 commented 2 weeks ago

appeared recently

[11/13/2024, 2:11:26 PM] [client] Starting extension with configuration: {
    "phpstan.singleFileMode": false,
    "phpstan.binPath": "vendor/bin/phpstan",
    "phpstan.binCommand": [],
    "phpstan.configFile": "phpstan.neon,phpstan.neon.dist,phpstan.dist.neon",
    "phpstan.paths": {},
    "phpstan.dockerContainerName": "",
    "phpstan.rootDir": "",
    "phpstan.options": [],
    "phpstan.enableStatusBar": true,
    "phpstan.memoryLimit": "1G",
    "phpstan.enabled": true,
    "phpstan.projectTimeout": 300000,
    "phpstan.timeout": 300000,
    "phpstan.suppressTimeoutMessage": false,
    "phpstan.showProgress": false,
    "phpstan.showTypeOnHover": true,
    "phpstan.enableLanguageServer": false,
    "phpstan.ignoreErrors": [
        "Xdebug: .*"
    ],
    "phpstan.suppressWorkspaceMessage": false,
    "phpstan.pro": false,
    "phpstan.tmpDir": "",
    "phpstan.checkValidity": false
}
[11/13/2024, 2:11:26 PM] [client] Initializing done
[11/13/2024, 2:11:26 PM] [client] Showing one-time messages (if needed)
[11/13/2024, 2:11:26 PM] [server] Language server ready
[11/13/2024, 2:11:26 PM] [server] Language server started
[11/13/2024, 2:11:26 PM] [file-watcher] Checking: New document active
[11/13/2024, 2:11:26 PM] [check:1] Check started for project
[11/13/2024, 2:11:26 PM] [status-bar] notification:' {"opId":0,"type":"new","tooltip":"Checking project"}
[11/13/2024, 2:11:26 PM] [status-bar] Showing status bar
[11/13/2024, 2:11:27 PM] [server] PHPStan version: PHPStan - PHP Static Analysis Tool 2.0.1

[11/13/2024, 2:11:27 PM] [check:1] Spawning PHPStan with the following configuration:  {"binStr":"/home/xxx/bla/bla-api/vendor/bin/phpstan","args":["analyse","-c","/home/xxx/bla/bla-api/phpstan.neon","--error-format=json","--no-interaction","--memory-limit=1G","-a","/home/xxx/.vscode-server/extensions/sanderronde.phpstan-vscode-3.2.14/_config/4f09c5c6606a8ac1b953d798f98a5522/autoload.php","-c","/home/xxx/.vscode-server/extensions/sanderronde.phpstan-vscode-3.2.14/_config/4f09c5c6606a8ac1b953d798f98a5522/config.neon"]}
[11/13/2024, 2:11:27 PM] [process-spawner] Spawning process 93390 with timeout 900000
[11/13/2024, 2:11:27 PM] [process-spawner] Spawning process 93390 with timeout 900000
[11/13/2024, 2:11:30 PM] [check:1] PHPStan process exited with error  filteredErr=Invalid configuration:
Unexpected item 'parameters › 0'.  rawErr=Invalid configuration:
Unexpected item 'parameters › 0'.
  data=
[11/13/2024, 2:11:30 PM] [status-bar] notification:' {"opId":0,"result":"Error","type":"done"}
[11/13/2024, 2:11:30 PM] [status-bar] Hiding status bar, last operation result = Error
[11/13/2024, 2:11:30 PM] [check:1] Check completed for project, errors= {"fileSpecificErrors":{},"notFileSpecificErrors":[]}
SanderRonde commented 2 weeks ago

Could you try disabling the showTypeOnHover setting? Fairly certain that's what's causing this (and if it's not, it's probably your own configuration file)

momala454 commented 2 weeks ago

yep it works with this disabled

SanderRonde commented 2 weeks ago

Would you mind posting your config (maybe censored) so I can maybe figure out what's causing it?

momala454 commented 2 weeks ago
includes:
    - phpstan-baseline.neon #TODO disable
    - phar://phpstan.phar/conf/bleedingEdge.neon
    - vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor/jbboehr/phpstan-laravel-validation/extension.neon
    - vendor/cuyz/valinor/qa/PHPStan/valinor-phpstan-configuration.php
    - vendor/larastan/larastan/extension.neon
parameters:
    level: 10
    treatPhpDocTypesAsCertain: true
    editorUrl: 'vscode://file/%%file%%:%%line%%'
    editorUrlTitle: '%%relFile%%:%%line%%'
    paths:
        - www
        - app
        - config
        - database
        - routes
        - swagger
    bootstrapFiles:
        - www/includes/App.php
    reportUnmatchedIgnoredErrors: false
    checkImplicitMixed: true
    reportMaybesInMethodSignatures: false
    reportMaybesInPropertyPhpDocTypes: false
    strictRules:
        disallowedLooseComparison: true
        booleansInConditions: false
        uselessCast: true
        requireParentConstructorCall: true
        #disallowedConstructs: false
        disallowedEmpty: false
        overwriteVariablesWithLoop: true
        closureUsesThis: true
        matchingInheritedMethodNames: true
        numericOperandsInArithmeticOperators: true
        #strictCalls: true
        switchConditionsMatchingType: true
        noVariableVariables: false
        strictArrayFilter: true
    ignoreErrors:
        - '#Dynamic call to static method Symfony\\Component\\HttpFoundation\\Response::.*#'
        - '#Dynamic call to static method Illuminate\\Http\\Request::validate\(\).#'
fabon-f commented 2 weeks ago

I encountered the same problem, with remote development. I found that ~/.vscode-server/extensions/sanderronde.phpstan-vscode-3.2.14/_config/xxxxxxxxxxxxxxxxxxxx/config.neon (which is referred from -c) causes the error. Executing phpstan from terminal with the same args to the vscode extension raises same error, but running without -c ~/.vscode-server/(...)/config.neon works fine.

config.neon is like below:

includes:
    # Replaced with location of user file when used
    - /home/xxxxx/path/to/repo/phpstan.neon.dist

rules:
    - PHPStanVSCodeTreeFetcher

parameters:
    # Don't complain when a non-included file is checked
    - zeroFiles: false

    # Use a custom cacheDir so that the transformed-args and
    # default args don't clear each others' caches.
    tmpDir: /home/xxxxx/.vscode-server/extensions/sanderronde.phpstan-vscode-3.2.14/_config/xxxxxxxxxxxxxxxxxxxx/cache

Note that in my case disabling showTypeOnHover doesn't solve the problem.

SanderRonde commented 2 weeks ago

Ah I know what this is, it's due to the recent 2.0 upgrade, will fix this

Also disabling showTypeOnHover should fix the issue, if it doesn't then it's likely your own config causing the problem. Check out what config is being used by checking the logs. (could be that it didn't register the disabling)

momala454 commented 2 weeks ago

Thank you, it's working fine now

momala454 commented 2 weeks ago

Actually, show type on hover does not work anymore, it doesn't tooltip the type

SanderRonde commented 2 weeks ago

Hmm probably an obvious question but are you sure it's enabled? And if so do you see anything in the logs?

Could be that PHPStan 2.0 broke it though, in that case I'd need to fix it.

momala454 commented 2 weeks ago

image

[11/14/2024, 9:14:30 AM] [client] Starting extension with configuration: {
    "phpstan.singleFileMode": false,
    "phpstan.binPath": "vendor/bin/phpstan",
    "phpstan.binCommand": [],
    "phpstan.configFile": "phpstan.neon,phpstan.neon.dist,phpstan.dist.neon",
    "phpstan.paths": {},
    "phpstan.dockerContainerName": "",
    "phpstan.rootDir": "",
    "phpstan.options": [],
    "phpstan.enableStatusBar": true,
    "phpstan.memoryLimit": "1G",
    "phpstan.enabled": true,
    "phpstan.projectTimeout": 300000,
    "phpstan.timeout": 300000,
    "phpstan.suppressTimeoutMessage": false,
    "phpstan.showProgress": false,
    "phpstan.showTypeOnHover": true,
    "phpstan.enableLanguageServer": false,
    "phpstan.ignoreErrors": [
        "Xdebug: .*"
    ],
    "phpstan.suppressWorkspaceMessage": false,
    "phpstan.pro": false,
    "phpstan.tmpDir": "",
    "phpstan.checkValidity": false
}

("phpstan.showTypeOnHover": true,)

When I hover, it shows

[11/14/2024, 9:14:48 AM] [fixer-manager] No file changes, not checking
[11/14/2024, 9:14:49 AM] [file-watcher] Checking: Hover action
[11/14/2024, 9:14:49 AM] [fixer-manager] No file changes, not checking
[11/14/2024, 9:14:50 AM] [file-watcher] Checking: Hover action
[11/14/2024, 9:14:50 AM] [fixer-manager] No file changes, not checking
[11/14/2024, 9:14:51 AM] [file-watcher] Checking: Hover action
[11/14/2024, 9:14:51 AM] [fixer-manager] No file changes, not checking
SanderRonde commented 2 weeks ago

Found the issue, it's something that changed from PHPStan 2 being bleeding edge to it no longer being bleeding edge. Will release the fix soon (somewhere today, will let you know)

SanderRonde commented 2 weeks ago

Published the fix in version 3.2.16

momala454 commented 2 weeks ago

thank you!