Skip to content

Commit

Permalink
Coverage 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym committed Oct 5, 2023
1 parent 63555cd commit 9871d04
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/AopCodeGenMethodSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use ReflectionUnionType;

use function array_map;
use function assert;
use function class_exists;
use function implode;
use function in_array;
Expand Down Expand Up @@ -119,20 +120,6 @@ public function getTypeString(?ReflectionType $type): string
return '';
}

// PHP 7.4+
if (class_exists('ReflectionNamedType') && $type instanceof ReflectionNamedType) {
/** @psalm-suppress TypeDoesNotContainType */
$isBuiltinOrSelf = $type->isBuiltin() || in_array($type->getName(), ['self', 'static'], true);
$typeStr = $isBuiltinOrSelf ? $type->getName() : '\\' . $type->getName();

// Check for Nullable in single types
if ($type->allowsNull()) {
$typeStr = $this->nullableStr . $typeStr;
}

return $typeStr;
}

// PHP 8.0+
if (class_exists('ReflectionUnionType') && $type instanceof ReflectionUnionType) {
$types = array_map(/** @param ReflectionNamedType $t */static function ($t) {
Expand All @@ -145,6 +132,17 @@ public function getTypeString(?ReflectionType $type): string
return implode('|', $types);
}

return '';
assert($type instanceof ReflectionNamedType);

/** @psalm-suppress TypeDoesNotContainType */
$isBuiltinOrSelf = $type->isBuiltin() || in_array($type->getName(), ['self', 'static'], true);
$typeStr = $isBuiltinOrSelf ? $type->getName() : '\\' . $type->getName();

// Check for Nullable in single types
if ($type->allowsNull()) {
$typeStr = $this->nullableStr . $typeStr;
}

return $typeStr;
}
}

0 comments on commit 9871d04

Please sign in to comment.