2012-02-06 98 views
5
PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /usr/share/php/PHPUnit/Framework/Test.php on line 66 
PHP Stack trace: 
PHP 1. {main}() /usr/bin/phpunit:0 
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46 
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130 
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/php/PHPUnit/TextUI/Command.php:150 
PHP 5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:104 
PHP 6. PHPUnit_Runner_StandardTestSuiteLoader->load() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:168 
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/php/PHPUnit/Runner/StandardTestSuiteLoader.php:78 
PHP 8. PHPUnit_Util_Fileloader::load() /usr/share/php/PHPUnit/Util/Fileloader.php:79 
PHP 9. include_once() /usr/share/php/PHPUnit/Util/Fileloader.php:95 
PHP 10. phpunit_autoload() /usr/share/php/PHPUnit/Autoload.php:0 
PHP 11. require() /usr/share/php/PHPUnit/Autoload.php:203 
PHP 12. phpunit_autoload() /usr/share/php/PHPUnit/Autoload.php:0 

有问题的线路有:PHPUnit的怪异错误而失败

public function run(PHPUnit_Framework_TestResult $result = NULL)

当我删除它通过但未能另一条线路上也有一个= NULL= NULL时,搞砸了的事情是该错误基本上说它是NULL,它是。

我没有以任何方式修改PHPUnit的,我安装了它使用此处介绍的方法:

http://www.giocc.com/installing-phpunit-on-ubuntu-11-04-natty-narwhal.html

老实说,我不明白为什么会这样..东西告诉我PHP在窃听这是给我错误的错误。

+0

你最近更新了你的PHP吗?你正在运行什么版本和O/S?我同意它看起来像PHP是坏的。那些线很好。 – 2012-02-06 20:08:25

+0

我不认为PHP最近更新了,唯一的变化是我从PhpUnit 3.6.3更新到最新版本。我在Ubuntu 11.10 /上有PHP 5.3.6版本。 – Naatan 2012-02-06 20:14:28

+0

在删除默认设置后,当它在后续的NULL上失败时,那种情况下的错误消息是什么? – Spudley 2012-02-06 20:38:07

回答

1

找到了答案,从评论部分引用自己:

Oh damn I found the problem, and it's a silly one on my side. I had a constant file that was defining NULL for use in an ORM library. It's defined in it's own namespace so it shouldn't have interfered with the global constant, but I guess constants are a bit tricky with namespaces..

所以TIL,如果你想在一个命名空间中定义的常量,简单地增加命名的文件的顶部是不够的,你必须像这样定义常量

define('NAMESPACE\CONSTANT',  'value'); 
// or 
define(__NAMESPACE__ . '\CONSTANT', 'value'); // to use the current namespace