summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2025-02-13 23:37:28 +0100
committeremkael <emkael@tlen.pl>2025-02-13 23:50:03 +0100
commitffe02865d24f9a5ccff4ccff41355612a34dd624 (patch)
tree7af07574a79d2a6475833bf3f3e9bca7e880228d /http
parent493a93248ed6304e3ed4a0d9b465439097162b0f (diff)
Elaborate comments on check_parameters and parse_parameters
Diffstat (limited to 'http')
-rw-r--r--http/api-inc.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/http/api-inc.php b/http/api-inc.php
index b33b9e0..ca8e0de 100644
--- a/http/api-inc.php
+++ b/http/api-inc.php
@@ -186,6 +186,16 @@ class ApiPkl {
}
}
+ /*
+ * This shouldn't alter any parameters, just validate them.
+ * The exception is when a new version no longer marks parameter
+ as mandatory, and assumes some default/derived values.
+ * Or when a parameter value marks other parameters as ignored,
+ meaning these parameters should never reach parse_parameters().
+ * Only then check_parameters should alter the provided
+ parameter list, which is also why it's still passed around
+ as an argument->return value.
+ */
function check_parameters($parameters) {
$this->ensure_parameters($parameters, array('type', 'contestants'));
$this->check_values($parameters, array(
@@ -262,6 +272,17 @@ class ApiPkl {
return $parameters;
}
+ /*
+ * This parses the parameters, transforms them and fills missing,
+ derivable data.
+ * When overriding, be careful when to use the original parameter list
+ from method argument, and when to use parameter list parsed
+ by parent::parse_parameters.
+ * Good guideline is that when API version introduces new parameter,
+ it must be parsed from method argument (as parent wouldn't parse it),
+ and all other times, the return value of parent::parse_parameters
+ is likely to be used.
+ */
function parse_parameters($parameters) {
$return = array();
$return['type'] = intval($parameters['type']);