Code Style - Chop down if long / Wrap if long

What does the "Chop" in "Chop down if long" mean (I know what I think it is supposed to mean, but it doesn't seam to do that)? For that matter, how is "if long" defined? Again, doesn't seem to match what I expect.

2
7 comments

Hi Keith,

how is "if long" defined

I think you need to look at   Settings | Code Style | General | Right Margin (columns)

0

So "if long" is only IF it goes past the line? What about if it's been manually cut down, but would go past the line and is not properly formatted when because it was manually cut down before we started using the Formatter? I'm guessing no.....

So, what is the difference between Chop and Wrap?

0

Actually, this my problem with the way you indicate it is defined. For array Intializer, I have Chop down if long. Here is the code
before formatting:

  Input2::$aOptions = array(0 => "N", 1 => "Y");

And after:

  Input2::$aOptions = array(0 => "N",
                            1 => "Y");



How is that "if long"?

0

"Wrap if long" means that only items which go beyond margin are put to the next line. For example:
$x = array("0","1","2");
will become:
$x = array("0","1",
        "2");
assuming that "1" still fits to the line. But "Chop down" means that every item will be on the next line if at least one item doesn't fit. In this case the result should be:
$x = array("0",
       "1",
       "2");
Although item "1" fits to the line, it is nevertherless put to the next line. That's how it should work at least.

2

Ok, that's what I thought....I think I can find some examples of where that does not happen, that Chop acts like Wrap. I'll try to find them and submit them as bug reports. Just wanted to make sure.

0

Yes, any deviation from the described behavior is a bug. Thanks!

0

For example the behaviour I set for method declaration parameters list is "wrap if long" and I kept hard wrap at 120 but the setter I'm posting wraps the method parameter, even if it's not longer than 120 (the wrap marking line is quite far from this text); I just wish to understand:

public KeyValues setSubvalues(
List<KeyValues> subvalues)
{
this.subvalues = subvalues;
this.subvalue = null;
return this;
}

0

Please sign in to leave a comment.