19

After many searches, it seems I don't have the option to align consecutive assignments of variables in PHP. I can align key/value pairs in arrays, but that's it.

It also seems older PHPStorm versions have it.

Is that possible in PHPStorm 9 ? If so, how ? If not, is it really much better than older versions ? I just started using it (coming from Sublime).

This is an example of non formatted code :

$sExample = 'Example !';
$sAnotherOneHere = 'Again ?';
$sAndTheLast = 'ENOUGH !';

And that's the format result :

$sExample        = 'Example !';
$sAnotherOneHere = 'Again ?';
$sAndTheLast     = 'ENOUGH !';
3

1 Answer 1

60

The option is still there and it works flawlessly.

Search for it under Editor -> Code Style -> PHP -> Wrapping and Braces -> Assignment Statement. It's called "Align consecutive assignments".

3
  • 1
    You might want to enable Class field/constant groups -> Align constants as well Mar 28, 2019 at 17:12
  • what about with $sExample => 'Example !';
    – pmiranda
    May 9, 2019 at 16:01
  • 1
    Array initializer -> Align key-value pairs
    – hdogan
    Jul 30, 2019 at 11:50

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.