Issues

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

Issue Type: Bug Created: 2011-08-28T13:26:57.000+0000 Last Updated: 2011-09-25T14:11:38.000+0000 Status: Closed Fix version(s): Reporter: Karol Ciba (keici) Assignee: Raphael de Almeida (jaguarnet7) Tags: - Zend_CodeGenerator

  • Zend_Tool

Related issues: Attachments: - zf11703.r24451.patch

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:

<pre class="highlight">
<?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:

<pre class="highlight">
/**
 * 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

Posted by Raphael de Almeida (jaguarnet7) on 2011-09-07T20:32:00.000+0000

The problem is with Zend_CodeGenerator

I create a UnitTest for this.

<pre class="highlight"> 
    /**
    * @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());
    }

Posted by Raphael de Almeida (jaguarnet7) on 2011-09-07T23:20:14.000+0000

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.

Posted by Pádraic Brady (padraic) on 2011-09-11T13:33:09.000+0000

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

Posted by Karol Ciba (keici) on 2011-09-11T14:11:25.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts