X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=mdref%2FStructure.php;h=ace780b4d0c62b340be869c124cdefebc3132cda;hb=a94ecb1009610a763dd74a7eebc4754b6643d832;hp=217cc13050a58bfe9fb7fb26e86a458248731b5d;hpb=8e4bf09cdf6976323ecd93e21114d2eba2b29e6a;p=mdref%2Fmdref diff --git a/mdref/Structure.php b/mdref/Structure.php index 217cc13..ace780b 100644 --- a/mdref/Structure.php +++ b/mdref/Structure.php @@ -129,7 +129,9 @@ class Structure { private function getConstants() : array { static $pattern = '/ \*\s+ + (?:[<]span[ ]class="constant"[>])? (?\w+) + (?:[<]\/span[>])? (?:\s*=\s*(?P.+))? (?P(?:\s*\n\s*[^\*\n#].*)*) /x'; @@ -149,6 +151,7 @@ class Structure { static $pattern = '/ \*\s+ (?P\w+\s+)* + (?:\((?P(?:(?:\w+)\s*)*)\))*\s* (?P[\\\\\w]+)\s+ (?\$\w+) (?:\s*=\s*(?P.+))? @@ -187,8 +190,8 @@ class Structure { static $pattern = '/ \*\s+ (?P\w+\s+)* - (?P[\\\\\w]+)\s+ - (?\$\w+) + (?P[\\\\\w_]+)\s+ + (?P&)?(?P\$[\w_]+) (?:\s*=\s*(?P.+))? (?P(?:\s*[^*]*\n(?!\n)\s*[^\*].*)*) /x'; @@ -204,11 +207,11 @@ class Structure { private function getReturns() : array { static $pattern = '/ \*\s+ - (?[\\\\\w]+) + (?[\\\\\w_]+) \s*,?\s* (?P(?:.|\n(?!\s*\*))*) /x'; - + $returns = $this->splitList($pattern, $this->getSection("Returns")); $retvals = []; foreach ($returns as list(, $type, $desc)) { @@ -294,7 +297,7 @@ abstract class StructureOf { return $type; break; default: - return ($type{0} === "\\" ? "":"\\") . $type; + return ($type[0] === "\\" ? "":"\\") . $type; break; } } @@ -353,8 +356,6 @@ class StructureOfClass extends StructureOfNs public $ns; public $props; - static $lastNs; - function format() { if ($this->ns !== StructureOfNs::$last) { printf("namespace %s;\n", $this->ns); @@ -432,7 +433,7 @@ class StructureOfFunc extends StructureOf { $desc .= $this->saneType($typ, false) . " " . $ret; } } else { - $type = $this->saneType($this->returns[0][0]); + $type = $this->saneType($this->returns[0][0], false); $desc = $this->returns[0][1]; } $tags[] = "return $type $desc"; @@ -468,7 +469,9 @@ class StructureOfVar extends StructureOf { public $type; public $desc; public $modifiers; + public $usages; public $defval; + public $ref; function formatDefval() { if (strlen($this->defval)) { @@ -476,6 +479,9 @@ class StructureOfVar extends StructureOf { printf(" = "); var_export(constant($this->defval)); } else if (strlen($this->defval)) { + if (false !== strchr($this->defval, "\\") && $this->defval[0] != "\\") { + $this->defval = "\\" . $this->defval; + } printf(" = %s", $this->defval); } } elseif ($this->modifiers) { @@ -487,8 +493,8 @@ class StructureOfVar extends StructureOf { function formatAsProp($level) { $indent = str_repeat("\t", $level); $this->formatDesc($level, - preg_split('/\s+/', $this->modifiers, -1, PREG_SPLIT_NO_EMPTY) - + [-1 => "var " . $this->saneType($this->type)] + preg_split('/\s+/', $this->modifiers ." " . $this->usages, -1, PREG_SPLIT_NO_EMPTY) + + [-1 => "var " . $this->saneType($this->type, false)] ); printf("%s%s %s", $indent, $this->modifiers, $this->name); $this->formatDefval(); @@ -498,7 +504,7 @@ class StructureOfVar extends StructureOf { if ($with_type && strlen($type = $this->saneType($this->type))) { printf("%s ", $type); } - printf("%s", $this->name); + printf("%s%s", $this->ref, $this->name); $this->formatDefval(); } }