From: Michael Wallner Date: Wed, 13 Mar 2019 13:51:03 +0000 (+0100) Subject: fix var names and references X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ef5031e18d8497180ad6fc1bc5bc4ea59c64c9d5;p=mdref%2Fmdref fix var names and references --- diff --git a/mdref/Structure.php b/mdref/Structure.php index 602bca2..dc871d1 100644 --- a/mdref/Structure.php +++ b/mdref/Structure.php @@ -187,8 +187,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,7 +204,7 @@ class Structure { private function getReturns() : array { static $pattern = '/ \*\s+ - (?[\\\\\w]+) + (?[\\\\\w_]+) \s*,?\s* (?P(?:.|\n(?!\s*\*))*) /x'; @@ -353,8 +353,6 @@ class StructureOfClass extends StructureOfNs public $ns; public $props; - static $lastNs; - function format() { if ($this->ns !== StructureOfNs::$last) { printf("namespace %s;\n", $this->ns); @@ -469,6 +467,7 @@ class StructureOfVar extends StructureOf { public $desc; public $modifiers; public $defval; + public $ref; function formatDefval() { if (strlen($this->defval)) { @@ -476,6 +475,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) { @@ -498,7 +500,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(); } }