3 namespace mdref\Generator
;
6 use phpDocumentor\Reflection\DocBlock
;
8 class Cls
extends Scrap
{
9 public function __toString() :string {
10 return parent
::toString(__FILE__
, __COMPILER_HALT_OFFSET__
);
14 /** @var $gen Generator */
15 /** @var $ref \ReflectionClass */
16 /** @var $doc DocBlock */
17 /** @var $patch callable as function(string, \Reflector) */
21 if ($ref instanceof \ReflectionEnum
) :
24 ?
><?
= implode(" ", \Reflection
::getModifierNames($ref->getModifiers()));
25 ?
> <?
= $ref->isInterface() ?
"interface" : "class"
29 ?
> <?
= $ref->getName() ?
><?php
31 if (($parent = $ref->getParentClass())) :
32 ?
> extends <?
= $parent->getName() ?
><?php
34 if (($implements = $ref->getInterfaceNames())) :
35 foreach ($implements as $index => $iface) :
36 foreach ($implements as $implemented) :
37 if ($iface !== $implemented && is_subclass_of($implemented, $iface)) :
38 unset($implements[$index]);
43 ?
> implements <?
= implode(", ", $implements); ?
><?php
48 <?
= $doc?
->getSummary() ?
>
51 <?
= $doc?
->getDescription() ?
>
54 <?php
$patch(SeeAlso
::class, $ref) ?
>
61 if (!($consts = array_filter($ref->getReflectionConstants(), fn($rc) => $rc->getDeclaringClass()->getName() === $ref->getName()))) :
64 /** @var \ReflectionClassConstant $rc */
65 foreach ($consts as $rc) :
66 ?
> * <span
class="constant"><?
= $rc->getName();
67 ?
></span
> = <span
><?php
68 if ($rc->getValue() instanceof \UnitEnum
) :
69 var_export($rc->getValue()->value
);
71 var_export($rc->getValue());
83 if (!($props = array_filter($ref->getProperties(), fn($rp) => $rp->getDeclaringClass()->getName() === $ref->getName()))) :
86 foreach ($props as $rp) :
88 $patch(Prop
::class, $rp);