Browse Source

[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');
logmanoriginal 7 years ago
parent
commit
d8f5aa3c79
1 changed files with 16 additions and 0 deletions
  1. 16 0
      phpcs.xml

+ 16 - 0
phpcs.xml

@@ -21,6 +21,13 @@
       <property name="absoluteLineLimit" value="120"/>
     </properties>
   </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 -->
   <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
   <!-- Use lowercase for 'true', 'false' and 'null' -->
@@ -37,6 +44,15 @@
   <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
   <!-- Add a new line at the end of a file -->
   <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 -->
   <rule ref="Squiz.WhiteSpace.CastSpacing"/>
   <!-- Operators must have a space around them -->