Reflection.php in Drupal 9
File
core/lib/Drupal/Component/Utility/Reflection.php
View source
<?php
namespace Drupal\Component\Utility;
final class Reflection {
public static function getParameterClassName(\ReflectionParameter $parameter) : ?string {
$name = NULL;
if ($parameter
->hasType() && !$parameter
->getType()
->isBuiltin()) {
$name = $parameter
->getType()
->getName();
$lc_name = strtolower($name);
switch ($lc_name) {
case 'self':
return $parameter
->getDeclaringClass()
->getName();
case 'parent':
return ($parent = $parameter
->getDeclaringClass()
->getParentClass()) ? $parent->name : NULL;
}
}
return $name;
}
}