Fix PHP 7.4 compatibility: replace static return type in ScriptFileManager::buildDisabledJsScript()

Created on 11 August 2025, 13 days ago

Problem/Motivation

On PHP 7.4 + Drupal 9, the module fatals during install/config import with:
ParseError: syntax error, unexpected 'static' (T_STATIC) in
src/Service/ScriptFileManager.php. The return type : static requires PHP ≥ 8.0.
Many Drupal 9 sites still run on PHP 7.4; this is a regression for those environments.

Steps to reproduce

  1. Environment example:
    • Drupal 9.x (e.g. 9.5.x)
    • PHP 7.4.x (CLI and FPM)
  2. Install/Config import via Drush:
    drush si --existing-config -y
  3. Observe fatal error:
    ParseError: syntax error, unexpected 'static' (T_STATIC) in .../src/Service/ScriptFileManager.php on line 77

Proposed resolution

Change the method return type from static to self and update the docblock. This restores PHP 7.4 compatibility while remaining valid on PHP 8+.

Remaining tasks

  • (Optional) Add a simple test/build job on PHP 7.4 to prevent regressions for D9 users.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇳🇴Norway truls1502 Oslo, Norway

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