ZF-9602: Zend_CodeGenerator allows extending a class with an empty string

Issue Type: Patch Created: 2010-04-02T18:46:32.000+0000 Last Updated: 2010-04-16T13:41:52.000+0000 Status: Resolved Fix version(s): - 1.10.4 (28/Apr/10)

Reporter: Nick Daugherty (nd987) Assignee: A.J. Brown (ajbrown) Tags: - Zend_CodeGenerator

Related issues: Attachments: - ZF-9602.diff


When using Zend_CodeGenerator to create a PHP class, if you set the 'extended class' property to an empty string, the code generator does not omit the 'extends' keyword in the class definition, it produces invalid code instead. For example:

<pre class="highlight">
$class = new Zend_CodeGenerator_Php_Class();

Produces the following code:

<pre class="highlight">

class MyClass extends 


Note the hanging 'extends'. Zend_CodeGenerator should avoid creating invalid PHP code and instead remove the hanging 'extends' keyword.

This case arises when you do not know what (if any) class will be extended, for example, by passing the value from a form input into the setExtendedClass() method...the value could be blank. It would be much simpler for coders to be able to pass in the blank value, rather than performing a check on a variable before hand (and being forced to break out of the fluent interface).


Posted by A.J. Brown (ajbrown) on 2010-04-15T13:40:06.000+0000

Fix for issue.

Posted by A.J. Brown (ajbrown) on 2010-04-15T13:44:19.000+0000

All fixed!

Posted by Matthew Weier O'Phinney (matthew) on 2010-04-16T13:41:52.000+0000

Patch applied in trunk and 1.10 release branch.

Have you found an issue?

See the Overview section for more details.


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

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