private function getConstants() : array {
static $pattern = '/
\*\s+
+ (?:[<]span[ ]class="constant"[>])?
(?<name>\w+)
+ (?:[<]\/span[>])?
(?:\s*=\s*(?P<value>.+))?
(?P<desc>(?:\s*\n\s*[^\*\n#].*)*)
/x';
static $pattern = '/
\*\s+
(?P<modifiers>\w+\s+)*
+ (?:\((?P<usages>(?:(?:\w+)\s*)*)\))*\s*
(?P<type>[\\\\\w]+)\s+
(?<name>\$\w+)
(?:\s*=\s*(?P<defval>.+))?
static $pattern = '/
\*\s+
(?P<modifiers>\w+\s+)*
- (?P<type>[\\\\\w]+)\s+
- (?<name>\$\w+)
+ (?P<type>[\\\\\w_]+)\s+
+ (?P<ref>&)?(?P<name>\$[\w_]+)
(?:\s*=\s*(?P<defval>.+))?
(?P<desc>(?:\s*[^*]*\n(?!\n)\s*[^\*].*)*)
/x';
private function getReturns() : array {
static $pattern = '/
\*\s+
- (?<type>[\\\\\w]+)
+ (?<type>[\\\\\w_]+)
\s*,?\s*
(?P<desc>(?:.|\n(?!\s*\*))*)
/x';
-
+
$returns = $this->splitList($pattern, $this->getSection("Returns"));
$retvals = [];
foreach ($returns as list(, $type, $desc)) {
return $type;
break;
default:
- return ($type{0} === "\\" ? "":"\\") . $type;
+ return ($type[0] === "\\" ? "":"\\") . $type;
break;
}
}
public $ns;
public $props;
- static $lastNs;
-
function format() {
if ($this->ns !== StructureOfNs::$last) {
printf("namespace %s;\n", $this->ns);
public $type;
public $desc;
public $modifiers;
+ public $usages;
public $defval;
+ public $ref;
function formatDefval() {
if (strlen($this->defval)) {
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) {
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();
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();
}
}