Question

So, this is how function invocations are setup with my custom formatting:

Eclipse does this regardless, notice at the end the 3 parentheses, together. arg?

$this->addElement(
new Form_Element_Note('test', 
    array(
        'value' => 'test'
    )));

I want to figure this out in the formatter, but I literally see nothing aside from chaining method invocations that could accomplish this style of formatting:

$this->addElement(
    new Form_Element_Note(
        'test', 
        array(
            'value' => 'test'
        )
    )
);

Notice this applies to object and function invocations. Any ideas how to edit this manually? I couldn't find anything in the documentation that could do this, but it would surely seem like something possible..

Was it helpful?

Solution

I have the same problem. Using a own (no-psr) coding style in eclipse is really difficult. After many tries I finally made it to format array brackets [] and () in new lines. But it's not a very nice solution.

First Open the formatter and edit your profile, then go to:

  • New Lines > Array Initializers > Insert new line before closing parenthesis of array initializer
  • Line Wrapping > Expressions > Array initializer > Force Split

Cons:

  • Every array gets splitted now, even if it has just one entry
  • if you use an array as method parameter the ending round brace won't be in a new line

Another huge Problem of code formatting in eclipse is (maybe just me). If you execute the formating mutliple times, it looks different. At least for on Save usage it is big problem.

I stopped trying to use code formating in eclipse since it isn't implemented very good and a way to static. I'd be glad, if anybody could provide us help (or implement an "Insert new line before closing parenthesis" for method calls)

Using Mars.2 Release (4.5.2) for PHP Developers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top