PHPCS coding standards


A pretty way to get your code withing the PHP Coding standards is using the PHP Code Sniffer tool.

If you are working in a Magento 2 site, the following snippet will be useful for you:

If you want to run the code sniffer for any PHP project, you can change the standard “Magento2” for whichever you want or none specific for everyone.

Afterwards, you can also use phpcbf to fix issues automattically, like this:

 

For more information you can check official PHPCS of Magento: here!