Sequential variables assignement format in PhpStorm

Currently using "Auto Format" in PhpStorm uses spaces to align variables like

$objUser = new User();
$arrUserSongs = $objUser->Songs()

to

$objUser      = new User();
$arrUserSongs = $objUser->Songs()

Can it be made to use "tabs" instead of spaces as using DIFF with  repositories makes the code clear [using dots (spaces are converted to  dots) makes it look ugly]

2 comments
Comment actions Permalink

Hi Akash,

AFAIK it is not possible. One of the reasons -- you cannot align nicely all possible variants. For example, that's how your code will look alligned with TAB = 4 spaces:

$objUser        = new User();
$arrUserSongs   = $objUser->Songs();

I think those extra spaces are pretty useless there.

Plus -- I'm using 4 spaces for 1 Tab, but how it will look on someone else's computer where 1 Tab = 8 spaces (or 2 spaces)?

In any case -- please check the Issue Tracker and feel free to submit new Feature Request ticket if no existing one found.

0
Comment actions Permalink

My advice would be to not try to format your code in that way. It looks pretty, but can be a pain in the ass in a team setting, where each team member may have different spacing options. It also makes the code more difficult to maintain, because a maintainer must put in the work to pretty format whatever changes they make, which leads to things like:

$hey          = "ho";
$firstEdit    = "looks good";
$iCameLateToTheParty = "I don't care for pretty declarations";
$butIDo      = "pretty is important";
$iHaveDifferentSpaceFormatting                    = "what is going on here?";



I see this all the time, and someone eventually has to put in the work to non-pretty-fy it.

$hey = "ho";
$firstEdit = "looks good";
$iCameLateToTheParty = "I don't care for pretty declarations";
$butIDo = "pretty is important";
$iHaveDifferentSpaceFormatting = "what is going on here?";



It doesn't look as good, but it keeps a consistent convention, and doesn't get all messed up and uglified when viewed on things like GitHub.
0

Please sign in to leave a comment.