"(PHPUnit) PHP fatal error: Uncaught error: Call to undefined function each()"
P粉877114798
P粉877114798 2023-08-23 09:25:03
0
1
549
<p>First, I got a warning and a fatal error. Warning: </p> <pre class="brush:php;toolbar:false;">Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?</pre> <p>Then I replaced continue with break and the warning disappeared. But even after replacing, the fatal error still occurs. Fatal error: </p> <pre class="brush:php;toolbar:false;">PHP Fatal error: Undefined function each() was called at line 80 of D:xamppphppearPHPUnitUtilGetopt.php Stack trace: #0 D:xamppphppearPHPUnitTextUICommand.php(242): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array) #1 D:xamppphppearPHPUnitTextUICommand.php(138): PHPUnit_TextUI_Command->handleArguments(Array) #2 D:xamppphppearPHPUnitTextUICommand.php(129): PHPUnit_TextUI_Command->run(Array, true) #3 D:xamppphpphpunit(46): PHPUnit_TextUI_Command::main() #4 {main} Throws at line 80 of D:xamppphppearPHPUnitUtilGetopt.php Fatal error: Undefined function each() called in D:xamppphppearPHPUnitUtilGetopt.php on line 80 Stack trace: #0 D:xamppphppearPHPUnitTextUICommand.php(242): PHPUnit_Util_Getopt::getopt(Array, 'd:c:hv', Array) #1 D:xamppphppearPHPUnitTextUICommand.php(138): PHPUnit_TextUI_Command->handleArguments(Array) #2 D:xamppphppearPHPUnitTextUICommand.php(129): PHPUnit_TextUI_Command->run(Array, true) #3 D:xamppphpphpunit(46): PHPUnit_TextUI_Command::main()</pre> <p>Lines 77-83 of Getopt.php</p> <pre class="brush:php;toolbar:false;">reset($args); array_map('trim', $args); while (list($i, $arg) = each($args)) { if ($arg == '') { continue; }</pre> <p>I'm using PHP 8.0.1 and PHPUnit 9 (at least I think so since I can't check with the command and I downloaded it after February 7th) </p>
P粉877114798
P粉877114798

reply all(1)
P粉378890106

I'm no expert on PHPUnit, but the "each" function is no longer supported in PHP 8

Quoted from PHP official website

Maybe the PHPUnit version you are using is not adapted to PHP 8. If possible, please check the version and then refer to PHPUnit version support

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template