Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
rector-bot committed Jan 29, 2021
1 parent 1c882b5 commit 83de443
Showing 1 changed file with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ private function resolveStringParameters(array $parameterReflections): array
return $stringParameters;
}

private function resolveReturnTagTypeNode(ReturnTagValueNode $returnTagValueNode, TemplateTypeMap $templateTypeMap): TypeNode
{
private function resolveReturnTagTypeNode(
ReturnTagValueNode $returnTagValueNode,
TemplateTypeMap $templateTypeMap
): TypeNode {
$returnTagTypeNode = $returnTagValueNode->type;

if ($returnTagValueNode->type instanceof UnionTypeNode) {
return $this->resolveUnionTypeNode($returnTagValueNode->type, $templateTypeMap);
} elseif ($returnTagValueNode->type instanceof IdentifierTypeNode) {
}

if ($returnTagValueNode->type instanceof IdentifierTypeNode) {
return $this->resolveIdentifierTypeNode(
$returnTagValueNode->type,
$templateTypeMap,
Expand All @@ -94,22 +97,6 @@ private function resolveReturnTagTypeNode(ReturnTagValueNode $returnTagValueNode
return $returnTagTypeNode;
}

private function resolveIdentifierTypeNode(
IdentifierTypeNode $identifierTypeNode,
TemplateTypeMap $templateTypeMap,
TypeNode $fallbackTypeNode
): TypeNode {
$typeName = $identifierTypeNode->name;
$genericType = $templateTypeMap->getType($typeName);

if ($genericType instanceof Type) {
$returnTagType = $genericType;
return $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($returnTagType);
}

return $fallbackTypeNode;
}

private function resolveUnionTypeNode(UnionTypeNode $unionTypeNode, TemplateTypeMap $templateTypeMap): UnionTypeNode
{
$resolvedTypes = [];
Expand All @@ -133,4 +120,20 @@ private function resolveUnionTypeNode(UnionTypeNode $unionTypeNode, TemplateType

return new UnionTypeNode($resolvedTypes);
}

private function resolveIdentifierTypeNode(
IdentifierTypeNode $identifierTypeNode,
TemplateTypeMap $templateTypeMap,
TypeNode $fallbackTypeNode
): TypeNode {
$typeName = $identifierTypeNode->name;
$genericType = $templateTypeMap->getType($typeName);

if ($genericType instanceof Type) {
$returnTagType = $genericType;
return $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($returnTagType);
}

return $fallbackTypeNode;
}
}

0 comments on commit 83de443

Please sign in to comment.