Split function call on several lines

The CS require lines to have a maximum length of 80 chars. Calling functions or methods with many parameters while adhering to CS is impossible in that cases. It should be allowed to split parameters in function calls onto several lines.

<?php

$this
->someObject->subObject->callThisFunctionWithALongName(
    
$parameterOne$parameterTwo,
    
$aVeryLongParameterThree
);
?>

Several parameters per line should be allowed. Parameters need to be indented 4 spaces compared to the level of the function call. The opening parenthesis is to be put at the end of the function call line, the closing parenthesis gets its own line at the end of the parameters. This shows a visual end to the parameter indentations and follows the opening/closing brace rules for functions and conditionals. (See bug #11562)

The same applies not only for parameter variables, but also for nested function calls and for arrays.

<?php

$this
->someObject->subObject->callThisFunctionWithALongName(
    
$this->someOtherFunc(
        
$this->someEvenOtherFunc(
            
'Help me!',
            array(
                
'foo'  => 'bar',
                
'spam' => 'eggs',
            ),
            
23
        
),
        
$this->someEvenOtherFunc()
    ),
    
$this->wowowowowow(12)
);
?>

Nesting those function parameters is allowed if it helps to make the code more readable, not only when it is necessary when the characters per line limit is reached.

Using fluent application programming interfaces often leads to many concatenated function calls. Those calls may be split onto several lines. When doing this, all subsequent lines are indented by 4 spaces and begin with the "->" arrow.

<?php

$someObject
->someFunction("some""parameter")
    ->
someOtherFunc(2342)
    ->
andAThirdFunction();
?>
    Поддержать сайт на родительском проекте КГБ