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

	<description>Apply WordPress Coding Standards to UnderStrap</description>

	<!-- Only scan PHP files. -->
	<arg name="extensions" value="php"/>

	<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
	<arg name="cache"/>

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

	<!-- Show colors in console -->
	<arg value="-colors"/>

	<!-- Show sniff codes in all reports -->
	<arg value="s"/>

	<!-- Don't show warnings -->
	<arg value="n"/>

	<!-- Scan these files -->
	<file>.</file>

	<!-- Directories and third party library exclusions. -->
	<exclude-pattern>/vendor/*</exclude-pattern>
	<exclude-pattern>/node_modules/*</exclude-pattern>
	<exclude-pattern>/dist/*</exclude-pattern>

	<!-- Use the WordPress Ruleset -->
	<rule ref="WordPress"/>

	<!--
		Verify that the text_domain is set to the desired text-domain.
		Multiple valid text domains can be provided as a comma-delimited list.
	-->
	<rule ref="WordPress.WP.I18n">
		<properties>
			<property name="text_domain" type="array" value="understrap"/>
		</properties>
	</rule>

	<!--
		Allow for theme specific exceptions to the file name rules based
		on the theme hierarchy.
	-->
	<rule ref="WordPress.Files.FileName">
		<properties>
			<property name="is_theme" value="true"/>
		</properties>
	</rule>

	<!-- Assignments in while conditions are a valid method of looping over iterables. -->
	<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
		<exclude-pattern>*</exclude-pattern>
	</rule>

	<!-- Exclude incorrectly named files that won't be renamed. -->
	<rule ref="WordPress.Files.FileName.InvalidClassFileName">
		<exclude-pattern>/inc/class-wp-bootstrap-navwalker\.php</exclude-pattern>
	</rule>

	<rule ref="WordPress.Security.EscapeOutput">
		<!-- Exclude functions which are escaped in inc/extras.php -->
		<properties>
			<property name="customAutoEscapedFunctions" type="array">
				<element value="get_the_title"/>
				<element value="get_the_archive_title"/>
				<element value="get_the_archive_description"/>
			</property>
		</properties>
	</rule>

	<!-- 
		Exclude checking of line endings when reporting errors, but fix them
		when running phpcbf.
	-->
	<rule ref="Generic.Files.LineEndings">
		<exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
	</rule>

	<!-- A closing tag is not permitted at the end of a PHP file -->
	<rule ref="Zend.Files.ClosingTag"/>

	<!-- Use the PHPCompatibility Ruleset -->
	<config name="testVersion" value="5.6-99.0"/>
	<rule ref="PHPCompatibilityWP">
		<include-pattern>*\.php$</include-pattern>
	</rule>
</ruleset>
