Skip to content

Commit 602f1ca

Browse files
✨ Add more rules
1 parent b92d6fe commit 602f1ca

11 files changed

+51
-3
lines changed

SymfonyCustom/Sniffs/WhiteSpace/CloseBracketSpacingSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function register()
2222
return [
2323
T_CLOSE_CURLY_BRACKET,
2424
T_CLOSE_PARENTHESIS,
25+
T_CLOSE_SHORT_ARRAY,
2526
];
2627
}
2728

SymfonyCustom/Sniffs/WhiteSpace/OpenBracketSpacingSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function register()
2121
return [
2222
T_OPEN_CURLY_BRACKET,
2323
T_OPEN_PARENTHESIS,
24+
T_OPEN_SHORT_ARRAY,
2425
];
2526
}
2627

SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ testFunction( args1, args2 );
55
function f( ) { };
66

77
$array = array( 1, 2 );
8+
9+
$array = [ 1, 2 ];

SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.inc.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ testFunction( args1, args2);
55
function f() {};
66

77
$array = array( 1, 2);
8+
9+
$array = [ 1, 2];

SymfonyCustom/Tests/WhiteSpace/CloseBracketSpacingUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function getErrorList()
2525
3 => 1,
2626
5 => 2,
2727
7 => 1,
28+
9 => 1,
2829
];
2930
}
3031

SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ testFunction( args1, args2 );
55
function f( ) { };
66

77
$array = array( 1, 2 );
8+
9+
$array = [ 1, 2 ];

SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.inc.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ testFunction(args1, args2 );
55
function f() {};
66

77
$array = array(1, 2 );
8+
9+
$array = [1, 2 ];

SymfonyCustom/Tests/WhiteSpace/OpenBracketSpacingUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function getErrorList()
2525
3 => 1,
2626
5 => 2,
2727
7 => 1,
28+
9 => 1,
2829
];
2930
}
3031

SymfonyCustom/ruleset.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,20 @@
8181
<property name="ignoreNewlines" value="true"/>
8282
</properties>
8383
</rule>
84+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
85+
<properties>
86+
<property name="ignoreNewlines" value="true"/>
87+
</properties>
88+
</rule>
8489
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
8590
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
8691
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
8792
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
8893
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
94+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
95+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
96+
<properties>
97+
<property name="allowMultiline" value="true"/>
98+
</properties>
99+
</rule>
89100
</ruleset>

docs/standards.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,40 @@ we do not respect this rule:
122122
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
123123
```
124124

125-
- Add a single space before and after logical operator
125+
- Add a single space around logical operator (`&&`, `||`, `...`)
126126

127127
```
128128
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
129129
```
130130

131+
- Do not use space around object operators (`->`)
132+
133+
```
134+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
135+
<properties>
136+
<property name="ignoreNewlines" value="true"/>
137+
</properties>
138+
</rule>
139+
```
140+
141+
- Do not use unnecessary concat operator
142+
143+
```
144+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
145+
<properties>
146+
<property name="allowMultiline" value="true"/>
147+
</properties>
148+
</rule>
149+
```
150+
131151
### Custom
132152
- Some others checks are made about array (`=>` alignments and indentation)
133153

134154
```
135155
<rule ref="SymfonyCustom.Array.ArrayDeclaration"/>
136156
```
137157

138-
- Do not use spaces after `(` or `{` and before `)` or `}`
158+
- Do not use spaces after `(`, `{` or `[` and before `)`, `}` or `]`
139159

140160
```
141161
<rule ref="SymfonyCustom.WhiteSpace.CloseBracketSpacing"/>

docs/standards/symfony.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ From [symfony standard](http://symfony.com/doc/current/contributing/code/standar
1212
with the exception of the concatenation (`.`) operator
1313

1414
```
15-
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
15+
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
16+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
17+
<properties>
18+
<property name="ignoreNewlines" value="true"/>
19+
</properties>
20+
</rule>
1621
<rule ref="Squiz.Strings.ConcatenationSpacing">
1722
<properties>
1823
<property name="ignoreNewlines" value="true"/>

0 commit comments

Comments
 (0)