\ReflectionParameter::getClass() is deprecated in PHP 8.0

Created on 2 July 2020, over 4 years ago
Updated 11 September 2023, about 1 year ago

Problem/Motivation

PHP has deprecated \ReflectionParameter::getClass(). We should replace our usages of it:

We use it in:

  • ArgumentsResolver
  • EntityResolverManager
  • ProxyBuilder
  • TaggedHandlersPass

Proposed resolution

Add helper to core/lib/Drupal/Component/Utility to handle this. Hopefully this approach will make it easier to backport to Drupal 8 and supporting PHP7 means that we need to still use getClass() there. It's not necessary at all in Drupal 9 since the reflection classes and methods we should use exist since PHP 7.2.

Remaining tasks

None

User interface changes

None

API changes

Calls to \ReflectionParameter::getClass() should be replaced with \Drupal\Component\Utility\Reflection::getParameterClassName($parameter);. Note that Reflection::getParameterClassName() returns the class name as a string and not a \ReflectionClass object.

Data model changes

None

Release notes snippet

In order to be PHP 8 compatible code that uses \ReflectionParameter::getClass() should use the new utility \Drupal\Component\Utility\Reflection::getParameterClassName() instead. See

πŸ› Bug report
Status

Fixed

Version

9.1

Component
BaseΒ  β†’

Last updated about 6 hours ago

Created by

πŸ‡ΊπŸ‡¦Ukraine voleger Ukraine, Rivne

Live updates comments and jobs are added and updated live.
  • PHP 8.0

    The issue particularly affects sites running on PHP version 8.0.0 or later.

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.

Production build 0.71.5 2024