-
Hi all, I'm in the process of setting up the CS Fixer in my project and have a question regarding method chain indentation. Maybe there is no set of rules that matches the way I did things before or I just couldn't find the correct rules. Here are examples for the changes that CS Fixer wants to apply to my code: $this->putJson('/api/v1/import/abc123', [
- 'parent_conflicts' => [1 => 'import', 2 => 'existing'],
- ])
+ 'parent_conflicts' => [1 => 'import', 2 => 'existing'],
+ ])
->assertStatus(200); $parentConflicts = $mergeLabels->filter(function ($label) {
- return array_key_exists('conflicting_parent_id', $label);
- })
+ return array_key_exists('conflicting_parent_id', $label);
+ })
->each(function ($label) use ($parentConflictResolution) { So basically with a multi-line array or a closure, CS Fixer wants to unindent the part to the same level than the original method call. However, I would like this to be on the same level than the following method in the chain. Can this be accomplished somehow? My configured CS Fixer rules are below. [
'@PSR2' => true,
'ordered_imports' => true,
'single_space_around_construct' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one', ]],
'no_whitespace_before_comma_in_array' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'method_chaining_indentation' => true,
] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Beta Was this translation helpful? Give feedback.
Did you try this?
The problem here is caused by
array_indentation
, notmethod_chaining_indentation
itself. Since second argument ofputJson()
is an multiline array, it finds the initial indentation of the line (not opening[
), which is$this
', and tries to align the rest to it. If you add new line for the first call in the chain, it works properly:I am not sure if we should consider this as a bug in
array_indentation
🤔...