phpstorm-2017.1

how to remove new line after comma for array element in phpstorm


I am applying a auto formatting (Code|Reformat Code ) in phpStrom which adds a new line after the the comma of array elements. Here is sample of code before and after applying auto formatting.

Before

public function getResponse() {
    return [
        'venue_id' => '1234'
        ,'match_name' => 'One-Day'
        ,'team1_id' => '123'
        ,'team2_id' => '456'
    ];
}

After

public function getResponse() {
    return [
        'venue_id' => '1234'
        ,
        'match_name' => 'One-Day'
        ,
        'team1_id' => '123'
        ,
        'team2_id' => '456'
    ];
} 

Adding a comma to new line before the element is the coding style. Please help me to remove the new line through auto formatting.


Solution

  • After googling a lot a, find the setting where we can change this feature. Go the Setting|Editor|Code Style|PHP

    Open the third tab Wrapping and Braces and you will find the array initializer property. Click in front of this property. And change this value to chop down if long. Here is the screen shot

    enter image description here