Skip to content

Instantly share code, notes, and snippets.

@mizner
Created February 19, 2023 23:40
Show Gist options
  • Save mizner/064d154f477850cafcd9df5e0831733b to your computer and use it in GitHub Desktop.
Save mizner/064d154f477850cafcd9df5e0831733b to your computer and use it in GitHub Desktop.
wp phpcs ruleset example
<?xml version="1.0"?>
<ruleset name="My Custom Ruleset">
<description>Custom ruleset for my PHP project</description>
<!-- exclude vendor -->
<exclude-pattern>vendor</exclude-pattern>
<!-- exclude WordPress core -->
<exclude-pattern>*/wp-includes/*</exclude-pattern>
<exclude-pattern>*/wp-admin/*</exclude-pattern>
<!-- Set config to add squizlabs standards to installed paths -->
<config name="installed_paths" value="vendor/wp-coding-standards/wpcs" />
<rule ref="WordPress-Extra">
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralDomain"/>
<exclude name="Generic.Arrays.DisallowLongArraySyntax"/>
<exclude name="Generic.Formatting.MultipleStatementAlignment"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing"/>
<exclude name="Generic.PHP.LowerCaseConstant"/>
<exclude name="Generic.PHP.LowerCaseKeyword"/>
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
<exclude name="Generic.WhiteSpace.ScopeIndent"/>
<exclude name="PSR12.Classes.AnonClassDeclaration"/>
<exclude name="Squiz.Classes.ValidClassName"/>
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="WordPress.Arrays.ArrayIndentation"/>
<rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment