'How to find phpcs current default standard
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
Solution 1:[1]
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
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mr.Thi |
Solution 2 | Patrick.SE |