phpvisual-studio-codecomposer-phpphpcs

why vscode phpcs extension fails after removing PEAR coding standard folder


I was going to remove (uninstall) PEAR and Zend standards from my phpcs (provided by composer installation in my windows 11)

according to this answer i manually deleted these two folders (PEAR and Zend) from below location:

C:\Users\myusername\AppData\Roaming\Composer\vendor\squizlabs\php_codesniffer\src\Standards

Now there is no PEAR and Zend in the result of phpcs -i command as expected but I've encountered below error every time I run vscode:

ERROR: Referenced sniff "PEAR.Functions.ValidDefaultValue" does not exist Run "phpcs --help" for usage information

https://s21.picofile.com/file/8447163976/vscode_error.PNG

Also "PHP sniffer" extension doesn't work any more and doesn't show violations anymore in my php script!

I checked vscode's "settings.json" file but there is not any rule containing PEAR or Zend in it!

Further information:

Composer is installed using compower-setup.exe file in windows 11.

vscode version 1.63.2

vscode extension: php Sniffer by wongjn

What's wrong with this? was manually deleting those standard folders there right way to uninstall those standards from system?


Solution

  • The included coding standards all borrow from each other. PEAR is the oldest standard and so most of the newer ones build upon it, including PSR2. PSR12 then builds on PSR2. So these standards reference sniffs in other standards.

    Do not remove any folders from the core PHPCS installation, even if you don't need the standards. Especially the Generic, PEAR, and Squiz folders. You will 100% break other standards if you remove any of these.

    If you want to see what sniffs are used by a standard, you can run phpcs -e --standard=STANDARD

    For example, running phpcs -e --standard=PSR12 shows that the PSR12 standard includes 60 sniffs from 6 different standards.