wp-phptidy icon indicating copy to clipboard operation
wp-phptidy copied to clipboard

Incorrect indentation for multiple open parentheses on the same line

Open scribu opened this issue 13 years ago • 4 comments

register_post_type( 'movie', array(
    'label' => 'Movies',
    'public' => true
) );

is transformed into:

register_post_type( 'movie', array(
        'label' => 'Movies',
        'public' => true
    ) );

If I add another pair of parentheses, the effect will be even more pronounced. This:

register_post_type( 'movie', ( array(
    'label' => 'Movies',
    'supports' => array( 'foo', 'bar' )
) ) );

will become:

register_post_type( 'movie', ( array(
            'label' => 'Movies',
            'supports' => array( 'foo', 'bar' )
        ) ) );

and so on.

The problem is that the two '(' on the register_post_type line are counted as two indentation levels, even if they're on the same line.

scribu avatar Jan 23 '12 11:01 scribu

What should those examples produce?

tnorthcutt avatar Jan 24 '12 15:01 tnorthcutt

When passing the first code block through wp-phptidy, it should remain unchanged.

scribu avatar Jan 24 '12 21:01 scribu

Ok, thanks.

tnorthcutt avatar Jan 24 '12 21:01 tnorthcutt

:+1:

it should indent only once in case of arrays inside functions or also anonymous functions:

Class::something( ..., function(){
$do->other->stuff( 'here' );
});

right now:

Class::something( ..., function()
     {
          $do->other->stuff( 'here' );
     } );

should be:

Class::something( ..., function() {
     $do->other->stuff( 'here' );
} );

another issue is indenting of arrays over multiple lines:

$array = function(array(
'something' => 'in here',
'something' => 'in here'
));

right now this happens because of the two round braces, same as with the anonymous function:

$array = function( array(
          'something' => 'in here',
          'something' => 'in here'
     ) );

it should become:

$array = function( array(
     'something' => 'in here',
     'something' => 'in here'
) );

tobsn avatar Jan 22 '13 00:01 tobsn