Calling get_class() without arguments is deprecated

Created on 30 January 2024, 8 months ago
Updated 14 February 2024, 7 months ago

Problem/Motivation

Drupal 10.2.2 with PHP 8.3. Hit with several deprecation notices:

Deprecated function: Calling get_class() without arguments is deprecated in Drupal\plugin\Plugin\Plugin\PluginSelector\AdvancedPluginSelectorBase::setPluginSelector() (line 103 of modules/contrib/plugin/src/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBase.php).

Deprecated function: Calling get_class() without arguments is deprecated in Drupal\plugin\Plugin\Plugin\PluginSelector\AdvancedPluginSelectorBase->buildSelectorForm() (line 82 of modules/contrib/plugin/src/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBase.php).

Deprecated function: Calling get_class() without arguments is deprecated in Drupal\plugin\Plugin\Plugin\PluginSelector\AdvancedPluginSelectorBase->buildSelector() (line 320 of modules/contrib/plugin/src/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBase.php).

Deprecated function: Calling get_class() without arguments is deprecated in Drupal\plugin\Plugin\Plugin\PluginSelector\AdvancedPluginSelectorBase->buildSelector() (line 327 of modules/contrib/plugin/src/Plugin/Plugin/PluginSelector/AdvancedPluginSelectorBase.php).

Deprecated function: Calling get_class() without arguments is deprecated in Drupal\plugin\Plugin\Plugin\PluginSelector\SelectList->buildSelector() (line 30 of modules/contrib/plugin/src/Plugin/Plugin/PluginSelector/SelectList.php).

Steps to reproduce

I get these notices when editing the settings for my custom payment gateway module.

Proposed resolution

Replace get_class() with get_called_class().

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇨🇦Canada gregcube

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