Skip to content

Commit df94604

Browse files
gsherwoodjrfnl
authored andcommitted
Updated Customisable Sniff Properties (markdown)
1 parent 312be6d commit df94604

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

wiki/Customisable-Sniff-Properties.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,35 @@ If the `ignoreComments` property is set to `true`, comments at the end of a line
212212

213213
Property Name | Type | Default | Available Since | Removed In
214214
------------- | ---- | ------- | --------------- | ----------
215-
maxPadding | int | 1000 | - |
215+
alignAtEnd | bool | true | 3.6.0 |
216216
error | bool | false | - | 4.0.0
217+
maxPadding | int | 1000 | - |
218+
219+
This sniff checks the alignment of assignment operators. If there are multiple adjacent assignments, it checks that the assignment operators of each assignment are aligned. By default, the sniff enforces that the end of the assignment operators are aligned, ensuring that the assigned values are aligned. This formats code like this:
217220

218-
This sniff checks the alignment of assignment operators. If there are multiple adjacent assignments, it checks that the equals signs of each assignment are aligned.
221+
```php
222+
$foo = 'foo';
223+
$foo .= 'bar';
224+
```
225+
226+
If you prefer the start of the assignment tokens to be aligned, you can set the `alignAtEnd` sniff property to `false`.
227+
228+
```xml
229+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
230+
<properties>
231+
<property name="alignAtEnd" value="false" />
232+
</properties>
233+
</rule>
234+
```
235+
236+
Code will now be formatted like this:
237+
238+
```php
239+
$foo = 'foo';
240+
$foo .= 'bar';
241+
```
219242

220-
The difference in alignment between two adjacent assignments is occasionally quite large, so aligning equals signs would create extremely long lines. By setting the `maxPadding` property, you can configure the maximum amount of padding required to align the assignment with the surrounding assignments before the alignment is ignored and no warnings will be generated.
243+
The difference in alignment between two adjacent assignments is occasionally quite large, so aligning assignment operators would create extremely long lines. By setting the `maxPadding` property, you can configure the maximum amount of padding required to align the assignment with the surrounding assignments before the alignment is ignored and no warnings will be generated.
221244

222245
```xml
223246
<rule ref="Generic.Formatting.MultipleStatementAlignment">

0 commit comments

Comments
 (0)