【发布时间】:2022-01-24 01:15:22
【问题描述】:
在 GitHub 操作上运行 PHPUnit 测试时出现错误。
PHP Fatal error: Cannot acquire reference to $GLOBALS in /home/runner/work/project-name/project-name/vendor/phpunit/phpunit/src/Util/Configuration.php on line 570
似乎这个错误可能与 PHP8 (https://php.watch/versions/8.1/GLOBALS-restrictions) 有关,但测试矩阵应该只运行 PHP 7.2 和 7.4(测试在 PHP 7.4 上本地运行良好)。
GitHub Actions 中显示的错误。 Testing matrix is here.
非常感谢任何帮助!
--
编辑:
通过专门设置容器中的PHP版本作为第一步解决了这个问题:
# PHPUnit errors with latest PHP 8.X build.
# This specifically sets PHP version to 7.4.
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: phpunit
【问题讨论】:
标签: php phpunit github-actions