Problem/Motivation

The latest stable release 1.1.3 says it is works with Drupal ^10.3 || ^11. Per Drupal's PHP requirements, it is possible to run Drupal 10.3 through 10.5 with PHP 8.1+. In #3515599: Improve classes UI typed class constants were introduced. This feature requires PHP 8.3+. A site running Drupal 10.5 on PHP 8.1 throws a fatal error when using LMS 1.1.3

ParseError: syntax error, unexpected identifier "CLASS_NO_STATE", expecting "=" in Composer\Autoload\{closure}() (line 20 of /var/www/html/web/modules/contrib/lms/modules/lms_classes/src/Service/ClassNameGenerator.php).

This comes from web/modules/contrib/lms/modules/lms_classes/src/Service/ClassNameGenerator.php:

final class ClassNameGenerator {

  private const string CLASS_NO_STATE = 'lms_classes_class_number';

Steps to reproduce

  • Install LMS 1.1.3 on Drupal 10.5.4.
  • Enable the lms_classes module.

Proposed resolution

Set the minimum PHP requirement to 8.3 in composer.json or remove code that is not compatible with PHP 8.1 (to match Drupal core supported PHP versions).

Also, consider adding version constraints for Drupal itself in composer.json

Remaining tasks

Decide on which approach to follow.

Issue fork lms-3554309

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

dinarcon created an issue. See original summary.

graber’s picture

I think it'll be better to fix this and stay compatible with 8.1. Can you confirm that's the only compatibility issue?

It'd be good to set automated test to run with lowest supported PHP and Drupal but the only relevant variable I see in https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes... is OPT_IN_TEST_PREVIOUS_MAJOR that wouldn't cover this.. or is there a way?

  • graber committed 310a0a95 on 1.1.x
    #3554309: PHP 8.1 compatibility fix.
    
graber’s picture

Status: Active » Fixed

Fixed, thanks for reporting this, now tests should catch any other issues with 8.1 as that's what's used with previous major.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

graber’s picture

Title: Set minimum PHP version in composer.json » Support PHP 8.1 as required by Drupal 10

Status: Fixed » Closed (fixed)

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