Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 70701bb8f1 | |||
| 8f9c744134 |
@ -118,6 +118,7 @@ class APIlite
|
||||
$ref_type = $ref_method->getReturnType();
|
||||
$method['return'] = $this->reflectionTypeToNames($ref_type, $ref_method->getDeclaringClass());
|
||||
$method['return_structure'] = $this->reflectionTypeToStructure($ref_type, $ref_method->getDeclaringClass());
|
||||
$method['return_doc'] = $this->parseReturnDoc($method['doc']);
|
||||
}
|
||||
$this->methods[] = $method;
|
||||
}
|
||||
@ -271,6 +272,19 @@ class APIlite
|
||||
return null;
|
||||
}
|
||||
|
||||
private function parseReturnDoc(string $doc): string|null
|
||||
{
|
||||
$lines = explode("\n", $doc);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos($line, '@return') !== false) {
|
||||
$ret = trim(substr($line, strpos($line, '@return') + strlen('@return')));
|
||||
if (strlen($ret) <= 0) return null;
|
||||
return trim(stristr($ret, ' '));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function response(array $arr): void
|
||||
{
|
||||
ob_clean();
|
||||
@ -279,7 +293,7 @@ class APIlite
|
||||
header('Access-Control-Allow-Origin: ' . $origin);
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept');
|
||||
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization');
|
||||
echo json_encode($arr);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -827,6 +827,7 @@ $renderParamControl = function (string $methodName, array $param) use ($formatDe
|
||||
<h3 style="margin-bottom: 1rem; color: #2c3e50;">Return:</h3>
|
||||
<?php if (is_string($method['return'])) { ?>
|
||||
<code class="parameter-type"><?php echo htmlspecialchars($method['return']); ?></code>
|
||||
<?php echo htmlspecialchars((string) $method['return_doc']); ?>
|
||||
<?php } ?>
|
||||
<?php if (is_array($method['return'])) foreach ($method['return'] as $return) { ?>
|
||||
<code class="parameter-type"><?php echo htmlspecialchars((string) $return); ?></code>
|
||||
|
||||
Reference in New Issue
Block a user