21

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
  • Can you post a formatted example? Commented Sep 25, 2015 at 18:35
  • I updated my original post to fit an example in. Commented Sep 25, 2015 at 18:44
  • If you also want to align array's key-value pairs check: stackoverflow.com/a/29795404/269622 Commented Jan 30, 2018 at 23:41

1 Answer 1

63

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".

Sign up to request clarification or add additional context in comments.

3 Comments

You might want to enable Class field/constant groups -> Align constants as well
what about with $sExample => 'Example !';
Array initializer -> Align key-value pairs

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.