<?xml version="1.0"?> | |
<ruleset name="PHP_CodeSniffer"> | |
<description>PHP Code Sniffer configuration file.</description> | |
<!-- https://github.com/squizlabs/PHP_CodeSniffer --> | |
<!-- check all these dirs/files --> | |
<file>app</file> | |
<file>bin</file> | |
<file>cfg</file> | |
<file>src</file> | |
<!-- but don't check these --> | |
<exclude-pattern>composer$</exclude-pattern> | |
<exclude-pattern>public$</exclude-pattern> | |
<!-- phpcs argument options --> | |
<arg name="basepath" value="./"/> | |
<arg name="colors"/> | |
<arg name="tab-width" value="4"/> | |
<arg name="extensions" value="php,js,css"/> | |
<!-- how many files to check at once --> | |
<arg name="parallel" value="10"/> | |
<!-- base rule: set to PSR12--> | |
<!-- https://www.php-fig.org/psr/psr-12/ --> | |
<!-- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties --> | |
<rule ref="PSR12"> | |
<!-- add any exclusions here --> | |
</rule> | |
<!-- Don't hide tokenizer exceptions --> | |
<rule ref="Internal.Tokenizer.Exception"> | |
<type>error</type> | |
</rule> | |
<!-- require 4 spaces, css --> | |
<rule ref="Squiz.CSS.Indentation"> | |
<properties> | |
<property name="indent" value="4" /> | |
</properties> | |
</rule> | |
<!-- lines can be lineLimit chars long (warnings), errors at absoluteLineLimit chars --> | |
<rule ref="Generic.Files.LineLength"> | |
<properties> | |
<!-- 120 is PSR12; cannot be 0; large for sql, arrays --> | |
<property name="lineLimit" value="360"/> | |
<!-- 0 to not show as error --> | |
<property name="absoluteLineLimit" value="0"/> | |
</properties> | |
</rule> | |
<!-- ban some functions --> | |
<rule ref="Generic.PHP.ForbiddenFunctions"> | |
<properties> | |
<property name="forbiddenFunctions" type="array"> | |
<element key="sizeof" value="count"/> | |
<element key="delete" value="unset"/> | |
<element key="print" value="echo"/> | |
<element key="is_null" value="null"/> | |
<element key="create_function" value="null"/> | |
</property> | |
</properties> | |
</rule> | |
</ruleset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Example PHP CodeSniffer phpcs.xml using PSR12 as a base rule, plus adding in app dirs, excluding some shared libs/dirs, and some rules exclusions due to app.