<?xml version="1.0"?>
<ruleset name="FHComplete">
	<description>FHComplete's coding standard</description>

	<!-- Ignored directories -->
	<exclude-pattern>\.git</exclude-pattern>
	<exclude-pattern>vendor</exclude-pattern>
	<exclude-pattern>tests</exclude-pattern>
	<exclude-pattern>application/controllers/api/v1</exclude-pattern>
	<exclude-pattern>application/extensions</exclude-pattern>
	<exclude-pattern>addons</exclude-pattern>

	<!-- This ruleset is based mainly on the PSR2 standard ruleset, exluding the following rules: -->
	<rule ref="PSR2">
		<!-- Forces the use of namespaces -->
		<exclude name="PSR1.Classes.ClassDeclaration" />
		<!-- Forbids the use of underscores at the beginning of properties name -->
		<exclude name="PSR2.Classes.PropertyDeclaration" />
		<!-- Forbids the use of classes name that contain underscores -->
		<exclude name="Squiz.Classes.ValidClassName" />
		<!-- Forbids the use inline control structure (ex. an if statement on one line) -->
		<exclude name="Generic.ControlStructures.InlineControlStructure" />
		<!-- Forces to have the bracket on the same line of the statement -->
		<exclude name="Squiz.ControlStructures.ControlSignature" />
		<!-- Forces to have in a single file only a class declaration, an if statement outside the class is forbidden -->
		<exclude name="PSR1.Files.SideEffects" />
		<!-- Forbids to have an empty line at the end of the file -->
		<exclude name="PSR2.Files.EndFileNewline" />
		<!-- Forbids the use of underscores at the beginning of methods name -->
		<exclude name="PSR2.Methods.MethodDeclaration" />
		<!-- Forbids the use of tabs -->
		<exclude name="Generic.WhiteSpace.DisallowTabIndent" />
	</rule>

	<!-- Do not prompt any warning about the line length -->
	<!-- Prompt an error if the line length is more than 150 -->
	<rule ref="Generic.Files.LineLength">
		<properties>
			<property name="lineLimit" value="9999"/>
			<property name="absoluteLineLimit" value="150"/>
		</properties>
		<exclude-pattern>application/phrases/</exclude-pattern>
	</rule>

	<!-- No white spaces are allowed in array declaration between brackets -->
	<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>

	<!-- Ensures all class keywords are lowercase -->
	<rule ref="Squiz.Classes.LowercaseClassKeywords"/>

	<!-- Forbids the use of TODO in the comments -->
	<rule ref="Generic.Commenting.Todo"/>
	<!-- Tests that the stars in a doc comment align correctly -->
	<rule ref="Squiz.Commenting.DocCommentAlignment"/>

	<!-- Ensures the file ends with a newline character -->
	<rule ref="Generic.Files.EndFileNewline"/>

	<!-- Ensures there is no space after cast tokens -->
	<rule ref="Generic.Formatting.NoSpaceAfterCast"/>

	<!-- Ensures logical operators 'and' and 'or' are not used -->
	<rule ref="Squiz.Operators.ValidLogicalOperators"/>

	<!-- Ensure cast statements don't contain whitespace -->
	<rule ref="Squiz.WhiteSpace.CastSpacing"/>
	<!-- Verifies that operators have valid spacing surrounding them -->
	<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
	<!-- Checks that control structures are defined and indented correctly -->
	<!-- The listed tokens are ignored: comment, doc comment open tag, php close tag -->
	<rule ref="Generic.WhiteSpace.ScopeIndent">
		<properties>
			<property name="ignoreIndentationTokens" type="array">
				<element value="T_COMMENT"/>
				<element value="T_DOC_COMMENT_OPEN_TAG"/>
				<element value="T_CLOSE_TAG"/>
			</property>
		</properties>
	</rule>
	<!-- Ensure there is no whitespace before a semicolon -->
	<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>

	<!-- All rules in ./Sniffs are included automatically -->
	<!-- FHComplete sniffs:
		- Classes/FHCPropertyDeclarationSniff: class properties checks, it does not check if the property name starts with an underscore "_"
		- Classes/FHCValidClassNameSniff: class names checks, it does not check if the class name contains an underscore "_"
		- ControlStructures/FHCControlSignatureSniff:
			- Does not force to have whitespaces after the brackets
			- Allows to have a bracket at newline after a control structure
		- Methods/FHCMethodDeclarationSniff: it does not check if the method name starts with an underscore "_"
	-->
</ruleset>

