Issues

ZF-7804: Invalid property specification if "defaultValue" is NULL

Issue Type: Bug Created: 2009-09-08T20:08:25.000+0000 Last Updated: 2009-09-10T13:48:39.000+0000 Status: Resolved Fix version(s): Reporter: Jan Pieper (jpieper) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_CodeGenerator

Related issues: - ZF-6722

Attachments: - ZF-7804.diff

Description

<pre class="highlight">echo new Zend_CodeGenerator_Php_Class(array(
    'name' => 'Foobar',
    'properties' => array(
        new Zend_CodeGenerator_Php_Property(array(
            'name'         => '_dummy',
            'visibility'   => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED,
            'defaultValue' => NULL
        ))
    )
));


<pre class="highlight">class Foobar {
    protected $_dummy = NULL;
}


<pre class="highlight">class Foobar {
    protected $_dummy = ;
}

Comments

Posted by Jan Pieper (jpieper) on 2009-09-08T20:09:18.000+0000

Added diff to fix this bug.

Posted by Benjamin Eberlei (beberlei) on 2009-09-09T00:40:53.000+0000

This is a duplicate of ZF-6722, its fixed in trunk and 1.9 release branch, which means it will be included in 1.9.3

Posted by Jan Pieper (jpieper) on 2009-09-09T03:53:25.000+0000

Why is it duplicate? Zend_CodeGenerator_Php_Parameter is not Zend_CodeGenerator_Php_Property. It is the same problem but located in different classes. And it seems to not be fixed in svn.

Posted by Benjamin Eberlei (beberlei) on 2009-09-09T04:59:01.000+0000

Ah ok, well its sort of a duplicate, there is another issue that fixes the parameter thing.

You have to call:

<pre class="highlight">
echo new Zend_CodeGenerator_Php_Class(array(
    'name' => 'Foobar',
    'properties' => array(
        new Zend_CodeGenerator_Php_Property(array(
            'name'         => '_dummy',
            'visibility'   => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED,
            'defaultValue' => new ZendCodeGenerator_Php_Property_DefaultValue("NULL")
        ))
    )
));

however the method, setDefaultValue could do that internally also like its done inside the parameter method. I'll add that

Posted by Jan Pieper (jpieper) on 2009-09-10T13:48:35.000+0000

Zend_CodeGenerator_Php_Property_DefaultValue has no own constructor. It's only a luck break that it generates "NULL" as result. Following example will also result in "NULL".

<pre class="highlight">echo new Zend_CodeGenerator_Php_Property_DefaultValue(array(
    'foo' => 'bar'
));

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