<?xml version="1.0"?>
<ruleset name="WordPress Extra">
	<description>Best practices beyond core WordPress Coding Standards</description>

	<autoload>./../WordPress/PHPCSAliases.php</autoload>

	<!-- Generic PHP best practices.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/382 -->
	<rule ref="Generic.PHP.DeprecatedFunctions"/>
	<rule ref="Generic.PHP.ForbiddenFunctions"/>
	<rule ref="Generic.Functions.CallTimePassByReference"/>
	<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
	<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
	<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
	<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
	<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
	<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
	<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
	<rule ref="Generic.Classes.DuplicateClassName"/>
	<rule ref="Generic.Strings.UnnecessaryStringConcat">
		<properties>
			<property name="allowMultiline" value="true"/>
		</properties>
	</rule>
	<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>

	<!-- Duplicate of upstream. Can be removed once minimum PHPCS requirement has gone up.
		 https://github.com/squizlabs/PHP_CodeSniffer/pull/1594 -->
	<rule ref="WordPress.CodeAnalysis.AssignmentInCondition"/>

	<!-- More generic PHP best practices.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/607 -->
	<rule ref="Squiz.PHP.NonExecutableCode"/>
	<rule ref="Squiz.Operators.IncrementDecrementUsage"/>
	<rule ref="Squiz.Operators.ValidLogicalOperators"/>
	<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>

	<!-- And even more generic PHP best practices.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/809 -->
	<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>

	<!-- And yet more best practices.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1143 -->
	<rule ref="PEAR.Files.IncludingFile">
		<exclude name="PEAR.Files.IncludingFile.UseInclude"/>
		<exclude name="PEAR.Files.IncludingFile.UseIncludeOnce"/>
	</rule>
	<rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
		<type>warning</type>
	</rule>
	<rule ref="PEAR.Files.IncludingFile.UseRequire">
		<type>warning</type>
	</rule>
	<rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
		<type>warning</type>
	</rule>

	<!-- Check correct spacing of language constructs. This also ensures that the
	     above rule for not using brackets with require is fixed correctly.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1153 -->
	<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>

	<!-- Hook callbacks may not use all params -->
	<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/382#discussion_r29981655 -->
	<!--<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>-->

	<!-- Encourage having only one class/interface/trait per file. -->
	<!-- Once the minimum WPCS PHPCS requirement has gone up to PHPCS 3.1.0, these three sniffs can be
	     replaced by the more comprehensive Generic.Files.OneObjectStructurePerFile sniff. -->
	<rule ref="Generic.Files.OneClassPerFile"/>
	<rule ref="Generic.Files.OneClassPerFile.MultipleFound">
		<type>warning</type>
		<message>Best practice suggestion: Declare only one class in a file.</message>
	</rule>
	<rule ref="Generic.Files.OneInterfacePerFile"/>
	<rule ref="Generic.Files.OneInterfacePerFile.MultipleFound">
		<type>warning</type>
		<message>Best practice suggestion: Declare only one interface in a file.</message>
	</rule>
	<rule ref="Generic.Files.OneTraitPerFile"/>
	<rule ref="Generic.Files.OneTraitPerFile.MultipleFound">
		<type>warning</type>
		<message>Best practice suggestion: Declare only one trait in a file.</message>
	</rule>

	<rule ref="WordPress-Core"/>

	<!-- Verify modifier keywords for declared methods and properties in classes.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1101 -->
	<rule ref="Squiz.Scope.MethodScope"/>
	<rule ref="Squiz.Scope.MemberVarScope"/>
	<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
	<rule ref="PSR2.Methods.MethodDeclaration"/>
	<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
		<type>warning</type>
	</rule>

	<!-- Warn against using fully-qualified class names instead of the self keyword. -->
	<rule ref="Squiz.Classes.SelfMemberReference.NotUsed">
		<!-- Restore default severity of 5 which WordPress-Core sets to 0. -->
		<severity>5</severity>
	</rule>

	<rule ref="WordPress.XSS.EscapeOutput"/>

	<!-- Verify that a nonce check is done before using values in superglobals.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/73 -->
	<rule ref="WordPress.CSRF.NonceVerification"/>

	<rule ref="WordPress.PHP.DevelopmentFunctions"/>
	<rule ref="WordPress.PHP.DiscouragedPHPFunctions"/>
	<rule ref="WordPress.WP.DeprecatedFunctions"/>
	<rule ref="WordPress.WP.DeprecatedClasses"/>
	<rule ref="WordPress.WP.DeprecatedParameters"/>
	<rule ref="WordPress.WP.AlternativeFunctions"/>
	<rule ref="WordPress.WP.DiscouragedConstants"/>
	<rule ref="WordPress.WP.DiscouragedFunctions"/>

	<!-- Scripts & style should be enqueued.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/35 -->
	<rule ref="WordPress.WP.EnqueuedResources"/>

	<!-- Warn against overriding WP global variables.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/26 -->
	<rule ref="WordPress.Variables.GlobalVariables"/>

	<!-- Encourage the use of strict ( === and !== ) comparisons.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/242 -->
	<rule ref="WordPress.PHP.StrictComparisons"/>

	<!-- Check that in_array() and array_search() use strict comparisons.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/399
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/503 -->
	<rule ref="WordPress.PHP.StrictInArray"/>

	<!-- Discourage use of the backtick operator (execution of shell commands).
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/646 -->
	<rule ref="Generic.PHP.BacktickOperator"/>

	<!-- Check for PHP Parse errors.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/522 -->
	<rule ref="Generic.PHP.Syntax"/>

	<!-- Make the translators comment check which is included in core stricter. -->
	<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
		<type>error</type>
	</rule>
	<rule ref="WordPress.WP.I18n.TranslatorsCommentWrongStyle">
		<type>error</type>
	</rule>

	<!-- Verify that everything in the global namespace is prefixed. -->
	<rule ref="WordPress.NamingConventions.PrefixAllGlobals"/>

	<!-- Check that object instantiations always have braces & are not assigned by reference.
		 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/919 -->
	<rule ref="WordPress.Classes.ClassInstantiation"/>


	<!--
	#############################################################################
	Code style sniffs for more recent PHP features and syntaxes.
	#############################################################################
	-->

	<!-- Check for single blank line after namespace declaration. -->
	<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>

</ruleset>
