Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[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 */
19 interface Callbacks {
20
21 /**
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.
27 */
28 public function hasParam( $name, array $options );
29
30 /**
31 * Fetch a value from the request
32 *
33 * Return `$default` for file-upload parameters.
34 *
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.
40 */
41 public function getValue( $name, $default, array $options );
42
43 /**
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.
48 */
49 public function hasUpload( $name, array $options );
50
51 /**
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.
56 */
57 public function getUploadedFile( $name, array $options );
58
59 /**
60 * Record non-fatal conditions.
61 * @param ValidationException $condition
62 * @param array $options Options array
63 */
64 public function recordCondition( ValidationException $condition, array $options );
65
66 /**
67 * Indicate whether "high limits" should be used.
68 *
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.
72 *
73 * @param array $options Options array
74 * @return bool Whether the current user is privileged to use high limits
75 */
76 public function useHighLimits( array $options );
77
78 }