Constructor Property Promotion without php 8 requirement.

Created on 14 August 2023, over 1 year ago

Problem/Motivation

Since version 8.x-1.20
The info.yml file doesn't restrict the php version (to php 8.*).
But src/Plugin/Filter/FilterTooltips.php implements php 8.0 code in the constructor.

    protected EntityTypeManagerInterface $entityTypeManager,
    protected Renderer $renderer

Steps to reproduce

Install the module on a php 7.4 environment and with composer.json set to php 8.4

    "config": {
        "platform": {
            "php": "7.4"
        }
     }

Visit the site.
Inspect the error logs.

The website crashes (or at least the part where the code runs).
The recent log messages will show a php error message that contains something like: unexpected 'protected' (T_PROTECTED), expecting variable

Proposed resolution

Since there is a 8.x-1.x.x branch and a 2.x.x branch.
I'd suggest to keep the 8.x-1.x.x branch compatible with 7.4 by removing the 'protect' keywords.

For the 2.x.x branch php 7.4. compatibility is probably not that an issue, but to prevent accidentally installation I suggest to add the minimum php version to the info.yml

php: 8.0

See: https://www.drupal.org/docs/develop/creating-modules/let-drupal-know-abo...

I'll provide a patch for the 8.x-1.x.x with php 7.4 compatibility.

Remaining tasks

Applying patch and/or set minimum php version in info.yml

🐛 Bug report
Status

Active

Version

1.20

Component

Code

Created by

🇳🇱Netherlands Floris Vedder

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024