3 namespace mdref\Generator
;
6 use phpDocumentor\Reflection\
{DocBlock
, DocBlock\Tags
, DocBlockFactory
};
8 class Func
extends Scrap
{
9 public function __toString() : string {
10 return parent
::toString(__FILE__
, __COMPILER_HALT_OFFSET__
);
14 /** @var $gen Generator */
15 /** @var $ref \ReflectionFunctionAbstract */
16 /** @var $doc DocBlock */
17 /** @var $patch callable as function(string, \Reflector) */
21 if ($ref instanceof \ReflectionMethod
) :
22 if ($ref->isFinal()) :
25 if ($ref->isStatic()) :
29 ?
><?
= $ref->hasReturnType() ?
$ref->getReturnType() : "void"
31 if ($ref instanceof \ReflectionMethod
) :
32 ?
><?
=$ref->getDeclaringClass()->getName()
35 ?
><?
= $ref->getName() ?
>
38 foreach ($ref->getParameters() as $i => $param) :
39 if ($param->isOptional()) : $optional++
42 $patch(Arg
::class, $param);
43 if ($i < $ref->getNumberOfParameters()-1):
47 echo str_repeat("]", $optional);
51 <?
= $doc?
->getSummary() ?
>
54 <?
= $doc?
->getDescription()?
->getBodyTemplate() ?
>
57 <?php
$patch(SeeAlso
::class, $ref) ?
>
64 if (!($params = $ref->getParameters())) :
67 foreach ($params as $i => $param) :
68 $patch(Param
::class, $param);
72 if (($tags = $doc?
->getTagsWithTypeByName("return")) ||
($ref->hasReturnType() && $ref->hasReturnType() != "void")) :
80 foreach ($tags as $tag) :
81 ?
>* <?
= $tag->getType()
82 ?
>, <?
= $tag->getDescription()
87 ?
>* <?
= $ref->getReturnType()