Skip to content
Snippets Groups Projects
phpcs.xml 5.24 KiB
<?xml version="1.0"?>
<ruleset name="CiviCRM.WordPress">

	<!-- Add source codes in the report. -->
	<arg value="s" />
	<arg name="colors" />

	<!-- Check all PHP files in directory tree by default. -->
	<arg name="extensions" value="php" />
	<file>.</file>

	<rule ref="WordPress">

		<!-- Allow slash-delimited hooks. -->
		<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores" />

		<!-- Ignore docblock formatting. -->
		<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType" />

		<!-- Allow CiviCRM control structures. -->
		<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.BlankLineAfterEnd" />

		<!-- Allow CiviCRM file headers. -->
		<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
		<exclude name="Squiz.Commenting.FileComment.WrongStyle" />

		<!-- Ignore arrow or equals alignment. -->
		<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
		<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />

		<!-- Ignore file-naming conventions. -->
		<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
		<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />

		<!-- Allow unreachable code in disabled Integration Page class for now. -->
		<exclude name="Squiz.PHP.NonExecutableCode.Unreachable" />

		<!-- Ignore any other rules that conflict with CiviCRM and civilint. -->
		<exclude name="Generic.Commenting.DocComment.MissingShort" />
		<exclude name="Generic.Commenting.DocComment.SpacingAfter" />
		<exclude name="Generic.Metrics.NestingLevel.MaxExceeded" />
		<exclude name="Generic.PHP.LowerCaseConstant.Found" />
		<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen" />
		<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose" />
		<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" />
		<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
		<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
		<exclude name="Squiz.Commenting.BlockComment.HasEmptyLineBefore" />
		<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
		<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen" />
		<exclude name="Squiz.PHP.CommentedOutCode.Found" />
		<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
		<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeOpen" />
		<exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterOpen" />
		<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd" />
		<exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE" />
		<exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakIndent" />
		<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
		<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
		<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
		<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
		<exclude name="PEAR.Functions.FunctionCallSignature.OpeningIndent" />
		<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" />
		<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" />
		<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions.NoSpacesAroundArrayKeys" />
		<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceAfterArrayOpener" />
		<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceBeforeArrayCloser" />
		<exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned" />
		<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine" />
		<exclude name="WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned" />
		<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase" />
		<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />
		<exclude name="WordPress.PHP.StrictInArray.MissingTrueStrict" />
		<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
		<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped" />
		<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis" />
		<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" />
		<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore" />
		<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter" />
		<exclude name="WordPress.WhiteSpace.PrecisionAlignment.Found" />

	</rule>

	<rule ref="WordPress.WP.I18n">
		<properties>
			<property name="text_domain" type="array" value="civicrm" />
		</properties>
	</rule>

	<!-- Allow short array syntax. -->
	<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
		<severity>0</severity>
	</rule>
	<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found" />

	<!-- Nesting levels. -->
	<rule ref="Generic.Metrics.NestingLevel">
		<properties>
			<property name="absoluteNestingLevel" value="5" />
		</properties>
	</rule>

	<!-- Ignore the CiviCRM Core subdirectory when present. -->
	<exclude-pattern>civicrm/civicrm/*</exclude-pattern>

	<!-- Ignore the following subdirectories for now. -->
	<exclude-pattern>wp-cli/*</exclude-pattern>
	<exclude-pattern>wp-rest/*</exclude-pattern>
	<exclude-pattern>tests/*</exclude-pattern>

</ruleset>