Skip to content

Instantly share code, notes, and snippets.



Last active Aug 5, 2020
What would you like to do?
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHP Code Sniffer configuration file.</description>
<!-- -->
<!-- check all these dirs/files -->
<!-- but don't check these -->
<!-- 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-->
<!-- -->
<!-- -->
<rule ref="PSR12">
<!-- add any exclusions here -->
<!-- Don't hide tokenizer exceptions -->
<rule ref="Internal.Tokenizer.Exception">
<!-- require 4 spaces, css -->
<rule ref="Squiz.CSS.Indentation">
<property name="indent" value="4" />
<!-- lines can be lineLimit chars long (warnings), errors at absoluteLineLimit chars -->
<rule ref="Generic.Files.LineLength">
<!-- 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"/>
<!-- ban some functions -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<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"/>

This comment has been minimized.

Copy link
Owner Author

@mbrowniebytes mbrowniebytes commented Aug 5, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment