Issues

ZF-8739: Fatal error: Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found

Description

<?php require_once "Zend/CodeGenerator/Php/Class.php"; $foo = new Zend_CodeGenerator_Php_Class(); ?>

Fatal error: Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found in /usr/local/lib/php/Zend/CodeGenerator/Php/Docblock/Tag/Param.php on line 34

Comments

If in file Zend/CodeGenerator/Php/Docblock/Tag.php to remove lines require_once ' Zend/CodeGenerator/Php/Docblock/Tag/Param.php '; and require_once ' Zend/CodeGenerator/Php/Docblock/Tag/Return.php ';

Then works

I've tried the following on trunk and cannot reproduce:



set_include_path('/Users/ralphschindler/Projects/ZFStandardTrunk/library'); // current trunk
require_once "Zend/CodeGenerator/Php/Class.php";
$foo = new Zend_CodeGenerator_Php_Class();
var_dump($foo); // works

If you can supply more information, like a backtrace or something, please do and reopen.

Here is a debug backtrace on 1.10.5:

Fatal error: Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found in /var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php on line 35 Call Stack

Time Memory Function Location

1 0.0000 327044 {main}( ) ../index.php:0 2 0.0304 1753412 Zend_Application->run( ) ../index.php:34 3 0.0304 1753412 Zend_Application_Bootstrap_Bootstrap->run( ) ../Application.php:366 4 0.0305 1753684 Zend_Controller_Front->dispatch( ) ../Bootstrap.php:97 5 0.0426 2606964 Zend_Controller_Dispatcher_Standard->dispatch( ) ../Front.php:954 6 0.0536 2854184 Zend_Controller_Action->dispatch( ) ../Standard.php:295 7 0.0537 2858812 TabController->createAction( ) ../Action.php:513 8 0.0537 2858812 Admin_Model_Tab->create( ) ../TabController.php:81 9 0.0846 3961800 Zend_Tool_Project_Provider_Abstract->__construct( ) ../Tab.php:71 10 0.0866 4021840 Zend_Tool_Project_Context_Repository->addContextsFromDirectory( ) ../Abstract.php:85 11 0.1032 4466196 Zend_Tool_Project_Context_Repository->addContextClass( ) ../Repository.php:79 12 0.1032 4466240 class_exists ( ) ../Repository.php:86 13 0.1032 4466616 Zend_Loader_Autoloader::autoload( ) ../Autoloader.php:0 14 0.1033 4467992 call_user_func ( ) ../Autoloader.php:130 15 0.1033 4468020 Zend_Loader_Autoloader->_autoload( ) ../Autoloader.php:0 16 0.1033 4468200 call_user_func ( ) ../Autoloader.php:474 17 0.1033 4468228 Zend_Loader::loadClass( ) ../Autoloader.php:0 18 0.1033 4468720 Zend_Loader::loadFile( ) ../Loader.php:94 19 0.1035 4476032 include_once( '/var/www/social/Stuzo/library/Zend/Tool/Project/Context/Zf/ProjectProviderFile.php' ) ../Loader.php:146 20 0.1038 4496464 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/File.php' ) ../ProjectProviderFile.php:31 21 0.1044 4535892 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Class.php' ) ../File.php:31 22 0.1047 4554468 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Method.php' ) ../Class.php:36 23 0.1052 4567068 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Member/Abstract.php' ) ../Method.php:26 24 0.1054 4577952 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Docblock.php' ) ../Abstract.php:31 25 0.1055 4587492 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Docblock/Tag.php' ) ../Docblock.php:31 26 0.1057 4594576 require_once( '/var/www/social/Stuzo/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php' ) ../Tag.php:31

Issue appears to be that the Param.php requires Tag.php, and Tag.php requires Param.php. It includes Param.php before the class has been initialized.

Please reopen the issue

Can reproduce on trunk with the following code:


set_include_path('/path/to/library'); // current trunk
require_once "Zend/CodeGenerator/Php/Docblock/Tag.php";
$foo = new Zend_CodeGenerator_Php_Docblock_Tag();

As mentioned by ~dontcare], it is due to spurious require_once statements in Zend_CodeGenerator_Php_Docblock_Tag causing a require_once loop. The statements were added in [14194, back before the plugin loader was being used, and should have been removed in 14942.

The above code gives the following order for required files:

The class instantiation isn't even necessary to reproduce:


set_include_path('/path/to/library'); // current trunk
require_once "Zend/CodeGenerator/Php/Docblock/Tag.php"; // Fatal

The above code gives the following order for required files:

Zend/CodeGenerator/Php/Docblock/Tag.php Zend/CodeGenerator/Php/Abstract.php Zend/CodeGenerator/Php/Docblock/Tag/Param.php

If the Abstract class is manually required prior to the Tag class, the error is not seen:


set_include_path('/path/to/library'); // current trunk
require_once 'Zend/CodeGenerator/Php/Abstract.php';
require_once "Zend/CodeGenerator/Php/Docblock/Tag.php"; // works

Issue resolved in ZF-11421