PHP 8.2 compatability: Deprecated function: Using ${var} in strings is deprecated, use {$var} instead in include()

Created on 24 November 2023, about 1 year ago
Updated 13 July 2024, 5 months ago

Problem/Motivation

I received the following warning message when loading the manage display screen for a taxonomy term (D10):
Deprecated function: Using ${var} in strings is deprecated, use {$var} instead in include() (line 571 of vendor/composer/ClassLoader.php).

The cause was not in ClassLoader.php but in the include $file, and the culprit turned out to be
.../modules/formatter_suite/src/Plugin/Field/FieldFormatter/GeneralNumberWithBarIndicatorFormatter.php
where line 455 is
$backgroundStyle = "width: ${barLength}px; height: ${barWidth}px;";

Proposed resolution

Simple fix: change line 455 to the now-preferred syntax by moving the curly brackets:
$backgroundStyle = "width: {$barLength}px; height: {$barWidth}px;";

The new form should be compatible with previous and future php versions.

(I thought I had seen a reference to this elsewhere, but can't find it now.)

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States peter pulsifer

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

Comments & Activities

Production build 0.71.5 2024