Change the arguments of the function, but save as is if one argument is a multi-line array and the string is not long

I play with all the phpStorm formatting options, but can't find a way to behave the way I want.

So basically I want PhpStorm:

1 .:

myfunction('hello',
    'world');

In it:

myfunction(
    'hello',
    'world'
);

2. save it as :

myfunction([
    'hello' => 'world',
]);

Also, this should not be reformatted:

myfunction($variableOne, [
    'hello' => 'world',
]);

Is it possible?

+4
source share
1 answer

As I know, at the moment this is not possible.

Now to get this ability

myfunction([
    'hello' => 'world',
]);

myfunction($variableOne, [
    'hello' => 'world',
]);

You can configure the parameters in this position:

enter image description here

But to set the wrap on different parameters in a new line

myfunction(
    'hello',
    'world'
);

you need another list of options:

enter image description here

.

JetBrains. .

, Don't wrap array declaration.

:

myfunction(
    'hello',
    'world'
);

?

myfunction(
    $variableOne, [
        'hello' => 'world',
    ]
);

myfunction(
    [
        'hello' => 'world',
    ]
);

, , Leave array declaration braces with comma/brace in method call. ,

myfunction($variableOne, [
    'hello' => 'world',
]);

myfunction([
    'hello' => 'world',
]);

- , Don't wrap argument if it no long and contain array declaration.

- , ,

myfunction($variableOne, $variableTwo, [
    'hello' => 'world',
]);

myfunction($variableOne, $variableTwo, [
    'hello' => 'world',
], [
    'another' => 'array',
]);

, PHP 5.3- array('key' => 'value') .

+2

Source: https://habr.com/ru/post/1674777/


All Articles