<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
	<description>A custom set of code standard rules to check for WordPress themes and plugins.</description>

	<file>.</file>

	<arg name="extensions" value="php" />

	<exclude-pattern>dist</exclude-pattern>
	<exclude-pattern>node_modules</exclude-pattern>
	<exclude-pattern>vendor</exclude-pattern>
	<exclude-pattern>\.lando</exclude-pattern>
	<exclude-pattern>\.wordpress</exclude-pattern>

	<!-- Basic -->
	<rule ref="PHPCompatibility" />
	<config name="testVersion" value="7.4-" />

	<!-- Include the WordPress ruleset, with exclusions -->
	<rule ref="WordPress">
		<exclude name="Generic.Commenting.DocComment.MissingShort"/>
		<exclude name="Generic.Functions.CallTimePassByReference" />

		<exclude name="Squiz.Commenting.ClassComment.Missing" />
		<exclude name="Squiz.Commenting.FileComment.Missing" />
		<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
		<exclude name="Squiz.Commenting.FileComment.SpacingAfterComment" />
		<exclude name="Squiz.Commenting.FileComment.SpacingAfterOpen" />
		<exclude name="Squiz.Commenting.FileComment.WrongStyle" />
		<exclude name="Squiz.Commenting.FunctionComment.Missing" />
		<exclude name="Squiz.Commenting.FunctionComment.WrongStyle" />
		<exclude name="Squiz.Commenting.FunctionCommentThrowTag.WrongNumber" />
		<exclude name="Squiz.Commenting.VariableComment.Missing" />
	</rule>

	<!-- Include WordPress VIP ruleset, with exclusions -->
	<rule ref="./vendor/automattic/vipwpcs/WordPress-VIP-Go/ruleset.xml">
		<exclude name="WordPressVIPMinimum.JS.DangerouslySetInnerHTML" />
		<exclude name="WordPressVIPMinimum.JS.HTMLExecutingFunctions" />
		<exclude name="WordPressVIPMinimum.JS.InnerHTML" />
		<exclude name="WordPressVIPMinimum.JS.StringConcat" />
		<exclude name="WordPressVIPMinimum.JS.StrippingTags" />
		<exclude name="WordPressVIPMinimum.JS.Window" />

		<exclude name="WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__" />
		<exclude name="WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE" />
	</rule>

	<!-- Add missing checks from Plugin Check -->
	<rule ref="Generic.PHP.ForbiddenFunctions">
		<properties>
			<property name="forbiddenFunctions" type="array">
				<element key="move_uploaded_file" value="null"/>
				<element key="passthru" value="null"/>
				<element key="proc_open" value="null"/>
				<element key="create_function" value="null"/>
				<element key="eval" value="null"/>
				<element key="str_rot13" value="null"/>
			</property>
		</properties>
		<type>error</type>
		<severity>7</severity>
	</rule>

	<rule ref="Squiz.PHP.DiscouragedFunctions">
		<properties>
			<property name="forbiddenFunctions" type="array">
				<element key="set_time_limit" value="null"/>
				<element key="ini_set" value="null"/>
				<element key="ini_alter" value="null"/>
				<element key="dl" value="null"/>
			</property>
		</properties>
	</rule>
	<rule ref="WordPress.Security.ValidatedSanitizedInput.MissingUnslash">
		<type>warning</type>
		<severity>5</severity>
	</rule>

	<rule ref="WordPress.WP.I18n">
		<properties>
			<property name="text_domain" type="array">
				<element value="nelio-maps"/>
			</property>
		</properties>
	</rule>

	<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
		<properties>
			<property name="prefixes" type="array">
				<element value="nelio_maps"/>
			</property>
		</properties>
		<exclude-pattern>phpstan.dynamic.neon.php</exclude-pattern>
	</rule>

	<rule ref="WordPress.DB.SlowDBQuery.slow_db_query_meta_key">
		<type>warning</type>
		<severity>5</severity>
	</rule>

	<!-- Prevent warnings on some files/folders -->
	<rule ref="WordPress.Files.FileName">
		<exclude-pattern>phpstan.dynamic.neon.php</exclude-pattern>
	</rule>
	<rule ref="WordPress.Files.FileName.InvalidClassFileName">
		<exclude-pattern>php-stubs/*</exclude-pattern>
	</rule>
	<rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
		<exclude-pattern>php-stubs/*</exclude-pattern>
	</rule>
	<rule ref="Squiz.Commenting.FunctionComment.InvalidNoReturn">
		<exclude-pattern>php-stubs/*</exclude-pattern>
	</rule>
	<rule ref="Universal.Namespaces.DisallowCurlyBraceSyntax.Forbidden">
		<exclude-pattern>php-stubs/*</exclude-pattern>
	</rule>
	<rule ref="Universal.Namespaces.OneDeclarationPerFile.MultipleFound">
		<exclude-pattern>php-stubs/*</exclude-pattern>
	</rule>

</ruleset>
