3 namespace Wikimedia\ParamValidator
;
5 use Psr\Http\Message\UploadedFileInterface
;
6 use Wikimedia\Message\DataMessageValue
;
9 * Interface defining callbacks needed by ParamValidator
11 * The user of ParamValidator is expected to pass an object implementing this
12 * interface to ParamValidator's constructor.
14 * All methods in this interface accept an "options array". This is the same `$options`
15 * passed to ParamValidator::getValue(), ParamValidator::validateValue(), and the like
16 * and is intended for communication of non-global state.
24 * Test if a parameter exists in the request
25 * @param string $name Parameter name
26 * @param array $options Options array
27 * @return bool True if present, false if absent.
28 * Return false for file upload parameters.
30 public function hasParam( $name, array $options );
33 * Fetch a value from the request
35 * Return `$default` for file-upload parameters.
37 * @param string $name Parameter name to fetch
38 * @param mixed $default Default value to return if the parameter is unset.
39 * @param array $options Options array
40 * @return string|string[]|mixed A string or string[] if the parameter was found,
41 * or $default if it was not.
43 public function getValue( $name, $default, array $options );
46 * Test if a parameter exists as an upload in the request
47 * @param string $name Parameter name
48 * @param array $options Options array
49 * @return bool True if present, false if absent.
51 public function hasUpload( $name, array $options );
54 * Fetch data for a file upload
55 * @param string $name Parameter name of the upload
56 * @param array $options Options array
57 * @return UploadedFileInterface|null Uploaded file, or null if there is no file for $name.
59 public function getUploadedFile( $name, array $options );
62 * Record non-fatal conditions.
63 * @param DataMessageValue $message Failure message
64 * @param string $name Parameter name
65 * @param mixed $value Parameter value
66 * @param array $settings Parameter settings array
67 * @param array $options Options array
69 public function recordCondition(
70 DataMessageValue
$message, $name, $value, array $settings, array $options
74 * Indicate whether "high limits" should be used.
76 * Some settings have multiple limits, one for "normal" users and a higher
77 * one for "privileged" users. This is used to determine which class the
78 * current user is in when necessary.
80 * @param array $options Options array
81 * @return bool Whether the current user is privileged to use high limits
83 public function useHighLimits( array $options );