<?xml version="1.0"?>
<ruleset name="FlexiLay Gateway for WooCommerce">
	<description>
		WordPress coding standards for the FlexiLay WooCommerce gateway.

		Run from this directory:
			phpcs            # report
			phpcbf           # auto-fix what can be fixed

		Requires: squizlabs/php_codesniffer, wp-coding-standards/wpcs,
		phpcsstandards/phpcsextra, phpcsstandards/phpcsutils.

		The plugin ships through two channels (wordpress.org and the Woo
		Marketplace), both of which review against these standards, so this file
		is committed rather than left to each developer's local setup.
	</description>

	<!-- Scan the plugin, but never the SVN tag copies: those are published
	     releases and must stay byte-identical to what shipped. -->
	<file>.</file>
	<exclude-pattern>*/node_modules/*</exclude-pattern>
	<exclude-pattern>*/vendor/*</exclude-pattern>

	<arg name="extensions" value="php"/>
	<arg name="colors"/>
	<arg value="sp"/>
	<arg name="parallel" value="8"/>

	<!--
		WordPress-Extra, not WordPress: "WordPress" additionally pulls in
		WordPress-Docs, which requires a docblock with @param/@return on EVERY
		function including one-line getters like get_api_key(). That produces 113
		tautological comments ("Get api key.") which satisfy the linter and tell a
		reader nothing. WordPress-Extra keeps everything substantive — escaping,
		sanitisation, nonces, SQL, i18n, prefixing, capabilities, WP best practice —
		which is also what wordpress.org's own Plugin Check enforces. Docblocks are
		written where they carry information rather than to satisfy a count.
	-->
	<rule ref="WordPress-Extra">
		<!-- The class-per-file naming rule expects class-{name}.php for every
		     class. The plugin groups small collaborating classes (for example the
		     Blocks integration declares both its payment-method type and its
		     registrar), which is deliberate and would mean splitting files purely
		     to satisfy the sniff. -->
		<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
		<exclude name="Generic.Files.OneObjectStructurePerFile"/>

		<!-- class-flexilay-blocks.php declares Flexilay_Blocks twice on purpose: a
		     no-op stub when WooCommerce Blocks is absent (followed immediately by
		     `return`), and the real implementation otherwise. Only one is ever
		     declared at runtime; the sniff cannot see the early return. -->
		<exclude name="Generic.Classes.DuplicateClassName"/>

		<!-- Yoda conditions ('foo' === $bar) guard against typing = instead of ==
		     in languages that do not warn. This plugin uses strict === throughout,
		     where a typo is a parse error, so the 36 rewrites this asks for would
		     reorder comparisons in payment code for no functional gain and no
		     auto-fixer to verify them. Deliberate deviation from WPCS. -->
		<exclude name="WordPress.PHP.YodaConditions"/>

		<!-- WordPress calls REST and hook callbacks with a fixed signature, so an
		     unused $req or $order_id is required, not dead. -->
		<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter"/>

		<!-- Flexilay_Woo_Options::get( $key, $default ) mirrors WordPress's own
		     get_option( $option, $default ) signature. Renaming it to satisfy the
		     sniff would make the plugin read less like its host. -->
		<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames"/>
	</rule>

	<!-- The sniff only knows core capabilities; these are WooCommerce's own. -->
	<rule ref="WordPress.WP.Capabilities">
		<properties>
			<property name="custom_capabilities" type="array">
				<element value="manage_woocommerce"/>
			</property>
		</properties>
	</rule>

	<!-- Text domain must match the plugin slug, or translations silently do
	     nothing. NOTE the Woo Marketplace build rewrites this to
	     flexilay-layby-payments; see plugins/woocommerce-marketplace/build.sh. -->
	<rule ref="WordPress.WP.I18n">
		<properties>
			<property name="text_domain" type="array">
				<element value="flexilay-gateway-for-woocommerce"/>
			</property>
		</properties>
	</rule>

	<!-- Everything global must carry one of these prefixes. -->
	<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
		<properties>
			<property name="prefixes" type="array">
				<element value="flexilay"/>
				<element value="FLEXILAY"/>
				<element value="Flexilay"/>
				<element value="FlexiLay"/>
			</property>
		</properties>
	</rule>

	<config name="minimum_wp_version" value="6.0"/>
	<config name="testVersion" value="7.4-"/>
</ruleset>
