如果您使用的机器由于某种原因无法立即升级到 PHP 5.3.3 或更高版本(PHPUnit 3.7需要),那么您可以通过降级软件包来修复此错误。
pear list -a
应该产生类似的东西:
Installed packages, channel pear.phpunit.de:
============================================
Package Version State
File_Iterator 1.3.3 stable
PHPUnit 3.6.12 stable
PHPUnit_MockObject 1.1.1 stable
PHP_CodeCoverage 1.1.4 stable
PHP_Timer 1.0.4 stable
PHP_TokenStream 1.1.4 stable
Text_Template 1.1.2 stable
您需要 1.3.2 版本的 File_Iterator、1.1.1 版本的 Text_Template 和 1.0.3 版本的 PHP_Timer。
所以卸载旧的:
pear uninstall phpunit/PHPUnit
pear uninstall phpunit/PHPUnit_MockObject
pear uninstall phpunit/PHP_CodeCoverage
pear uninstall phpunit/File_Iterator
pear uninstall phpunit/PHP_Timer
pear uninstall phpunit/PHP_TokenStream
pear uninstall phpunit/Text_Template
您应该能够验证您没有安装 phpunit 包:
pear list -a
Installed packages, channel pear.phpunit.de:
============================================
(no packages installed)
现在首先显式安装这些依赖版本:
pear install phpunit/File_Iterator-1.3.2
pear install phpunit/PHP_Timer-1.0.3
pear install phpunit/Text_Template-1.1.1
然后 PHPUnit:
pear install --alldeps phpunit/PHPUnit
pear list -a
Installed packages, channel pear.phpunit.de:
============================================
Package Version State
File_Iterator 1.3.2 stable
PHPUnit 3.6.12 stable
PHPUnit_MockObject 1.1.1 stable
PHP_CodeCoverage 1.1.4 stable
PHP_Invoker 1.1.2 stable
PHP_Timer 1.0.3 stable
PHP_TokenStream 1.1.4 stable
Text_Template 1.1.1 stable
现在一切都应该工作了:)