简体   繁体   English

(PHPUnit) PHP 致命错误:未捕获的错误:调用未定义的 function each()

[英](PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

firstly I was receiving a warning and a fatal error.首先我收到一个警告和一个致命错误。 The warning:警告:

Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

Then I replaced the continue with break and the warning disappeared.然后我用break替换了continue,警告消失了。 But even after the replacement, the fatal error still happens.但即使更换后,致命错误仍然发生。 The fatal error:致命错误:

PHP Fatal error:  Uncaught Error: Call to undefined function each() in D:\xampp\php\pear\PHPUnit\Util\Getopt.php:80
Stack trace:
#0 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(242): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array)
#1 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(138): PHPUnit_TextUI_Command->handleArguments(Array)
#2 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 D:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()
#4 {main}
  thrown in D:\xampp\php\pear\PHPUnit\Util\Getopt.php on line 80

Fatal error: Uncaught Error: Call to undefined function each() in D:\xampp\php\pear\PHPUnit\Util\Getopt.php:80
Stack trace:
#0 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(242): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array)
#1 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(138): PHPUnit_TextUI_Command->handleArguments(Array)
#2 D:\xampp\php\pear\PHPUnit\TextUI\Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#3 D:\xampp\php\phpunit(46): PHPUnit_TextUI_Command::main()

The line 77-83 of Getopt.php Getopt.php 的 77-83 行

        reset($args);
        array_map('trim', $args);

        while (list($i, $arg) = each($args)) {
            if ($arg == '') {
                continue;
            }

Im using PHP 8.0.1 and the PHPUnit 9 (at least I think, because I cant use commands to check, and I downloaded it after february 7)我正在使用 PHP 8.0.1 和 PHPUnit 9 (至少我认为,因为我不能使用命令来检查,我在 2 月 7 日之后下载了它)

not an expert of PHPUnit but the "each" function is not available anymore in PHP 8不是 PHPUnit 的专家,但 PHP 8 中不再提供“每个” function

Warning: This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0.警告:此 function 自 PHP 7.2.0 起已弃用,自 PHP 8.0.0 起已删除。 Relying on this function is highly discouraged.强烈建议不要依赖此 function。

Taken from the PHP site取自PHP 站点

Probably the PHPUnit version you're using is not up-to-date yet for PHP 8. Check the version if you can and then see here PHPUnit version support您使用的 PHPUnit 版本可能还不是最新的 PHP 8. 如果可以,请检查版本,然后在此处查看PHPUnit 版本支持

Probably the PHPUnit version you're using is not up-to-date yet for PHP 8 try您使用的 PHPUnit 版本可能还不是最新的 PHP 8 尝试

while (list($i, $arg) = each($args)) {

into进入

foreach ($arg as $arg,) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 PHP 致命错误:未捕获错误:调用未定义的 function each()? - How to solve a PHP Fatal error: Uncaught Error: Call to undefined function each()? PHP致命错误:未捕获错误:调用未定义函数getheaders() - PHP Fatal error: Uncaught Error: Call to undefined function getheaders() 致命错误:未捕获错误:调用未定义的函数 - Fatal error: Uncaught Error: Call to undefined function PHPUnit TDD,PHP致命错误:调用未定义方法 - PHPUnit TDD, PHP Fatal error: Call to undefined method 致命错误:未捕获的错误:调用未定义的函数<function name> - Fatal error: Uncaught Error: Call to undefined function <function name> PHP 致命错误:未捕获错误:在 PHP 7.2.13 上调用未定义的函数 idn_to_ascii() - PHP Fatal error: Uncaught Error: Call to undefined function idn_to_ascii() on PHP 7.2.13 PHP-致命错误:未捕获错误:调用未定义的方法PDO :: statement() - PHP - Fatal error: Uncaught Error: Call to undefined method PDO::statement() 致命错误:未捕获错误:调用未定义的方法 Closure::index() php - Fatal error: Uncaught Error: Call to undefined method Closure::index() php 未捕获的错误:调用未定义的 function each() - Uncaught Error: Call to undefined function each() 致命错误:未捕获错误:调用未定义的函数 - 必须使用$ this - Fatal error: Uncaught Error: Call to undefined function - have to use $this
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM