ZF-6982: "zf create action" automatic code formatting messed up

Description

When I create an action for an existing controller via "zf create action ", Zend_Tool creates an action method stub in the controller file.

The bad part of it: it also inserts a blank line after every line and messes with the indentation, indenting everything after the first line in every method. If you create subsequent actions, the effect accumulates. So after the creation of a few actions, your file consists of mostly blank lines with occasional code lines inbetween, and most of the code lines are indented by several tabs.

Thus, everytime I use the Zend_Tool via the CLI, I'll have to tidy up the mess, only to have it all scrambled up with the next action creation.

I'm on a Mac, so maybe part of the problem relates to different line break characters between Windows and Mac OS X. But that's just a shot from the hip.

I'm also using Zend Studio on Mac, if you want to know.

Best regards, Constantin

Comments

I can confirm that this also happens on Windows.

Regards, Wenbert

I confirm that I also have this problem.

In addition, any constants defined in the class will be removed and any function that has type-hinted parameters eg

public function indexAction(MyObject $object)

will be replaced as

public function indexAction($)

I have same problem on Ubuntu 8.10.

I resolve this proglem change the file

Zend \ Reflection \ Method.php

on line 153 i put this:

$tempLines = array_slice($lines, 0); $lines = array(); foreach( $tempLines as $line ){ array_push( $lines, rtrim($line) ); }

this script just remove the break line on the end. This work for me.

Wesley

Added to CodeGenerator also

As of 1.9.6, the extra line breaks have been fixed but the indentation problem remains.

Resolved in trunk in r23561, merged to 1.11 release branch in r23562.