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=PHP Fatal error: Unknown option -c in Unknown on line 0 #73

Closed apss-pohl closed 7 months ago

apss-pohl commented 7 months ago

I cant get it working, i always fail with:

client] Starting extension with configuration: {
    "binPath": "${workspaceFolder}/bin/library-dev/vendor/bin/phpstan",
    "binCommand": [],
    "configFile": "phpstan.neon,phpstan.neon.dist,phpstan.dist.neon",
    "rootDir": "",
    "options": [],
    "enableStatusBar": true,
    "memoryLimit": "1G",
    "enabled": true,
    "projectTimeout": 300000,
    "suppressTimeoutMessage": false,
    "paths": {},
    "showProgress": true,
    "enableLanguageServer": true,
    "ignoreErrors": [],
    "suppressWorkspaceMessage": false,
    "pro": false,
    "proTmpDir": "",
    "checkValidity": false
}
[client] Initializing done
[client] Showing one-time messages (if needed)
[server] Language server ready
[server] Language server started
[check:1] Check started for project
[status-bar] Showing status bar
[check:1] Spawning PHPStan with the following configuration:  {"binStr":"/mnt/share/dev/code/freeclimber-gtk3/bin/library-dev/vendor/bin/phpstan","args":["analyse","-c","/mnt/share/dev/code/freeclimber-gtk3/phpstan.neon","--error-format=json","--no-interaction","--memory-limit=1G","-a","/home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/autoload.php","-c","/home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/config.neon"]}
[process-spawner] Spawning process 137595 with timeout 900000
[check:1] PHPStan process exited with error  filteredErr=PHP Fatal error:  Unknown option -c in Unknown on line 0  rawErr=PHP Fatal error:  Unknown option -c in Unknown on line 0
  data=Could not startup.

But

bin/library-dev/vendor/bin/phpstan analyze  -c /mnt/share/dev/code/freeclimber-gtk3/phpstan.neon | more
 124/124 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

works perfectly fine. What could be the issue?

SanderRonde commented 7 months ago

Which version are you using? The -c parameter should specify the config file.

apss-pohl commented 7 months ago

image I am working on ubuntu linux

SanderRonde commented 7 months ago

Ah I meant the version of the PHPStan program itself. What version is that?

apss-pohl commented 7 months ago

sure:

        "name": "phpstan/phpstan",
        "version": "1.10.63",
apss-pohl commented 7 months ago

i might have messed up with the php executable. After a fresh restart of vscode the message disappeared. Unfortunately a new one came up:

[client] Starting extension with configuration: {
    "binPath": "./bin/library-dev/vendor/bin/phpstan",
    "binCommand": [],
    "configFile": "phpstan.neon,phpstan.neon.dist,phpstan.dist.neon",
    "rootDir": "",
    "options": [],
    "enableStatusBar": true,
    "memoryLimit": "1G",
    "enabled": true,
    "projectTimeout": 300000,
    "suppressTimeoutMessage": false,
    "paths": {},
    "showProgress": true,
    "enableLanguageServer": true,
    "ignoreErrors": [],
    "suppressWorkspaceMessage": false,
    "pro": false,
    "proTmpDir": "",
    "checkValidity": false
}
[client] Initializing done
[client] Showing one-time messages (if needed)
[server] Language server ready
[server] Language server started
[file-watcher] New document active (file:///mnt/share/dev/code/freeclimber-gtk3/ka/module/bill/func_bill.php), triggering
[check:1] Check started for project
[status-bar] Showing status bar
[server] PHPStan version: PHPStan - PHP Static Analysis Tool 1.10.63

[check:1] Spawning PHPStan with the following configuration:  {"binStr":"/mnt/share/dev/code/freeclimber-gtk3/bin/library-dev/vendor/bin/phpstan","args":["analyse","-c","/mnt/share/dev/code/freeclimber-gtk3/phpstan.neon","--error-format=json","--no-interaction","--memory-limit=1G","-a","/home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/autoload.php","-c","/home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/config.neon"]}
[process-spawner] Spawning process 146446 with timeout 900000
[check:1] PHPStan process exited with error  filteredErr=PHP Parse error:  syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/TreeFetcher.php on line 202
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/TreeFetcher.php on line 202  rawErr=PHP Parse error:  syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /home/sven/.vscode/extensions/sanderronde.phpstan-vscode-3.1.1/_config/TreeFetcher.php on line 202

I am on a php 7.4 project, therefore this will not work:

        $scope->getClassReflection()?->getName(),

However i also have php 8 available. Should i configure the extension to use this? Is it is possible?

SanderRonde commented 7 months ago

Can you disable the languageServer setting? (i think it should be disabled by default). That should fix the issue

apss-pohl commented 7 months ago

I managed that php 8 is used, everything working fine now. Maybe an option to configure the executable would be a nice to have.

Thank you and sorry for confusion!

SanderRonde commented 7 months ago

You can configure the executable using the phpstan.binCommand setting, you can use that to run anything you want (so ['/bin/php8', 'vendor/bin/phpstan'] etc :)

No worries, glad you were able to figure it out.