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


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:

$class = new Zend_CodeGenerator_Php_Class();

Produces the following code:


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).


Fix for issue.

All fixed!

Patch applied in trunk and 1.10 release branch.