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
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
Comment #2
graber commentedI 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_MAJORthat wouldn't cover this.. or is there a way?Comment #5
graber commentedFixed, thanks for reporting this, now tests should catch any other issues with 8.1 as that's what's used with previous major.
Comment #7
graber commented