Skip to content

Commit

Permalink
Fixed incorrect namespace on type hinted return
Browse files Browse the repository at this point in the history
Closes: #1229
  • Loading branch information
sergeyklay committed Nov 2, 2019
1 parent 9231da1 commit d064b4b
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions templates/Api/themes/zephir/partials/class/method-summary.phtml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
<?php
/**
* @var $method \Zephir\ClassMethod
* @var string $classNamespace
* @var Zephir\ClassMethod $method
*/

$allTypes = [];
$_lClasses = $method->getReturnClassTypes();

foreach ($_lClasses as $c) {
foreach ($method->getReturnClassTypes() as $c) {
if ('\\' == $c[0]) {
$allTypes[] = substr($c,1);
} else {
$_lFullClassName = $classNamespace . "\\" . $c;
$_lClassUrl = $this->url(\Zephir\Documentation::classUrl($_lFullClassName));
continue;
}

$aliasManager = $method->getClassDefinition()->getAliasManager();

$allTypes[]= "<a href='$_lClassUrl'>$_lFullClassName</a>";
$returnClassType = "{$classNamespace}\\{$c}";
if ($aliasManager->isAlias($c)) {
$returnClassType = '\\'.$aliasManager->getAlias($c);
}

$allTypes[] = sprintf(
'<a href="%s">%s</a>',
$this->url(Zephir\Documentation::classUrl($returnClassType)),
$returnClassType
);
}

$types = $method->getReturnTypes();

if ($types && count($types)>0 ) {
foreach ($types as $type) {
if ($type && isset($type["data-type"])) {
$allTypes[] = $type["data-type"];
if ($type && isset($type['data-type'])) {
$allTypes[] = $type['data-type'];
}
}
}
Expand All @@ -33,17 +42,22 @@ $docblock = $method->getParsedDocblock();
<li class="class-method clearfix">
<div class="method-summary">
<div class="method-signature">
<span class="method-name"><a href="#method-details-<?= $method->getName() ?>"><?= $method->getName() ?></a></span>(<?= $this->partial("partials/class/method-summary-params.phtml" ) ?>)
<span class="method-return">
&nbsp;<strong>:</strong>&nbsp;
<!-- method-summary -->
<!-- Do not remove comments below. It's a trick to remove the spaces. -->
<span class="method-name">
<a href="#method-details-<?= $method->getName() ?>"><?= $method->getName() ?></a><!--
--></span><!--
-->(<?= $this->partial("partials/class/method-summary-params.phtml" ) ?>)<!--
--><span class="method-return">
<strong>:</strong>
<?php if (!empty($allTypes)):?>
<?php echo join(' | ', $allTypes); ?>
<?php else: ?>
void
<?php endif; ?>
</span>
</div>
<?php if ($docblock):?>
<?php if ($docblock): ?>
<div class="method-doc">
<div class="summary-text">
<?php echo $docblock->getSummary(); ?>
Expand Down

0 comments on commit d064b4b

Please sign in to comment.