[phpcs] Add sniffs for function declaration and -calls

When declaring a function
- Do not add a space before a comma
- Add a space after a comma
- Add a space after an equal sign

Example:
function myFunction($x, $y, $z = null){...}

When calling a function
- Do not add a space before the opening parenthesis
- Do not add a space after the opening parenthesis
- Do not add a space before the closing parenthesis
- Do not add a space before a comma
- Add a space after a comma

Example:
myFunction('x', 'y', 'z');
This commit is contained in:
logmanoriginal 2017-02-14 17:00:22 +01:00
parent 23430f1c07
commit d8f5aa3c79

View file

@ -21,6 +21,13 @@
<property name="absoluteLineLimit" value="120"/> <property name="absoluteLineLimit" value="120"/>
</properties> </properties>
</rule> </rule>
<!-- When calling a function: -->
<!-- Do not add a space before the opening parenthesis -->
<!-- Do not add a space after the opening parenthesis -->
<!-- Do not add a space before the closing parenthesis -->
<!-- Do not add a space before a comma -->
<!-- Add a space after a comma -->
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<!-- Use UPPERCARE for constants --> <!-- Use UPPERCARE for constants -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/> <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<!-- Use lowercase for 'true', 'false' and 'null' --> <!-- Use lowercase for 'true', 'false' and 'null' -->
@ -37,6 +44,15 @@
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/> <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<!-- Add a new line at the end of a file --> <!-- Add a new line at the end of a file -->
<rule ref="PSR2.Files.EndFileNewline"/> <rule ref="PSR2.Files.EndFileNewline"/>
<!-- When declaring a function: -->
<!-- Do not add a space before a comma -->
<!-- Add a space after a comma -->
<!-- Add a space before and after an equal sign -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
</properties>
</rule>
<!-- Do not add spaces when casting --> <!-- Do not add spaces when casting -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/> <rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Operators must have a space around them --> <!-- Operators must have a space around them -->