• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / WordPress CodeSniffer phpcs.xml

WordPress CodeSniffer phpcs.xml

Last updated on January 15, 2019 by Sal Ferrarello

I’ve been using PHP CodeSniffer to help me following coding standards. The WordPress Coding Standards (wpcs) are a great resource and the basis of the rules I follow. I have made a few modifications based on my personal preferences.

You can download this to your project directly from the command line with

curl -O https://gist.githubusercontent.com/salcode/57b1d8018624c73b10015faa29e6acb2/raw/.phpcs.xml.dist
<?xml version="1.0"?>
<ruleset name="Iron Code Studio">
<description>The PHP CodeSniffer rules used by Sal Ferrarello (salcode) for his Iron Code Studio projects.</description>
<!--
You can download this file directly
to your project from the command-line with
curl -O https://gist.githubusercontent.com/salcode/57b1d8018624c73b10015faa29e6acb2/raw/.phpcs.xml.dist
-->
<!-- Exclude the Composer Vendor directory. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<!-- Exclude the Node Modules directory. -->
<exclude-pattern>/node_modules/*</exclude-pattern>
<!-- Exclude all Javascript files. -->
<exclude-pattern>*.js</exclude-pattern>
<!-- Exclude minified CSS file. -->
<exclude-pattern>style.css</exclude-pattern>
<!-- Include the WordPress-Extra standard. -->
<rule ref="WordPress-Extra">
<!--
Example of removing a rule.
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing"/>
-->
</rule>
<!-- Add in some extra rules from other standards. -->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfter"/>
<!-- Only enforce aligning assignment operators when difference is 2 or less. -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="2" />
</properties>
</rule>
<!-- Do not follow WordPress class name naming requirements -->
<rule ref="WordPress.Files.FileName">
<properties>
<property name="strict_class_file_names" value="false" />
</properties>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="fe_"/>
</properties>
</rule>
</ruleset>
view raw .phpcs.xml.dist hosted with ❤ by GitHub
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Programming Tagged With: code standards, WordPress

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in