<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">

	<!-- Set a description for this ruleset. -->
	<description>PHP 7.4+ coding standards for WordPress projects.</description>

	<!--
    	PHP 7.4 and higher.
	-->
	<config name="testVersion" value="7.4-"/>

	<!--
	#############################################################################
	COMMAND LINE ARGUMENTS
	https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
	#############################################################################
	-->

	<!-- Pass some flags to PHPCS:
		 p flag: Show progress of the run.
		 s flag: Show sniff codes in all reports.
	-->
	<arg value="ps"/>

	<!-- Strip the filepaths down to the relevant bit. -->
	<arg name="basepath" value="."/>

	<!-- Check up to 8 files simultanously. -->
	<arg name="parallel" value="20"/>

	<!-- Only check the PHP files. JS, and CSS files are checked separately with @wordpress/scripts package. -->
	<arg name="extensions" value="php"/>

	<!-- Check all files in this directory and the directories below it. -->
    <file>./</file>

	<!-- Exclude patterns. -->
    <exclude-pattern>./vendor/*</exclude-pattern>
    <exclude-pattern>./.codeception/*</exclude-pattern>
    <exclude-pattern>./.tests/*</exclude-pattern>
    <exclude-pattern>./deploy.php</exclude-pattern>
	<!--
    PSR 12 Code style.
    See http://www.php-fig.org/psr/psr-12/
    -->
    <rule ref="PSR12">
        <exclude name="Generic.Files.LineLength.TooLong"/>
        <exclude name="PSR12.Properties.ConstantVisibility"/>
    </rule>

    <!--
    Neutron standard are quality tools for PHP7 development from Automattic.
    See https://github.com/Automattic/phpcs-neutron-standard
    -->
    <rule ref="NeutronStandard.AssignAlign.DisallowAssignAlign">
        <type>warning</type>
    </rule>
    <rule ref="NeutronStandard.Functions.DisallowCallUserFunc">
        <type>warning</type>
    </rule>
    <rule ref="NeutronStandard.Globals.DisallowGlobalFunctions">
	   <type>warning</type>
    </rule>
    <rule ref="NeutronStandard.MagicMethods.DisallowMagicSerialize">
        <type>warning</type>
    </rule>
    <rule ref="NeutronStandard.StrictTypes.RequireStrictTypes">
       <type>warning</type>
    </rule>
    <rule ref="NeutronStandard.Whitespace.DisallowMultipleNewlines">
        <type>warning</type>
    </rule>
    <rule ref="NeutronStandard.Whitespace.RequireNewlineBetweenFunctions">
        <type>warning</type>
    </rule>

    <!-- Use WordPress standard and remove settings not needed.  -->
    <rule ref="WordPress.WP.I18n">
        <exclude name="WordPress.WP.I18n.NonSingularStringLiteralText"/>
        <exclude name="WordPress.WP.I18n.NonSingularStringLiteralDomain"/>
    </rule>

    <!--
    Curated list of WordPress specific rules.
    See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
    -->
    <rule ref="WordPress.Arrays.CommaAfterArrayItem"/>
    <rule ref="WordPress.CodeAnalysis.AssignmentInCondition"/>
    <rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
    <rule ref="WordPress.CodeAnalysis.EscapedNotTranslated"/>
    <rule ref="WordPress.DB.PreparedSQLPlaceholders"/>
    <rule ref="WordPress.DB.PreparedSQL"/>
    <rule ref="WordPress.DB.RestrictedClasses"/>
    <rule ref="WordPress.DB.RestrictedFunctions"/>
    <rule ref="WordPress.DateTime.CurrentTimeTimestamp"/>
    <rule ref="WordPress.NamingConventions.PrefixAllGlobals"/>
    <rule ref="WordPress.NamingConventions.ValidHookName">
        <properties>
            <property name="additionalWordDelimiters" value="-/."/>
        </properties>
    </rule>
    <rule ref="WordPress.NamingConventions.ValidPostTypeSlug"/>
    <rule ref="WordPress.PHP.DevelopmentFunctions"/>
    <rule ref="WordPress.PHP.DevelopmentFunctions.error_log">
        <type>error</type>
    </rule>
    <rule ref="WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure">
        <type>error</type>
    </rule>
    <rule ref="WordPress.PHP.RestrictedPHPFunctions"/>
    <rule ref="WordPress.PHP.DiscouragedPHPFunctions">
        <properties>
            <property name="exclude" type="array" value="serialize,urlencode,obfuscation"/>
        </properties>
    </rule>
    <rule ref="WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration">
        <type>error</type>
    </rule>
    <rule ref="WordPress.PHP.DontExtract"/>
    <rule ref="WordPress.PHP.IniSet"/>
    <rule ref="WordPress.PHP.NoSilencedErrors"/>
    <rule ref="WordPress.PHP.POSIXFunctions"/>
    <rule ref="WordPress.PHP.PregQuoteDelimiter"/>
    <rule ref="WordPress.PHP.RestrictedPHPFunctions"/>
    <rule ref="WordPress.PHP.StrictComparisons">
        <exclude name="WordPress.PHP.StrictComparisons.LooseComparison" />
    </rule>
    <rule ref="WordPress.PHP.StrictInArray"/>
    <rule ref="WordPress.PHP.TypeCasts"/>
    <rule ref="WordPress.Security.EscapeOutput"/>
    <rule ref="WordPress.Security.NonceVerification"/>
    <rule ref="WordPress.Security.PluginMenuSlug"/>
    <rule ref="WordPress.Security.SafeRedirect"/>
    <rule ref="WordPress.Security.ValidatedSanitizedInput"/>
    <rule ref="WordPress.WP.AlternativeFunctions.curl"/>
    <rule ref="WordPress.WP.AlternativeFunctions.file_get_contents"/>
    <rule ref="WordPress.WP.AlternativeFunctions.file_system_read"/>
    <rule ref="WordPress.WP.AlternativeFunctions.strip_tags"/>
    <rule ref="WordPress.WP.AlternativeFunctions.rand_seeding"/>
    <rule ref="WordPress.WP.AlternativeFunctions.rand"/>
    <rule ref="WordPress.WP.CapitalPDangit"/>
    <rule ref="WordPress.WP.DeprecatedClasses"/>
    <rule ref="WordPress.WP.DeprecatedFunctions"/>
    <rule ref="WordPress.WP.DeprecatedParameters"/>
    <rule ref="WordPress.WP.DeprecatedParameterValues"/>
    <rule ref="WordPress.WP.DiscouragedConstants"/>
    <rule ref="WordPress.WP.DiscouragedFunctions"/>
    <rule ref="WordPress.WP.EnqueuedResourceParameters"/>
    <rule ref="WordPress.WP.EnqueuedResources"/>
    <rule ref="WordPress.WP.I18n"/>

    <!--
    Curated list of WordPress VIP rules.
    See https://github.com/Automattic/VIP-Coding-Standards/
    -->
    <rule ref="WordPressVIPMinimum.Classes.DeclarationCompatibility"/>
    <rule ref="WordPressVIPMinimum.Constants.ConstantString"/>
    <rule ref="WordPressVIPMinimum.Constants.RestrictedConstants"/>
    <rule ref="WordPressVIPMinimum.Files.IncludingNonPHPFile"/>
    <rule ref="WordPressVIPMinimum.Functions.CheckReturnValue"/>
    <rule ref="WordPressVIPMinimum.Functions.DynamicCalls"/>
    <rule ref="WordPressVIPMinimum.Functions.StripTags"/>
    <rule ref="WordPressVIPMinimum.Hooks.AlwaysReturnInFilter"/>
    <rule ref="WordPressVIPMinimum.Hooks.PreGetPosts"/>
    <rule ref="WordPressVIPMinimum.Performance.CacheValueOverride"/>
    <rule ref="WordPressVIPMinimum.Performance.RegexpCompare"/>
    <rule ref="WordPressVIPMinimum.Performance.TaxonomyMetaInOptions"/>
    <rule ref="WordPressVIPMinimum.Security.EscapingVoidReturnFunctions"/>
    <rule ref="WordPressVIPMinimum.Security.ExitAfterRedirect"/>
    <rule ref="WordPressVIPMinimum.Security.PHPFilterFunctions"/>
    <rule ref="WordPressVIPMinimum.Security.ProperEscapingFunction"/>
    <rule ref="WordPressVIPMinimum.Security.StaticStrreplace"/>

    <!--
    Generic
    -->
    <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
    <rule ref="Generic.Metrics.CyclomaticComplexity">
        <properties>
            <property name="absoluteComplexity" value="50"/>
        </properties>
    </rule>
    <rule ref="Generic.NamingConventions.ConstructorName"/>
    <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
    <rule ref="Generic.PHP.LowerCaseConstant"/>
    <rule ref="Generic.VersionControl.GitMergeConflict"/>
    <rule ref="Squiz.Classes.LowercaseClassKeywords"/>
    <rule ref="Squiz.PHP.CommentedOutCode">
        <properties>
            <property name="maxPercentage" value="45"/>
        </properties>
    </rule>
    <rule ref="Squiz.PHP.Eval"/>
    <rule ref="Squiz.PHP.InnerFunctions"/>
    <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
    <rule ref="Squiz.PHP.NonExecutableCode"/>
    <rule ref="Squiz.Scope.MemberVarScope"/>
    <rule ref="Squiz.Scope.StaticThisUsage"/>

    <!--
    PHPCompatibility
    -->
    <rule ref="PHPCompatibility"/>

    <!--
    Use own rules :)
    -->
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/ArgumentTypeDeclarationSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/ConstantVisibilitySniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/DisallowShortOpenTagSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/ElementNameMinimalLengthSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/ForbiddenPublicPropertySniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/FunctionBodyStartSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/FunctionLengthSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/NestingLevelSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/NoAccessorsSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/NoElseSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/NoTopLevelDefineSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/PropertyPerClassLimitSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/Psr4Sniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/ReturnTypeDeclarationSniff.php"/>
    <rule ref="./vendor/inpsyde/php-coding-standards/Inpsyde/Sniffs/CodeQuality/StaticClosureSniff.php"/>
    
</ruleset>
