Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions api/ApiRouter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ class ApiRouter
* Route an API call to its specific handler.
*
* @param array<string, string|string[]> $query_params
* @return mixed
*/
public function route(string $url, array $query_params)
public function route(string $url, array $query_params): mixed
{
$node = $this->root;
$data = [];
Expand Down Expand Up @@ -118,8 +117,7 @@ class ApiRouter
throw new InvalidAPI($path, $part, $children);
}

/** @return mixed */
public function request(bool $raw = false)
public function request(bool $raw = false): mixed
{
if ($raw) {
return file_get_contents('php://input');
Expand Down
2 changes: 1 addition & 1 deletion api/api_common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @param array<string, string|string[]> $query_params
*/
function get_flag_value(array $query_params, string $flagname)
function get_flag_value(array $query_params, string $flagname): ?bool
{
if (!isset($query_params[$flagname])) {
return null;
Expand Down
4 changes: 3 additions & 1 deletion api/exceptions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class UnexpectedError extends ApiException

class InvalidAPI extends ApiException
{
/** @param string[] $children */
public function __construct(string $url, ?string $part, array $children, int $code = 8)
{
if (is_null($part)) {
Expand All @@ -114,7 +115,8 @@ class InvalidAPI extends ApiException

class MethodNotAllowed extends ApiException
{
public function __construct(string $url, string $invalid, array $valids, $code = 9)
/** @param string[] $valids */
public function __construct(string $url, string $invalid, array $valids, int $code = 9)
{
$valid = implode(", ", $valids);
$message = "API endpoint $url: Method $invalid not supported. Valid methods: $valid.";
Expand Down
16 changes: 14 additions & 2 deletions api/v1_docs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
include_once($relPath.'faq.inc');
include_once("api_common.inc");

/** @param array<string, string|string[]> $query_params */
/**
* @param array<string, mixed> $data
* @param array<string, string|string[]> $query_params
* @return string[]
* List of document IDs
*/
function api_v1_documents(string $method, array $data, array $query_params): array
{
global $external_faq_overrides;
Expand All @@ -23,7 +28,10 @@ function api_v1_documents(string $method, array $data, array $query_params): arr
return $docs;
}

/** @param array<string, string|string[]> $query_params */
/**
* @param array<string, mixed> $data
* @param array<string, string|string[]> $query_params
*/
function api_v1_document(string $method, array $data, array $query_params): string
{
$lang_code = $query_params["language_code"] ?? "en";
Expand All @@ -36,6 +44,10 @@ function api_v1_document(string $method, array $data, array $query_params): stri
return $faq_url;
}

/**
* @param array<string, mixed> $data
* @return array<string, string>
*/
function api_v1_dictionaries(string $method, array $data): array
{
$dict_list = get_languages_with_dictionaries();
Expand Down
Loading