-2

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?

IT_man2018
  • 53
  • 7
  • You messed with an installed program's component and now the program doesn't work any more. Did I summarize that correctly? – Ulrich Eckhardt Jan 30 '22 at 17:03
  • @ulrich-eckhardt almost true. I deleted two folders from Composer's installation folder to get rid of those two coding standards since I don't want to use those two at all, and now the problem is vscode shows that error and php code sniffer extension doesn't performs its functionality anymore ! – IT_man2018 Jan 30 '22 at 17:38

1 Answers1

0

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.

Greg Sherwood
  • 6,992
  • 2
  • 29
  • 24
  • Greg thanks a lot for this Great explanation. really useful. just please correct these two: change "PSR12 then builds on PSR12" to "PSR12 then builds on PSR2." And also change "For example, running phpcs -e PSR12 shows..." to "For example, running phpcs -e --standard=PSR12 shows..." – IT_man2018 Jan 31 '22 at 04:09
  • Thanks. I have corrected those in my original reply. – Greg Sherwood Feb 01 '22 at 05:06