wongjn / vscode-php-sniffer

Visual Studio Code extension for PHP_Codesniffer validation and formatting.
https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer
MIT License
46 stars 7 forks source link
lint-php php-codesniffer php-sniffer vscode-extension

PHP Sniffer

Build Status PHP Sniffer on the Visual Studio Marketplace

Uses PHP_CodeSniffer to format and lint (mainly) PHP code.

Features

Requirements

Extension Settings

Quick Setup

settings.json:

{
  "phpSniffer.autoDetect": true
}

And if your projects look like this:

workspace-folder/
  vendor/
    bin/
      phpcs
      phpcbf
  .phpcs.xml

Validation and formatting will work (see below for alternative filenames for .phpcs.xml).

In Depth

This extension contributes the following settings:

Known Issues

Windows Hanging PHP Process

When phpcs encounters a malformed array declaration, it can sometimes hang from an error. This is exacerbated by the fact that we do not have access to the spawned php process in the extension code and cannot kill php.exe directly. This causes many non-exiting PHP processes on Windows machines which can really slow down the machine. The fix for this is to update squizlabs/PHP_Codesniffer in use to >=3.4.2.