Skip to content

Commit 87768c3

Browse files
committed
Refactor
1 parent 68d553d commit 87768c3

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

renderers/BaseRenderer.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,16 @@ public function createTypeLink(
254254

255255
if ($type instanceof Array_ && substr((string) $type, -2, 2) === '[]') {
256256
$valueType = $type->getValueType();
257-
$templateType = $valueType instanceof Object_
258-
? $this->getTemplateType((string) $valueType->getFqsen(), $context)
259-
: null;
260-
261-
if ($templateType !== null) {
262-
$typeLink = $this->createTypeLink($templateType, $context, $title, $options);
263-
if ($templateType instanceof Compound) {
264-
$links[] = "({$typeLink})[]";
265-
} else {
266-
$links[] = "{$typeLink}[]";
257+
if ($valueType instanceof Object_ && $valueType->getFqsen() !== null) {
258+
$templateType = $this->getTemplateType((string) $valueType->getFqsen(), $context);
259+
if ($templateType !== null) {
260+
$typeLink = $this->createTypeLink($templateType, $context, $title, $options);
261+
$links[] = $templateType instanceof Compound ? "({$typeLink})[]" : "{$typeLink}[]";
262+
continue;
267263
}
268-
} else {
269-
$links[] = $this->createTypeLink($valueType, $context, $title, $options) . '[]';
270264
}
271265

266+
$links[] = $this->createTypeLink($valueType, $context, $title, $options) . '[]';
272267
continue;
273268
}
274269

@@ -411,7 +406,7 @@ private function resolveNamespace($context)
411406
return $context->namespace;
412407
}
413408
if ($context->hasProperty('definedBy') && method_exists($context, '__toString')) {
414-
$type = $this->apiContext->getType($context);
409+
$type = $this->apiContext->getType((string) $context);
415410
if ($type !== null) {
416411
return $type->namespace;
417412
}
@@ -719,6 +714,9 @@ private function createLinkByTypeWithGenerics(
719714
return null;
720715
}
721716

717+
/**
718+
* @param Type[] $types
719+
*/
722720
private function createTypeLinksByTypes(
723721
array $types,
724722
?BaseDoc $context,

0 commit comments

Comments
 (0)