ParamValidator: Flag as unstable for 1.34
[lhc/web/wiklou.git] / includes / libs / ParamValidator / Callbacks.php
1 <?php
2
3 namespace Wikimedia\ParamValidator;
4
5 use Psr\Http\Message\UploadedFileInterface;
6
7 /**
8 * Interface defining callbacks needed by ParamValidator
9 *
10 * The user of ParamValidator is expected to pass an object implementing this
11 * interface to ParamValidator's constructor.
12 *
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.
16 *
17 * @since 1.34
18 * @unstable
19 */
20 interface Callbacks {
21
22 /**
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.
28 */
29 public function hasParam( $name, array $options );
30
31 /**
32 * Fetch a value from the request
33 *
34 * Return `$default` for file-upload parameters.
35 *
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.
41 */
42 public function getValue( $name, $default, array $options );
43
44 /**
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.
49 */
50 public function hasUpload( $name, array $options );
51
52 /**
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.
57 */
58 public function getUploadedFile( $name, array $options );
59
60 /**
61 * Record non-fatal conditions.
62 * @param ValidationException $condition
63 * @param array $options Options array
64 */
65 public function recordCondition( ValidationException $condition, array $options );
66
67 /**
68 * Indicate whether "high limits" should be used.
69 *
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.
73 *
74 * @param array $options Options array
75 * @return bool Whether the current user is privileged to use high limits
76 */
77 public function useHighLimits( array $options );
78
79 }