<?xml version="1.0"?>
<ruleset name="KaiGen">
	<description>WordPress Coding Standards for KaiGen Plugin</description>

	<!-- What to scan -->
	<file>.</file>

	<!-- Exclude vendor and node_modules -->
	<exclude-pattern>*/vendor/*</exclude-pattern>
	<exclude-pattern>*/node_modules/*</exclude-pattern>
	<exclude-pattern>*/build/*</exclude-pattern>
	<exclude-pattern>*/tests/e2e/*</exclude-pattern>
	<exclude-pattern>*/playwright/*</exclude-pattern>
	<exclude-pattern>*.map</exclude-pattern>

	<!-- How to scan -->
	<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
	<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
	<arg value="sp"/> <!-- Show sniff and progress -->
	<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
	<arg name="colors"/>
	<arg name="extensions" value="php"/>
	<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->

	<!-- Rules: Check PHP version compatibility -->
	<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
	<config name="testVersion" value="7.0-"/>
	<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
	<rule ref="PHPCompatibilityWP">
		<!-- Ignore const visibility (PHP 7.1+) -->
		<exclude name="PHPCompatibility.Classes.NewConstVisibility.Found"/>
	</rule>

	<!-- Rules: WordPress Coding Standards -->
	<!-- https://github.com/WordPress/WordPress-Coding-Standards -->
	<!-- https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
	<config name="minimum_supported_wp_version" value="6.1"/>

	<rule ref="WordPress">
		<!-- Allow short array syntax -->
		<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
		<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
		<!-- Ignore class prefix requirement -->
		<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound"/>
		<!-- Ignore interface prefix requirement -->
		<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedInterfaceFound"/>
	</rule>

	<!-- Rules: WordPress Extra -->
	<rule ref="WordPress-Extra">
		<!-- Allow short array syntax -->
		<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
		<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
		<!-- Ignore class prefix requirement -->
		<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound"/>
		<!-- Ignore interface prefix requirement -->
		<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedInterfaceFound"/>
	</rule>

	<!-- Rules: WordPress VIP -->
	<!-- https://github.com/Automattic/VIP-Coding-Standards -->
	<!-- Uncomment to use WordPress VIP Coding Standards -->
	<!-- <rule ref="WordPress-VIP"/> -->

	<!-- Rules: Prevent some common PHP errors -->
	<rule ref="Generic.PHP.Syntax"/>

	<!-- Rules: WordPress.NamingConventions -->
	<!-- Allow camelCase for JavaScript-related code -->
	<!-- Plugin-specific: Allow KaiGen_ prefix for classes -->
	<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
		<properties>
			<property name="prefixes" type="array">
				<element key="0" value="KaiGen"/>
			</property>
		</properties>
	</rule>
</ruleset>
