Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 808fd747fe | |||
| 70701bb8f1 | |||
| 8f9c744134 |
@ -118,6 +118,7 @@ class APIlite
|
|||||||
$ref_type = $ref_method->getReturnType();
|
$ref_type = $ref_method->getReturnType();
|
||||||
$method['return'] = $this->reflectionTypeToNames($ref_type, $ref_method->getDeclaringClass());
|
$method['return'] = $this->reflectionTypeToNames($ref_type, $ref_method->getDeclaringClass());
|
||||||
$method['return_structure'] = $this->reflectionTypeToStructure($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;
|
$this->methods[] = $method;
|
||||||
}
|
}
|
||||||
@ -271,6 +272,22 @@ class APIlite
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function parseReturnDoc(?string $doc): string|null
|
||||||
|
{
|
||||||
|
if (is_null($doc) || $doc === '') {
|
||||||
|
return 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
|
private function response(array $arr): void
|
||||||
{
|
{
|
||||||
ob_clean();
|
ob_clean();
|
||||||
@ -279,7 +296,7 @@ class APIlite
|
|||||||
header('Access-Control-Allow-Origin: ' . $origin);
|
header('Access-Control-Allow-Origin: ' . $origin);
|
||||||
header('Access-Control-Allow-Credentials: true');
|
header('Access-Control-Allow-Credentials: true');
|
||||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
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);
|
echo json_encode($arr);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -827,6 +827,7 @@ $renderParamControl = function (string $methodName, array $param) use ($formatDe
|
|||||||
<h3 style="margin-bottom: 1rem; color: #2c3e50;">Return:</h3>
|
<h3 style="margin-bottom: 1rem; color: #2c3e50;">Return:</h3>
|
||||||
<?php if (is_string($method['return'])) { ?>
|
<?php if (is_string($method['return'])) { ?>
|
||||||
<code class="parameter-type"><?php echo htmlspecialchars($method['return']); ?></code>
|
<code class="parameter-type"><?php echo htmlspecialchars($method['return']); ?></code>
|
||||||
|
<?php echo htmlspecialchars((string) $method['return_doc']); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if (is_array($method['return'])) foreach ($method['return'] as $return) { ?>
|
<?php if (is_array($method['return'])) foreach ($method['return'] as $return) { ?>
|
||||||
<code class="parameter-type"><?php echo htmlspecialchars((string) $return); ?></code>
|
<code class="parameter-type"><?php echo htmlspecialchars((string) $return); ?></code>
|
||||||
|
|||||||
Reference in New Issue
Block a user