WordPress Coding Standards are well documented in detail in WordPress Developer Handbook. WordPress also offers a Github project, which maintains the WordPress Coding Standards rules and the tools needed to inspect and format the code (PHP Code Sniffer And Beautifier).
It is to keep in mind that, WordPress Coding Standards have notable differences from PSR (PHP Standard Recommendation), for example:
- snake case (
my_function_name
) - space around function arguments (
myfunction ( 'foo' )
) - long array syntax (
array()
instead of[]
) - and more
For Windows Users
1) NodeJS & NPM Installation
If NodeJS and NPM is not installed on system, Please find install NodeJS from link
https://nodejs.org/en/download
2) Composer Installation
If Composer tool is not installed on system, you need to install it first. PHP is also required to install composer,
Please install required version of PHP from this link
https://windows.php.net/download
then please install Composer from below link
https://nodejs.org/en/download
3) Download and Install WordPress Coding Standards
Create a Folder for Tools, better to create on some place where admin permissions are not required
E:\Program_Files\vscode-tools\phpcs
git clone https://github.com/WordPress/WordPress-Coding-Standards.git
cd WordPress-Coding-Standards
composer install
vendor/bin/phpcs -d phpcs -d memory_limit=2048M -ps . --standard=WordPress