Custom PHPCS sniffs for enforcing additional coding standards on DemandDrive PHP projects.
Install via Composer:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/digitalimpulse/coding-standards"
}
],
"require": {
"digitalimpulse/php-coding-standards": "v0.1.1"
}
}Create a phpcs.xml or phpcs.xml.dist file in your project root:
<?xml version="1.0"?>
<ruleset name="My Project Standards">
<!-- Include DemandDrive standards -->
<rule ref="DemandDrive"/>
<!-- Project-specific configuration -->
<file>.</file>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<!-- Override specific rules if needed -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="my-textdomain"/>
</property>
</properties>
</rule>
</ruleset>- Create a new sniff class in
src/Standards/DemandDrive/Sniffs/Category/SniffNameSniff.php - Implement the
Sniffinterface - Add the sniff rule to
src/Standards/DemandDrive/ruleset.xml - Create tests in
tests/Category/SniffNameSniffTest.php