Skip to content

Commit

Permalink
[phpcs] Add sniffs for function declaration and -calls
Browse files Browse the repository at this point in the history
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');
  • Loading branch information
logmanoriginal committed Feb 14, 2017
1 parent 23430f1 commit d8f5aa3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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' -->
Expand All @@ -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 -->
Expand Down

0 comments on commit d8f5aa3

Please sign in to comment.