Setting up WordPress’s PHP coding standards for your theme
Setting up coding standards for your project is always a good idea. While it is ideal to start with one from the beginning, sometimes you have to do it after you’ve already written quite a bit of code (looks at Zuari π). Here is a quick guide on setting up the WordPress PHP Coding Standards for your theme or plugin:
For the purpose of this guide you’d need PHP and Composer installed locally, even if you are using docker for local development. We start by running composer init. This sets up the composer.json file and adds it to .gitignore. Next to get the phpcs and the WordPress coding standards, we run:
composer require squizlabs/php_codesniffer --dev composer require wp-coding-standards/wpcs --dev composer require dealerdirect/phpcodesniffer-composer-installer --dev composer require phpcompatibility/php-compatibility --dev

