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 visual-studio-code vscode vscode-extension

VSCode Installs

Features

https://user-images.githubusercontent.com/5385012/188924277-c9392477-9bd6-40b1-9ed7-eb892da1fe0f.mp4

Configuration

Main Config

Tuning

Customization

FAQ

XDebug-related issues

If you find XDebug-related issues (such as checks failing with The Xdebug PHP extension is active, but "--xdebug" is not used in the output), see these issues: https://github.com/SanderRonde/phpstan-vscode/issues/17, https://github.com/SanderRonde/phpstan-vscode/issues/19.

Does this extension support checking multiple workspaces?

The extension currently doesn't support checking multiple workspaces. You can use the extension just fine in a multi-workspace project, but only a single PHPStan configuration can be checked. The one that will be checked is configurable using the above configuration options. If you really would like multi-workspace support, feel free to mention so in this issue and I might eventually add support for it if there's enough demand.

Development

First get your dev environment started by running bun dev. Note that this expects you to have a few programs installed:

This command installs all JS and PHP dependencies and ensures you're ready to go for writing a PHPStan extension.

Running the extension

To run the extension, you can use the Launch Client task in VSCode. This will start a new VSCode window with the extension running. Use Client + Server to also attach the debugger to the language server.

Building the extension for production

To build for production or publish, use the VSCode Extension command (vsce). vsce package will build an installable .vsix file.

Good-to-know commands

The following command will run PHPStan on a demo file, this is handy for testing out changes to the PHPStan plugin that collects hover data.

php/vendor/bin/phpstan analyze -c php/config.neon -a php/TreeFetcher.php --debug test/demo/php/DemoClass.php