<?xml version="1.0"?>
<ruleset name="Divi5">
	<description>PHPCS Configuration for Divi 5 Builder Server</description>

	<!-- Check all PHP files in current directory. -->
	<file>.</file>

	<!-- Exclude patterns. -->
	<exclude-pattern>*/vendor/*</exclude-pattern>
	<exclude-pattern>*/__TESTS__/*</exclude-pattern>
	<exclude-pattern>*/__BENCH_TESTS__/*</exclude-pattern>
	<exclude-pattern>*/_all_modules_metadata.php</exclude-pattern>
	<exclude-pattern>*/_all_modules_default_printed_style_attributes.php</exclude-pattern>
	<exclude-pattern>*/.cursor/*</exclude-pattern>
	<!-- Default to D5-only linting; legacy is checked by the security rules below. -->
	<exclude-pattern>^((?!includes/builder-5/).)*$</exclude-pattern>

	<!-- Arguments. -->
	<arg value="sp"/>
	<arg name="colors"/>
	<arg name="extensions" value="php"/>
	<arg name="parallel" value="8"/>

	<!--
		Use ElegantThemes marketplace-phpcs standard.

		Why "marketplace-phpcs"?
		- Historical name from the ET Marketplace project where this standard originated.
		- Package lives in: https://github.com/elegantthemes/et-styles (Composer: elegantthemes/marketplace-phpcs).
		- Single source of truth for all ET projects (Divi, Bloom, Monarch, Marketplace).

		What it includes:
		- WordPress-Extra: Core WordPress coding standards (tabs, spacing, etc.).
		- WordPress-Docs: Documentation standards (PHPDoc).
		- PHPCompatibility: PHP version compatibility checks.
		- Custom ET sniffs: Security.BadFunctions, dangerous functions, deprecated functions.
		- Custom ET allowed functions: et_core_esc_*, et_builder_*, wp_kses_post, etc.

		What it already allows (no errors for):
		- PSR-4 file naming (e.g., TextModule.php instead of class-text-module.php).
		- Short array syntax [] (both array() and [] are valid).

		Note: We ADD DisallowLongArraySyntax below to ENFORCE [] and auto-convert array().
	-->
	<rule ref="marketplace-phpcs"/>

	<!-- ENFORCE short array syntax [] - converts array() to [] automatically. -->
	<!-- marketplace-phpcs allows [] but doesn't enforce it; this rule enforces it. -->
	<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

	<!-- Legacy files (outside builder-5) run security-only checks. -->
	<rule ref="WordPress.Security">
		<include-pattern>^((?!includes/builder-5/).)*$</include-pattern>
	</rule>
</ruleset>
