*/
private $response;
+ /**
+ * @var resource
+ */
+ private $output;
+
/**
* @var \http\Url
*/
/**
* Initialize the reference
*/
- public function __construct(Reference $ref, Request $req, Response $res, BaseUrl $baseUrl) {
+ public function __construct(Reference $ref, Request $req, Response $res, BaseUrl $baseUrl, $output = null) {
$this->reference = $ref;
$this->request = $req;
$this->response = $res;
$this->baseUrl = $baseUrl;
+ $this->output = $output;
ob_start($res);
}
private function serveCanonical(string $cnn) : void {
$this->response->setHeader("Location", $this->baseUrl->mod(["path" => $cnn]));
$this->response->setResponseCode(301);
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
private function serveStylesheet() : void {
$this->response->setHeader("Content-Type", "text/css");
$this->response->setBody(new Body(\fopen(ROOT."/public/index.css", "r")));
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
private function serveJavascript() : void {
$this->response->setHeader("Content-Type", "application/javascript");
$this->response->setBody(new Body(\fopen(ROOT."/public/index.js", "r")));
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
$this->response->setHeader("Content-Type", "application/x-php");
$this->response->setContentDisposition(["attachment" => ["filename" => "$name.stub.php"]]);
$this->response->setBody(new Body(\fopen($stub, "r")));
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
include ROOT."/views/layout.phtml";
$this->response->addHeader("Link", "<" . $this->baseUrl->path . "index.css>; rel=preload; as=style");
$this->response->addHeader("Link", "<" . $this->baseUrl->path . "index.js>; rel=preload; as=script");
- $this->response->send();
+ if (is_resource($this->output)) {
+ $this->response->send($this->output);
+ } else {
+ $this->response->send();
+ }
}
/**
*/
public function isFunction() : bool {
$base = end($this->list);
- return $base{0} === "_" || ctype_lower($base{0});
+ return $base[0] === "_" || ctype_lower($base[0]);
}
/**
*/
public function isNsClass() : bool {
$base = end($this->list);
- return ctype_upper($base{0});
+ return ctype_upper($base[0]);
}
/**
}
$parent = end($parts);
- switch ($myself{0}) {
+ switch ($myself[0]) {
case ":":
return "★" . substr($myself, 1);
default:
- if (!ctype_lower($myself{0}) || ctype_lower($parent{0})) {
+ if (!ctype_lower($myself[0]) || ctype_lower($parent[0])) {
return $myself;
}
case "_":
public function readFullDescription() : ?string {
$desc = $this->readDescription();
while (false !== ($line = fgets($this->fd))) {
- if ($line{0} === "#") {
+ if ($line[0] === "#") {
break;
} else {
$desc .= $line;
static $pattern = '/
\*\s+
(?P<modifiers>\w+\s+)*
+ (?:\((?P<usages>(?:(?:\w+)\s*)*)\))*\s*
(?P<type>[\\\\\w]+)\s+
(?<name>\$\w+)
(?:\s*=\s*(?P<defval>.+))?
\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 $type;
public $desc;
public $modifiers;
+ public $usages;
public $defval;
public $ref;
printf(" = ");
var_export(constant($this->defval));
} else if (strlen($this->defval)) {
- if (false !== strchr($this->defval, "\\") && $this->defval{0} != "\\") {
+ if (false !== strchr($this->defval, "\\") && $this->defval[0] != "\\") {
$this->defval = "\\" . $this->defval;
}
printf(" = %s", $this->defval);
function formatAsProp($level) {
$indent = str_repeat("\t", $level);
$this->formatDesc($level,
- preg_split('/\s+/', $this->modifiers, -1, PREG_SPLIT_NO_EMPTY)
+ preg_split('/\s+/', $this->modifiers ." " . $this->usages, -1, PREG_SPLIT_NO_EMPTY)
+ [-1 => "var " . $this->saneType($this->type)]
);
printf("%s%s %s", $indent, $this->modifiers, $this->name);
*/
private function generateFilter(array $list) : \Closure {
return function($v) use($list) {
- if ($v{0} === ".") {
+ if ($v[0] === ".") {
return false;
}
if (false !== array_search("$v.md", $list, true)) {
$ab = basename($a, ".md");
$bb = basename($b, ".md");
- if ($ab{0} === ":" && $bb{0} === ":") {
+ if ($ab[0] === ":" && $bb[0] === ":") {
return strcmp($ab, $bb);
- } elseif ($ab{0} === ":") {
+ } elseif ($ab[0] === ":") {
return -1;
- } elseif ($bb{0} === ":") {
+ } elseif ($bb[0] === ":") {
return 1;
}
});
setTimeout(function() {
$("footer").addClass("hidden");
- }, 1);
+ }, 1000);
});