Issues

ZF-11703: Zend tool can't manage controllers with phpdoc

Description

I think there's bug in creating new action in controller with class php doc. Zend tools mangles controller code.

For example, i have class:


<?php
/**
 * For manipulating files.
 * 
 * @author Karol Ciba
 */
class Admin_FileController extends Zend_Controller_Action
{

    public function init()
    {
    }

    public function indexAction()
    {
        // action body
    }
}

when i try to create new action with: zf create action list file 1 admin, then controller class looks like this:


/**
 * For manipulating files.
 *
 * @author Karol Ciba
 *
 */


/**
 * For manipulating files.
 *
 * @author Karol Ciba
 *
 */
class Admin_FileController extends Zend_Controller_Action
{

    public function init()
    {
    }

    public function indexAction()
    {
        // action body
    }

    public function listAction()
    {
        // action body
    }


}

<?php
/* Zend_CodeGenerator_Php_File-DocblockMarker */ 

Comments

The problem is with Zend_CodeGenerator

I create a UnitTest for this.

 
    /**
    * @group ZF-11703
    */
    public function testNewMethodKeepPHPDoc(){
        $codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName(dirname(__FILE__).'/_files/zf-11703.php', true, true);
        $target = <<getClass()->setMethod(array(
            'name' => 'listAction',
            'body' => '// action body'
            ));

        $this->assertEquals($target, $codeGenFile->generate());
    }

The bug occurs in php files with only one docblock. CodeGenerator don't known if one is for file or for class.

When file has docblock and the class too, this bug don't occurs.

Committed in r24456. Thanks for the patch and tests!!!

Thanks for fixing, I can get much better documented code now!