Bug 540024 - Bad Line Wrapping inside "if" conditions
Summary: Bad Line Wrapping inside "if" conditions
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-10 20:14 EDT by David Bernard CLA
Modified: 2020-05-14 10:17 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Bernard CLA 2018-10-10 20:14:31 EDT
Let's take this PHP function manually indented:

function MyFunction()
{
    if ($conditionA && 
        $conditionB > 0 && 
        $conditionC >= 0 && 
        $conditionD + $conditionE > 100 && 
        $conditionF > 0 && 
        $conditionG >= 0 && 
        $conditionH) {
        return true;
    } else {
        return false;
    }
}

Into which we apply the "Wrap all elements, except first element if not necessary" formatting:

function MyFunction()
{
    if ($conditionA &&
        $conditionB >
        0 &&
        $conditionC >=
        0 &&
        $conditionD +
        $conditionE >
        100 &&
        $conditionF >
        0 &&
        $conditionG >=
        0 &&
        $conditionH) {
        return true;
    } else {
        return false;
    }
}

As you can see, the wrapping occur on all operators, instead of only on the "&&" or "||" operators. This make it much more difficult to read in my opinion.

Is it because all those are included in a single formatting policy: Live Wrapping / Binary expressions? Maybe we need a policy separated from the binary operator when inside a control statement like an "if"?

PS: Reproduced wit the default "PSR-2" profile, except for the wrapping policy of the Live Wrapping / Binary expressions which is set to "Wrap all elements, except first element if not necessary".