ZF-7894: Installation of PHPUnit 3.4.0 makes the zf --help command exit with Fatal PHP errors

Issue Type: Bug Created: 2009-09-19T04:31:33.000+0000 Last Updated: 2009-11-22T01:41:53.000+0000 Status: Resolved Fix version(s): - 1.9.6 (24/Nov/09)

Reporter: Raphael Stolt (raphael.stolt) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Tool

Related issues: Attachments: - 7894.diff


After having installed the latest/new PHPUnit version 3.4.0 via Pear issuing the zf --help command exits with following PHP Fatal errors.

$ zf --help PHP Fatal error: Cannot redeclare class phpunit_framework_testsuite_dataprovider in /opt/local/lib/php/PHPUnit/Framework/TestSuite/DataProvider.php on line 65 PHP Stack trace: PHP 1. {main}() /opt/local/bin/zf.php:0 PHP 2. Zend_Tool_Framework_Client_Console::main() /opt/local/bin/zf.php:77 PHP 3. Zend_Tool_Framework_Client_Abstract->dispatch() /opt/local/lib/php/Zend/Tool/Framework/Client/Console.php:96 PHP 4. Zend_Tool_Framework_Client_Abstract->initialize() /opt/local/lib/php/Zend/Tool/Framework/Client/Abstract.php:209 PHP 5. Zend_Tool_Framework_Loader_Abstract->load() /opt/local/lib/php/Zend/Tool/Framework/Client/Abstract.php:118 PHP 6. include_once() /opt/local/lib/php/Zend/Tool/Framework/Loader/Abstract.php:90

Fatal error: Cannot redeclare class phpunit_framework_testsuite_dataprovider in /opt/local/lib/php/PHPUnit/Framework/TestSuite/DataProvider.php on line 65

Call Stack: 0.0005 643208 1. {main}() /opt/local/bin/zf.php:0 0.0071 1452848 2. Zend_Tool_Framework_Client_Console::main() /opt/local/bin/zf.php:77 0.0071 1454344 3. Zend_Tool_Framework_Client_Abstract->dispatch() /opt/local/lib/php/Zend/Tool/Framework/Client/Console.php:96 0.0071 1454344 4. Zend_Tool_Framework_Client_Abstract->initialize() /opt/local/lib/php/Zend/Tool/Framework/Client/Abstract.php:209 0.0102 1706760 5. Zend_Tool_Framework_Loader_Abstract->load() /opt/local/lib/php/Zend/Tool/Framework/Client/Abstract.php:118 0.3996 2317528 6. include_once('/opt/local/lib/php/PHPUnit/Framework/TestSuite/DataProvider.php') /opt/local/lib/php/Zend/Tool/Framework/Loader/Abstract.php:90


Posted by Benjamin Eberlei (beberlei) on 2009-09-19T08:53:43.000+0000

this just means that you have phpunit in your include path twice.


wouldn't it make sense to extend the include loader to block equal paths relative from the different include paths?

<pre class="highlight">


<pre class="highlight">

disallows the inclusion of another file:

<pre class="highlight">

Posted by Raphael Stolt (raphael.stolt) on 2009-09-22T15:42:55.000+0000

The problem is that $filterAcceptFilePattern = '.*(?:Manifest|Provider).php$'; on line 60 in Zend_Tool_Framework_Loader_IncludePathLoader lets slip the /opt/local/lib/php/PHPUnit/Framework/TestSuite/DataProvider.php through, as it has Provider in the class file name, and therefore adds it twice to the list of classes to include. I temporarly fixed it by filtering out the one item that has PHPUnit/Framework in it (see attached patch 7894.diff).

Posted by Benjamin Eberlei (beberlei) on 2009-09-23T00:24:48.000+0000

@Ralphschindler I may have a possible fix for the symlink || file in include path twice problem.

How about the _getFiles() maintains an array of visited files in a reverse tree like schema relative to the include path:

Zend/OpenId/Provider.php would become

<pre class="highlight">
$visited = array(
    'Provider' => array('OpenId' => array('Zend')),

when adding a potential new hit one could then do:

<pre class="highlight">
$fileParts = explode(DIRECTORY_SEPARATOR, str_replace($currentIncludePath, "", $file));
$alreadyVisited = true;
$currentLeaf = $visited;
while(count($fileParts)) {
    $item = array_pop($fileParts);
    if(!isset($currentLeaf[$item]) || !is_array($currentLeaf[$item])) {
       $alreadyVisited = false;
    } elseif(!in_array($item, $currentLeaf)) {
        $alreadyVisited = false;
    $currentLeaf = $currentLeaf[$item];
if($alreadyVisited == false) {
   // add to $visited
   // add to $files

Edit: Fixed the code

Posted by Goran Juric (gog) on 2009-10-11T02:17:24.000+0000

Just want to confirm that the patch provided by Raphael Stolt is working.

I had the same issue trying to run "zf show version"

Posted by Benjamin Eberlei (beberlei) on 2009-11-20T14:09:40.000+0000

Fixed in trunk and merged into 1.9 release branch, this hack will not be necessary for 1.10 anymore since the IncludePathLoader will be removed.

Posted by Satoru Yoshida (satoruyoshida) on 2009-11-22T01:41:52.000+0000

I set fix version

Have you found an issue?

See the Overview section for more details.


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

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