Formatting for arrays

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

Formatting for arrays

Postby codeowl » February 21st, 2013, 3:51 am

Hi there,

When I past the following code it looks like this:
Code: Select all
public $components = array(
'Session',
'Auth' => array(
'loginAction' => array(
'controller' => 'users',
'action' => 'login'
),
array('authorize' => array('Controller'))
)
);


Then I have to do all this indenting to make it look more readable, like this:
Code: Select all
public $components = array(
    'Session',
    'Auth' => array(
        'loginAction' => array(
            'controller' => 'users',
            'action' => 'login'
        ),
        array('authorize' => array('Controller'))
    )
);


It would be fantastic if PHP Tools did this formatting for me.

Regards,

Scott
codeowl
 
Posts: 51
Joined: February 10th, 2013, 10:05 am

Re: Formatting for arrays

Postby CFI » February 21st, 2013, 12:33 pm

Good Idea and I also vote for "configurable brakets placement", as I like the ( on a new line ;)...
CFI
 
Posts: 66
Joined: December 13th, 2012, 1:29 pm

Re: Formatting for arrays

Postby Miloslav Beno » February 21st, 2013, 3:22 pm

Hi Guys,

Formatting in the current version defines all multiline expressions (e.g. function call or array definition) as user defined formatting. That means we just respect how user formats this as everyone wants it little bit differently. So during formating we just move whole block but won't interfere with the formating that user used.

In the next stage of formatting engine when we can provide more options to choose from we will include formatting of these expressions.

Thanks,
Miloslav
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbenomiloslav@devsense.com
User avatar
Miloslav Beno
 
Posts: 1252
Joined: January 7th, 2012, 8:36 pm

Re: Formatting for arrays

Postby codeowl » February 21st, 2013, 10:23 pm

Miloslav,

Thanks for the response mate. I don't see that happening here. In VS, on a .php page in a <?php ?> element, if I write and array formatted like the second code block in my post, eg; indented, and then copy that formatted code to the clipboard, and then paste it back two lines down from the original, it will be completely un-formatted, like the first block of code in my post...
So how does your statement:
"So during formatting we just move whole block but won't interfere with the formatting that user used."
apply to this scenario?

Regards,

Scott
codeowl
 
Posts: 51
Joined: February 10th, 2013, 10:05 am

Re: Formatting for arrays

Postby Miloslav Beno » February 21st, 2013, 10:48 pm

Scott,

Thanks for reporting this. It's a bug when array is directly used as a class member initialization, will be fixed for the next minor update.

Regards,
Miloslav
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbenomiloslav@devsense.com
User avatar
Miloslav Beno
 
Posts: 1252
Joined: January 7th, 2012, 8:36 pm

Re: Formatting for arrays

Postby codeowl » February 21st, 2013, 11:40 pm

Miloslav,

Great work mate, thanks for following this up ;-)

Regards,

Scott
codeowl
 
Posts: 51
Joined: February 10th, 2013, 10:05 am

Re: Formatting for arrays

Postby Miloslav Beno » February 25th, 2013, 3:52 pm

Thanks Scott,

This has been fixed and it will be available in the following update.

Btw. Thanks for a great review on vs gallery! It made my day.
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbenomiloslav@devsense.com
User avatar
Miloslav Beno
 
Posts: 1252
Joined: January 7th, 2012, 8:36 pm

Re: Formatting for arrays

Postby codeowl » February 28th, 2013, 10:33 pm

Miloslav,

Thanks for following up on this mate.

You guys earned the good review, keep up the great work ;-)

Regards,

Scott
codeowl
 
Posts: 51
Joined: February 10th, 2013, 10:05 am


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 45 guests

cron

User Control Panel

Login

Who is online

In total there are 45 users online :: 0 registered, 0 hidden and 45 guests (based on users active over the past 5 minutes)
Most users ever online was 287 on March 29th, 2024, 6:11 am

Users browsing this forum: No registered users and 45 guests