0

I lost my previous settings from PhpStorm for formatting an array like this:

$array = [
    'short_key' => 'value1',
    'a_much_longer_key' => 'value2',
    'another_long_key' => 'value3',
];

by hitting Ctrl + Alt + L it would become like this:

$array = [
    'short_key'         => 'value1',
    'a_much_longer_key' => 'value2',
    'another_long_key'  => 'value3',
];

How is this setting called? How to make PhpStorm do this? It has to be somewhere under "Settings -> Code Style".

4
  • 1
    "Settings (Preferences on macOS) | Editor | Code Style | PHP | Wrapping and Braces | Array initializer | Align key-value pairs". Here it was asked the opposite: stackoverflow.com/a/29795404/783119 Commented Jan 9, 2023 at 17:47
  • You're right... I couldn't find that question.... should I delete mine? Commented Jan 10, 2023 at 7:16
  • Up to you. I personally see no strong reason why -- simply because it may help finding the answer for other people who use similar keywords sequence in their search. It's not always that you can come up with "align array on value" or similar kind of keywords. Usually it's more general "how to align an array in a desired way"... Commented Jan 10, 2023 at 10:36
  • True... let's keep it then... Commented Jan 10, 2023 at 15:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.