This is my ruleset for PHP CodeSniffer. It's based on the PSR-12 Extended Coding Style, enhanced with sniffs from the Slevomat Coding Standard.
composer require --dev squizlabs/php_codesniffer nicwortel/coding-standard
Create a phpcs.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<!-- Show progress and sniff names -->
<arg value="ps" />
<file>src/</file>
<rule ref="NicWortel"/>
</ruleset>
Then you can run vendor/bin/phpcs
.