move formatting from JS to PHP
[mdref/mdref] / mdref / Generator / Arg.php
1 <?php
2
3 namespace mdref\Generator;
4
5 use mdref\Generator;
6 use phpDocumentor\Reflection\{DocBlock, DocBlock\Tags};
7
8 class Arg extends Scrap {
9 public function __toString() : string {
10 return parent::toString(__FILE__, __COMPILER_HALT_OFFSET__, [
11 "tag" => $this->getParamTag($this->ref->getName())
12 ]);
13 }
14
15 }
16
17 /** @var $gen Generator */
18 /** @var $ref \ReflectionParameter */
19 /** @var $doc ?DocBlock */
20 /** @var $tag ?Tags\Param */
21
22 __HALT_COMPILER();
23 <?= $ref->hasType() ? $ref->getType() : str_replace("\\ref", "", $tag?->getType() ?? "mixed")
24 ?> <?php
25 if ($ref->isVariadic()) : ?>
26 ?>...<?php
27 endif;
28 if ($ref->isPassedByReference()) :
29 ?>&<?php
30 endif;
31 ?>$<?=$ref->getName()
32 ?><?php
33 if ($ref->isDefaultValueAvailable()) :
34 ?> = <?php var_export($ref->getDefaultValue()) ?><?php
35 endif;