I am attempting to configure my phpcs.xml
(PHP CodeSniffer configuration file) so that I can exclude all directories from inspection within a folder except for those that I specify.
For those familiar with .gitignore
, an equivalent would be something like this so that "ButIncludeThisOne" is included in version control.
/ignoreContentsWithin/*
!/ignoreContentsWithin/ButIncludeThisOne
What I have tried
Here is my phpcs.xml
file:
<?xml version="1.0"?>
<ruleset name="MyRuleset">
...
<!-- Exclude Plugin Folders. -->
<exclude-pattern>/cms/wp-content/plugins/*</exclude-pattern>
<!-- But Inspect My Plugin Folder. -->
<include-pattern>/cms/wp-content/plugins/myplugin/*</include-pattern>
</ruleset>
Using the example above, I can specify every single folder within the plugins folder except for myplugin
and this works, but it is not ideal. (I would have to remember to exclude any new plugin from inspection)
If I remove the exclude-pattern
directive, files within the myplugin
folder are sniffed, so I know that it is working otherwise.