Change record status: 
Project: 
Introduced in branch: 
9.1.x
Introduced in version: 
9.1.0
Description: 

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

Before

function foo(Exception $a) { }

$functionReflection = new ReflectionFunction('foo');
$parameters = $functionReflection->getParameters();
$aParameter = $parameters[0];

echo $aParameter->getClass()->name;

After

function foo(Exception $a) { }

$functionReflection = new ReflectionFunction('foo');
$parameters = $functionReflection->getParameters();
$aParameter = $parameters[0];

$param_class = \Drupal\Component\Utility\Reflection::getParameterClassName($aParameter);
echo $param_class;

// If you need the reflection class object.
$reflection = new \ReflectionClass($param_class);
echo $reflection->name;
Impacts: 
Module developers