Deprecated dynamic property creation in UpdateAvailabilityForm

Created on 18 May 2024, 6 months ago
Updated 15 July 2024, 4 months ago

Problem/Motivation

When navigating to the node availability path (node/{nid}/availability) after making a node type bookable and creating a node of that type, the following PHP deprecation warnings are observed:

Deprecated function: Creation of dynamic property Drupal\bee\Form\UpdateAvailabilityForm::$nodetypeStorage is deprecated in Drupal\bee\Form\UpdateAvailabilityForm->__construct() (line 45 of modules/contrib/bee/src/Form/UpdateAvailabilityForm.php).
Deprecated function: Creation of dynamic property Drupal\bee\Form\UpdateAvailabilityForm::$nodeStorage is deprecated in Drupal\bee\Form\UpdateAvailabilityForm->__construct() (line 46 of modules/contrib/bee/src/Form/UpdateAvailabilityForm.php).

This occurs because properties $nodetypeStorage and $nodeStorage are being dynamically created in the constructor of UpdateAvailabilityForm without being declared within the class definition.

See https://www.php.net/manual/en/class.allowdynamicproperties.php

Steps to reproduce

  1. Install the BEE module.
  2. Define a node type and set it as bookable.
  3. Create a node of the bookable type.
  4. Visit node/{nid}/availability.
  5. Observe the deprecated warnings.

Proposed resolution

Modify the UpdateAvailabilityForm class to declare these properties explicitly at the beginning of the class.

📌 Task
Status

Needs review

Version

3.0

Component

Code

Created by

🇩🇪Germany majdi

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