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",
    ...
  },
CommentFileSizeAuthor
#4 select2-3424485.patch350 bytesabhishek_gupta1

Issue fork select2-3424485

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jnlar created an issue. See original summary.

himanshu_jhaloya made their first commit to this issue’s fork.

abhishek_gupta1’s picture

Status: Active » Needs review
StatusFileSize
new350 bytes

@jnlar , above MR seems to be failed.I have added changes to patch file. please kindly review it.

jnlar’s picture

thanks @abhishek_gupta1, those changes look OK. As for the CI failing it looks like some unit tests are failing, none of which are an affect of this change. So I'd say there outside the context of this issue.

chr.fritsch’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.