PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 20, 2022

[FIXED] why vscode phpcs extension fails after removing PEAR coding standard folder

 May 20, 2022     composer-php, php, phpcs, visual-studio-code     No comments   

Issue

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.



Answered By - Greg Sherwood
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing