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