5

I want to know my current PHPCS standard in Visual Studio

e.g:

 {
     "phpcs.standard": "PSR2"
 }

how to set it is given in the documentation

phpcs --config-set default_standard value

1
  • 6
    You might be looking for the command phpcs --config-show Commented Dec 27, 2018 at 21:50

2 Answers 2

5

when you config

phpcs --config-set default_standard value

a message will show up like:

Using config file: /home/yourpc/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf

so, the configuration will be storage in:

/home/yourpc/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf
Sign up to request clarification or add additional context in comments.

1 Comment

If you want to use the local phpcs instead of the global phpcs, run vendor/bin/phpcs --confi-set instead
3

You can run phpcs with -i to print your installed standards:

~$ phpcs -i
The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, Universal, NormalizedArrays, PHPCS23Utils, PHPCSUtils, NoGetCurrentUser, VariableAnalysis, WordPress, WordPress-Extra, WordPress-Docs, WordPress-Core, IsolatedTests, WordPress-Core, WordPress and WordPress-Docs

You can get information on where these standards are being pulled from, as well as which configuration file is in use by calling phpcs with the --config-show flag:

~$ phpcs --config-show
Using config file: /Users/pz/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer.conf

installed_paths: /Users/pz/.composer/vendor/phpcsstandards/phpcsextra,/Users/pz/.composer/vendor/phpcsstandards/phpcsutils,/Users/pz/.composer/vendor/sirbrillig/phpcs-no-get-current-user,/Users/pz/.composer/vendor/sirbrillig/phpcs-variable-analysis,/Users/pz/.composer/vendor/wp-coding-standards/wpcs,/Users/pz/Code/wpcom/bin/metrics/shared/phpcs-coding-standards/IsolatedTests,/Users/pz/Code/wpcom/bin/metrics/shared/phpcs-coding-standards/WordPress-Coding-Standards/WordPress-Core,/Users/pz/Code/wpcom/bin/metrics/shared/phpcs-coding-standards/WordPress-Coding-Standards/WordPress,/Users/pz/Code/wpcom/bin/metrics/shared/phpcs-coding-standards/WordPress-Coding-Standards/WordPress-Docs

It's worth mentioning that if you have a phpcs.xml file in your project phpcs will try to discover and use that by default. If you want to run it with a specific standard, you will use the --standard flag:

phpcs --standard=Pear <option filepath etc>

The usage page on the repository is quite comprehensive.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.