PhpUnit 9 fails on php 8+
P粉505917590
P粉505917590 2024-01-28 23:51:20
0
1
397

I tried using PHPUnit 9 but it does not support the latest version of PHP above 8.0 I get the following error

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

in C:\xampp\php\pear\PHPUnit\Util\Getopt.php on line 80
P粉505917590
P粉505917590

reply all(1)
P粉010967136

Make sure you are not using an older version of PHPUnit to install the global package.

Check this answer to find globally installed packages.

cd $(composer -n config --global home) && ls -la vendor

Maybe you are calling global instead of project.
If you can remove it using

composer global remove phpunit

I guess your environment PATH variable contains the global Composer folder, so phpunit will call that by default.
Otherwise, use ./vendor/bin/phpunit (from directory C:\xampp\htdocs\test) to call the specific version you installed in your project.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!