3 namespace Wikimedia\ParamValidator
;
5 use Psr\Http\Message\UploadedFileInterface
;
8 * Interface defining callbacks needed by ParamValidator
10 * The user of ParamValidator is expected to pass an object implementing this
11 * interface to ParamValidator's constructor.
13 * All methods in this interface accept an "options array". This is the same `$options`
14 * passed to ParamValidator::getValue(), ParamValidator::validateValue(), and the like
15 * and is intended for communication of non-global state.
23 * Test if a parameter exists in the request
24 * @param string $name Parameter name
25 * @param array $options Options array
26 * @return bool True if present, false if absent.
27 * Return false for file upload parameters.
29 public function hasParam( $name, array $options );
32 * Fetch a value from the request
34 * Return `$default` for file-upload parameters.
36 * @param string $name Parameter name to fetch
37 * @param mixed $default Default value to return if the parameter is unset.
38 * @param array $options Options array
39 * @return string|string[]|mixed A string or string[] if the parameter was found,
40 * or $default if it was not.
42 public function getValue( $name, $default, array $options );
45 * Test if a parameter exists as an upload in the request
46 * @param string $name Parameter name
47 * @param array $options Options array
48 * @return bool True if present, false if absent.
50 public function hasUpload( $name, array $options );
53 * Fetch data for a file upload
54 * @param string $name Parameter name of the upload
55 * @param array $options Options array
56 * @return UploadedFileInterface|null Uploaded file, or null if there is no file for $name.
58 public function getUploadedFile( $name, array $options );
61 * Record non-fatal conditions.
62 * @param ValidationException $condition
63 * @param array $options Options array
65 public function recordCondition( ValidationException
$condition, array $options );
68 * Indicate whether "high limits" should be used.
70 * Some settings have multiple limits, one for "normal" users and a higher
71 * one for "privileged" users. This is used to determine which class the
72 * current user is in when necessary.
74 * @param array $options Options array
75 * @return bool Whether the current user is privileged to use high limits
77 public function useHighLimits( array $options );