Dynamic properties are deprecated in PHP 8.2

Created on 21 November 2023, 7 months ago
Updated 28 February 2024, 4 months ago

Problem/Motivation

In PHP 8.2, dynamic properties are deprecated. At least one class in Diff does not declare all the properties that can be created on its instances.

Steps to reproduce

  1. Install a Drupal 7 site on PHP 8.2.
  2. Download and enable the latest versions of Diff, Features, and Features UI submodule.
  3. Create a Feature and enable it.
  4. Override some of the configuration controlled by the Feature.
  5. Visit the "Review overrides" tab to see a diff of the Feature.
  6. Note the following PHP warnings:
Deprecated function: Creation of dynamic property _DiffEngine::$ychanged is deprecated in _DiffEngine->diff() (line 145 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$xchanged is deprecated in _DiffEngine->diff() (line 145 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$yv is deprecated in _DiffEngine->diff() (line 146 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$xv is deprecated in _DiffEngine->diff() (line 146 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$yind is deprecated in _DiffEngine->diff() (line 147 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$xind is deprecated in _DiffEngine->diff() (line 147 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$lcs is deprecated in _DiffEngine->_diag() (line 293 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$seq is deprecated in _DiffEngine->_diag() (line 294 of /diff/DiffEngine.php).
Deprecated function: Creation of dynamic property _DiffEngine::$in_seq is deprecated in _DiffEngine->_diag() (line 295 of /diff/DiffEngine.php).

Proposed resolution

Add the annotation to allow dynamic properties to the class. Another solution would be to declare all the properties in the class.

Remaining tasks

Patch and test.

User interface changes

None.

API changes

None.

Data model changes

None.

๐Ÿ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States cboyden

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024