【问题标题】:PHPUnit Cannot acquire reference to $GLOBALSPHPUnit 无法获取对 $GLOBALS 的引用
【发布时间】: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


    【解决方案1】:

    您正在使用 PHPUnit 7.5.20,即not compatible 和 PHP 8。

    【讨论】:

      猜你喜欢
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      • 2013-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      相关资源
      最近更新 更多