ZF-11421: CLONE - Fatal error: Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found
Description
set_include_path('/path/to/library'); // current trunk
require_once "Zend/CodeGenerator/Php/Docblock/Tag.php";
$foo = new Zend_CodeGenerator_Php_Docblock_Tag();
Fatal error: Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found in /path/to/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php on line 34
Comments
Posted by Chris Buckley (cbuckley) on 2011-05-31T12:28:21.000+0000
Clone of ZF-8739 as the issue has remained closed for a while now.
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-31T15:39:15.000+0000
I was able to reproduce this in trunk by running this command:
Results in fatal error:
Zend/CodeGenerator/Php/Docblock/Tag.php require_once's Zend/CodeGenerator/Php/Docblock/Tag/Param.php, which in turn require_once's Zend/CodeGenerator/Php/Docblock/Tag.php. That second require_once of Zend/CodeGenerator/Php/Docblock/Tag.php isn't performed since the file is already included, but because it hasn't been fully processed by PHP yet the class Zend_CodeGenerator_Php_Docblock_Tag doesn't exist, so PHP throws a fatal error when trying to define class Zend_CodeGenerator_Php_Docblock_Tag_Param.
Posted by Chris Buckley (cbuckley) on 2011-05-31T15:53:34.000+0000
Fix suggested in original bug (ZF-8739) is to remove
from Zend_CodeGenerator_Php_Docblock_Tag.
Workaround is to manually require abstract class to modify include order:
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-31T16:02:37.000+0000
The question is why are _Param and _Return require_once'd into Zend/CodeGenerator/Php/Docblock/Tag.php?
Those classes are not directly referenced anywhere in the code of the class. If I remove those require_once statements, the errors go away:
And the unit test suite results are unchanged.
Is there any practical reason why those seemingly-unnecessary require_once statements can't be removed?
Posted by Chris Buckley (cbuckley) on 2011-05-31T16:09:58.000+0000
See my comment on the original bug; they were left over from before the class used the plugin loader for the factory.
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-31T16:29:31.000+0000
That explanation works for me. I've updated the file in trunk to remove the require_once statements.
Fixed in trunk r24098 Merged to release-1.11 in r24099