PHP errors in DiffBuilderManager.php and other classes with PHP 7.4 and Drupal 9.3 to 9.5

Created on 28 May 2024, 7 months ago
Updated 4 August 2024, 5 months ago

Problem/Motivation

I am the maintainer of the view_mode_switch module and I implement basic diff support. My automated tests just showed a little problem with the code in DiffBuilderManager.php when running automated tests against the previous Drupal 9 major version. The official Drupal CI template uses PHP 7.4.28 as minimum required PHP version for these tests, which results in the following error:

ParseError: syntax error, unexpected ')', expecting variable (T_VARIABLE)
/builds/project/view_mode_switch/web/modules/contrib/diff/src/DiffBuilderManager.php:77

This is because the trailing comma in the constructor's parameter list is only supported for PHP >= 8.

I know, that both Drupal core 9.x and PHP 7.x are EOL, but this module's code should be compatible the minimum required versions though, when Drupal 9.3 - 9.5 is still supported here.

UPDATE: I just digged through the diff module code a little more and saw that DiffBuilderManager.php unfortunately is not the only occurrence of these incompatibilities with PHP 7.4. Almost all other classes with constructors have the same problem.

Steps to reproduce

Proposed resolution

  • There are several options:
    • Remove the trailing comma from the constructor's parameter list
    • add PHP 8 as a requirement in composer.json
    • remove support for Drupal 9.x because Drupal 10.x already requires PHP >= 8.1
  • Check other code of this module for potential PHP 7.4 compatibility issues and fix them as well

I guess the easiest is to remove the trailing comma, to get it working with PHP 7.4.x again. Just let me know what is preferred, then I can create an issue fork and MR with the required changes.

Remaining tasks

  • Create issue fork and MR to fix this issue

User interface changes

n/a

API changes

n/a

Data model changes

n/a

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany hctom

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