ZF-11421: CLONE - Fatal error: Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found

Issue Type: Bug Created: 2011-05-31T12:27:12.000+0000 Last Updated: 2011-05-31T16:34:48.000+0000 Status: Resolved Fix version(s): - 1.11.7 (02/Jun/11)

Reporter: Chris Buckley (cbuckley) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_CodeGenerator

Related issues: - ZF-8739



<pre class="highlight">
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


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:

<pre class="highlight">
[adam@zfdev trunk]$ php -r "set_include_path('/path/to/zf/library'); require_once 'Zend/CodeGenerator/Php/Docblock/Tag.php';"

Results in fatal error:

<pre class="highlight">
PHP Fatal error:  Class 'Zend_CodeGenerator_Php_Docblock_Tag' not found in /usr/local/apache2/htdocs/lib/zfdev/trunk/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php on line 35
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. require_once() Command line code:1
PHP   3. require_once() /usr/local/apache2/htdocs/lib/zfdev/trunk/library/Zend/CodeGenerator/Php/Docblock/Tag.php:31

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

<pre class="highlight">
require_once 'Zend/CodeGenerator/Php/Docblock/Tag/Param.php';
require_once 'Zend/CodeGenerator/Php/Docblock/Tag/Return.php';

from Zend_CodeGenerator_Php_Docblock_Tag.

Workaround is to manually require abstract class to modify include order:

<pre class="highlight">
require_once "Zend/CodeGenerator/Php/Abstract.php";
require_once "Zend/CodeGenerator/Php/Docblock/Tag.php"; // works

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?

<pre class="highlight">
 * @see Zend_CodeGenerator_Php_Docblock_Tag_Param
require_once 'Zend/CodeGenerator/Php/Docblock/Tag/Param.php';

 * @see Zend_CodeGenerator_Php_Docblock_Tag_Return
require_once 'Zend/CodeGenerator/Php/Docblock/Tag/Return.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:

<pre class="highlight">
[adam@zfdev trunk]$ phpsh
php> set_include_path('/home/webadmin/htdocs/lib/zfdev/trunk/library');
php> require_once 'Zend/CodeGenerator/Php/Docblock/Tag.php';
php> $o = new Zend_CodeGenerator_Php_Docblock_Tag();
php> var_dump(get_class($o));
string(35) "Zend_CodeGenerator_Php_Docblock_Tag"

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

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.