PHP Fatal error when running tests on PHP 7.4.x

Created on 29 February 2024, 9 months ago
Updated 21 May 2024, 7 months ago

Problem/Motivation

The 1.15.0 version of select2 includes Union types in Select2Test.php, which is a PHP 8 feature. However the composer.json in the module doesn't specify the required version. This can lead to module requiring/updates via composer passing platform requirements when they shouldn't.

Steps to reproduce

Run a phpunit test while on PHP 7.4.x, this error will still occur when no test is run as it seems to trip in PHPUnit\Util\FileLoader::load

./vendor/bin/phpunit --configuration=web/core/ --group=foo --testsuite=unit

PHP Fatal error:  Uncaught ParseError: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /var/www/site/web/modules/contrib/select2/tests/src/Unit/Element/Select2Test.php:199
Stack trace:
#0 /var/www/site/vendor/phpunit/phpunit/src/Util/FileLoader.php(49): PHPUnit\Util\FileLoader::load

Proposed resolution

Add a platform dependency for PHP 8 in the projects composer.json

  "require": {
    "php": ">=8.1",
    ...
  },
🐛 Bug report
Status

Fixed

Version

1.15

Component

Miscellaneous

Created by

🇦🇺Australia jnlar Sydney, Australia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024