Skip to content

Commit 6594d3c

Browse files
gsherwoodjrfnl
authored andcommitted
Added ignoreSpacingBeforeAssignments property for Squiz.WhiteSpace.OperatorSpacing (ref #2515)
1 parent d478abc commit 6594d3c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

wiki/Customisable-Sniff-Properties.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,11 +1348,12 @@ This sniff ensures there are no spaces surrounding an object operator. Sometimes
13481348

13491349
### Squiz.WhiteSpace.OperatorSpacing
13501350

1351-
Property Name | Type | Default | Available Since
1352-
-------------- | ---- | ------- | ---------------
1353-
ignoreNewlines | bool | false | 2.2.0
1351+
Property Name | Type | Default | Available Since
1352+
------------------------------ | ---- | ------- | ---------------
1353+
ignoreNewlines | bool | false | 2.2.0
1354+
ignoreSpacingBeforeAssignments | bool | true | 3.5.0
13541355

1355-
This sniff ensures there is one space before and after an operators. Sometimes long statements are broken over multiple lines to work within a maximum line length, but this sniff will generate an error for these cases by default. Setting the `ignoreNewlines` property to `true` will allow newline characters before or after an operator, and any required padding for alignment.
1356+
This sniff ensures there is one space before and after an operator. Sometimes long statements are broken over multiple lines to work within a maximum line length, but this sniff will generate an error for these cases by default. Setting the `ignoreNewlines` property to `true` will allow newline characters before or after an operator, and any required padding for alignment.
13561357

13571358
```xml
13581359
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
@@ -1362,6 +1363,16 @@ This sniff ensures there is one space before and after an operators. Sometimes l
13621363
</rule>
13631364
```
13641365

1366+
A number of coding standards allow multiple assignments to be aligned inside a single code block. When doing this, the number of spaces before an assignment operator can be greater than `1`. To support this coding style, this sniff does not check the spacing before assignment operators by default. If you do not want to allow multiple assignments to be aligned, you can enable checking of spacing before assignment operators by setting the `ignoreSpacingBeforeAssignments` property to `false`.
1367+
1368+
```xml
1369+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
1370+
<properties>
1371+
<property name="ignoreSpacingBeforeAssignments" value="false" />
1372+
</properties>
1373+
</rule>
1374+
```
1375+
13651376
### Squiz.WhiteSpace.SuperfluousWhitespace
13661377

13671378
Property Name | Type | Default | Available Since

0 commit comments

Comments
 (0)