| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentMail\Includes\Core; |
| 4 |
|
| 5 |
use ReflectionParameter; |
| 6 |
use ReflectionNamedType; |
| 7 |
|
| 8 |
class Reflection |
| 9 |
{ |
| 10 |
private static function isPhp8OrHigher() |
| 11 |
{ |
| 12 |
return PHP_VERSION_ID >= 80000; |
| 13 |
} |
| 14 |
|
| 15 |
public static function getClassName(ReflectionParameter $parameter) |
| 16 |
{ |
| 17 |
if (static::isPhp8OrHigher()) { |
| 18 |
$type = $parameter->getType(); |
| 19 |
if ($type instanceof ReflectionNamedType && !$type->isBuiltin()) { |
| 20 |
return $type->getName(); |
| 21 |
} |
| 22 |
|
| 23 |
return null; |
| 24 |
} |
| 25 |
|
| 26 |
$class = $parameter->getClass(); |
| 27 |
|
| 28 |
return $class ? $class->getName() : null; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|