Replace deprecated node_type_get_names() calls with entity_type.bundle.info service

Created on 10 September 2025, about 2 months ago

Problem/Motivation

PHPStan reports deprecation errors due to the use of the deprecated node_type_get_names() function.
This function is deprecated in Drupal 11.3.0 and removed in Drupal 13.0.0.
The recommended replacement is \Drupal::service('entity_type.bundle.info')->getBundleLabels('node').

Note: Using configuration file /builds/project/calendar/web/modules/custom/calendar/phpstan.neon.
 ------ ---------------------------------------------------------------------- 
  Line   calendar.theme.inc                                                    
 ------ ---------------------------------------------------------------------- 
  731    Call to deprecated function node_type_get_names():                    
         in drupal:11.3.0 and is removed from drupal:13.0.0. Use               
         \Drupal::service('entity_type.bundle.info')->getBundleLabels('node')  
         instead.                                                              
         🪪  function.deprecated                                               
 ------ ---------------------------------------------------------------------- 
 ------ ---------------------------------------------------------------------- 
  Line   src/Plugin/views/row/Calendar.php                                     
 ------ ---------------------------------------------------------------------- 
  166    Call to deprecated function node_type_get_names():                    
         in drupal:11.3.0 and is removed from drupal:13.0.0. Use               
         \Drupal::service('entity_type.bundle.info')->getBundleLabels('node')  
         instead.                                                              
         🪪  function.deprecated                                               
  558    Call to deprecated function node_type_get_names():                    
         in drupal:11.3.0 and is removed from drupal:13.0.0. Use               
         \Drupal::service('entity_type.bundle.info')->getBundleLabels('node')  
         instead.                                                              
         🪪  function.deprecated                                               
 ------ ---------------------------------------------------------------------- 
 [ERROR] Found 3 errors  

Proposed resolution

Replace calls to node_type_get_names() with calls to the entity type bundle info service:
\Drupal::service('entity_type.bundle.info')->getBundleLabels('node').

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇨🇦Canada joelpittet Vancouver

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024