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.
22 * Test if a parameter exists in the request
23 * @param string $name Parameter name
24 * @param array $options Options array
25 * @return bool True if present, false if absent.
26 * Return false for file upload parameters.
28 public function hasParam( $name, array $options );
31 * Fetch a value from the request
33 * Return `$default` for file-upload parameters.
35 * @param string $name Parameter name to fetch
36 * @param mixed $default Default value to return if the parameter is unset.
37 * @param array $options Options array
38 * @return string|string[]|mixed A string or string[] if the parameter was found,
39 * or $default if it was not.
41 public function getValue( $name, $default, array $options );
44 * Test if a parameter exists as an upload in the request
45 * @param string $name Parameter name
46 * @param array $options Options array
47 * @return bool True if present, false if absent.
49 public function hasUpload( $name, array $options );
52 * Fetch data for a file upload
53 * @param string $name Parameter name of the upload
54 * @param array $options Options array
55 * @return UploadedFileInterface|null Uploaded file, or null if there is no file for $name.
57 public function getUploadedFile( $name, array $options );
60 * Record non-fatal conditions.
61 * @param ValidationException $condition
62 * @param array $options Options array
64 public function recordCondition( ValidationException
$condition, array $options );
67 * Indicate whether "high limits" should be used.
69 * Some settings have multiple limits, one for "normal" users and a higher
70 * one for "privileged" users. This is used to determine which class the
71 * current user is in when necessary.
73 * @param array $options Options array
74 * @return bool Whether the current user is privileged to use high limits
76 public function useHighLimits( array $options );