This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 196405 - 'Wrong' indention depth when assigning a methods return value
Summary: 'Wrong' indention depth when assigning a methods return value
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Navigation (show other bugs)
Version: 7.0
Hardware: PC Windows 7 x64
: P3 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-07 17:26 UTC by edorian
Modified: 2011-06-11 15:14 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description edorian 2011-03-07 17:26:03 UTC
Hi,

autoformating the following code will produce 8 spaces instead of the set indention of 4. 

Possibly because it's 4 for the assignment and 4 for the function call.

It feels like an error to me since I've never seen a coding standard that asks for 2 levels of indention there.

--------------------

Before formatting:
<?php
class foo {

    public function test() {
        $x = $this->foobar(
            1,
            2
        );
    }

}

After formatting:
<?php

class foo {

    public function test() {
        $x = $this->foobar(
                1,
                2
        );
    }

}
Comment 1 Tomas Mysik 2011-06-03 10:23:10 UTC
Batch reassigning.
Comment 2 Tomas Mysik 2011-06-08 10:12:40 UTC
Editor area.
Comment 3 Petr Pisl 2011-06-09 13:12:10 UTC
The reason, why there are 8 spaces is that it's continual expression. The function call continues on next line and there is used the continual size indentation, which is by default 8. You can change the value in the options. 


I'm closing this as want fix, but feel free if to reopen if you think that there should be created a special rule for this case.
Comment 4 edorian 2011-06-09 14:53:40 UTC
First off: Thanks for replying :)

I didn't make my case clear enough it seems.

"Continual indentation" is set to 4 in this example.

The indentation IMHO should be the same if you say

$this->foobar(
    4spaces

and if you say

$x = $this->foobar(
    shouldBeAlso4spaces---ButItIs8


Maybe this reproduce snipped can explain it better:


Before:
---------------
<?php

class foo {

    public function test() {
        // just the function call
        $this->foobar(
            1, 2
        );
        // fuction call AND assignment, this changes on reformat!
        $x = $this->foobar(
            1, 2
        );
    }

}

After:
--------------


<?php

class foo {

    public function test() {
        // just the function call
        $this->foobar(
            1, 2
        );
        // fuction call AND assignment, this changes on reformat!
        $x = $this->foobar(
                1, 2
        );
    }

}

----------------------------------

So if you think this is correct behavior ("Indenting twice, once for the assignment once for the function") then: yeah. I'd LOVE to be able to turn this off since i don't want do have the other code lines change when i decide to take a functions return value into a variable


Thanks again,
edorian
Comment 5 Petr Pisl 2011-06-09 15:14:13 UTC
Thanks, now I understand:) .  You are right, it's indented with 8 spaces because there are two indent level. One for assignment and one for the function invocation that is over more lines. And you are right, it's strange in this case. I'm going to fix it.
Comment 6 Petr Pisl 2011-06-10 08:10:15 UTC
Fixed in web-main and releases/release701.
Comment 7 Quality Engineering 2011-06-11 04:18:23 UTC
Integrated into 'releases'
Changeset: http://hg.netbeans.org/releases/rev/dcf0c81291c9
User: Petr Pisl <ppisl@netbeans.org>
Log: #196405 - 'Wrong' indention depth when assigning a methods return value
(transplanted from 22fc6c5ff7e2db144dabc28be4fa7af5446a8585)
Comment 8 Quality Engineering 2011-06-11 15:14:27 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/22fc6c5ff7e2
User: Petr Pisl <ppisl@netbeans.org>
Log: #196405 - 'Wrong' indention depth when assigning a methods return value