Skip to content

Commit 4a89add

Browse files
committed
Better inheritdoc support
1 parent 59ba8e5 commit 4a89add

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/PHPFUI/InstaDoc/Section/CodeCommon.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ protected function formatComments(?\phpDocumentor\Reflection\DocBlock $docBlock,
194194

195195
$container = new \PHPFUI\Container();
196196

197-
$container->add($this->parsedown->text($this->getInheritedSummary($docBlock, $reflectionMethod)));
198-
$desc = $docBlock->getDescription();
197+
$container->add($this->parsedown->text($this->getInheritedText($docBlock, $reflectionMethod, 'getSummary')));
198+
$desc = $this->getInheritedText($docBlock, $reflectionMethod, 'getDescription');
199199

200200
if ($desc)
201201
{
@@ -382,18 +382,16 @@ protected function getComments(?\phpDocumentor\Reflection\DocBlock $docBlock, ?\
382382

383383
protected function getDocBlock($method) : ?\phpDocumentor\Reflection\DocBlock
384384
{
385-
/**
386-
* @todo get attributes everywhere
387-
* $attributes = $this->getAttributes($method);
388-
*/
389385
$comments = $method->getDocComment();
390-
$comments = \str_ireplace('{@inheritdoc}', '@inheritdoc', $comments);
391386

392387
if (! $comments)
393388
{
394389
return null;
395390
}
396391

392+
$comments = \str_ireplace('inheritdocs', 'inheritdoc', $comments);
393+
$comments = \str_ireplace('{@inheritdoc}', '@inheritdoc', $comments);
394+
397395
try
398396
{
399397
$docBlock = $this->factory->create($comments);
@@ -414,9 +412,9 @@ protected function getHtmlClass(string $class) : string
414412
return \str_replace('\\', '-', $class);
415413
}
416414

417-
protected function getInheritedSummary(\phpDocumentor\Reflection\DocBlock $docBlock, ?\ReflectionMethod $reflectionMethod = null) : string
415+
protected function getInheritedText(\phpDocumentor\Reflection\DocBlock $docBlock, ?\ReflectionMethod $reflectionMethod = null, string $textType = 'getDescription') : string
418416
{
419-
$summary = $docBlock->getSummary();
417+
$summary = $docBlock->{$textType}();
420418

421419
if (! $reflectionMethod)
422420
{
@@ -429,7 +427,7 @@ protected function getInheritedSummary(\phpDocumentor\Reflection\DocBlock $docBl
429427
{
430428
$pos = \stripos($tag->getName(), 'inheritdoc');
431429

432-
if (false !== $pos && 0 >= $pos)
430+
if (false !== $pos && 0 <= $pos)
433431
{
434432
$reflectionClass = $reflectionMethod->getDeclaringClass();
435433
$parent = $reflectionClass->getParentClass();
@@ -451,7 +449,7 @@ protected function getInheritedSummary(\phpDocumentor\Reflection\DocBlock $docBl
451449

452450
if ($docBlock)
453451
{
454-
return $summary . "\n" . $this->getInheritedSummary($docBlock, $method);
452+
return $this->getInheritedText($docBlock, $method, $textType) . $summary;
455453
}
456454
}
457455
$parent = $parent->getParentClass();

src/PHPFUI/InstaDoc/Section/Doc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ protected function objectCompare($lhs, $rhs) : int
474474
return \strcasecmp($lhs->name, $rhs->name);
475475
}
476476

477-
protected function objectSort(array & $objects) : void
477+
protected function objectSort(array &$objects) : void
478478
{
479479
\usort($objects, [$this, 'objectCompare']);
480480
}

0 commit comments

Comments
 (0)