PHP 8.2: Creation of dynamic property is deprecated

Created on 6 May 2024, 6 months ago
Updated 22 May 2024, 6 months ago

Problem/Motivation

After upgrading to PHP 8.2, I get several deprecation warnings in the log about dynamic creation of properties in the ICalItem class. These are the different variables that it is warning about: $organizer, $attendee, $additionalProperties, $duration, $dtend_tz, $dtstart_tz, $last_modified.

Steps to reproduce

I think this would happen on any calendar feed import, but in case it matters:

We are pulling from a Microsoft 365 shared calendar.

We are extending the ICalItem class for our own custom feed parsing to do a little massaging of the data for a custom entity. But I don't think this part throwing the warnings is in our code.

Proposed resolution

I've encountered similar in a couple other modules already and the solution is to explicitly declare the protected properties. I tested that same idea here:

protected $organizer, $attendee, $additionalProperties, $duration, $dtend_tz, $dtstart_tz, $last_modified;

That's not up to the Drupal coding standards (each should have a var declaration with its type), but the concept seemed to work.

πŸ› Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada ryanrobinson_wlu

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