File: Callbacks.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (85 lines) | stat: -rw-r--r-- 2,692 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php

namespace Wikimedia\ParamValidator;

use Psr\Http\Message\UploadedFileInterface;
use Wikimedia\Message\DataMessageValue;

/**
 * Interface defining callbacks needed by ParamValidator
 *
 * The user of ParamValidator is expected to pass an object implementing this
 * interface to ParamValidator's constructor.
 *
 * All methods in this interface accept an "options array". This is the same `$options`
 * passed to ParamValidator::getValue(), ParamValidator::validateValue(), and the like
 * and is intended for communication of non-global state.
 *
 * @since 1.34
 * @unstable
 */
interface Callbacks {

	/**
	 * Test if a parameter exists in the request
	 * @param string $name Parameter name
	 * @param array $options Options array
	 * @return bool True if present, false if absent.
	 *  Return false for file upload parameters.
	 */
	public function hasParam( $name, array $options );

	/**
	 * Fetch a value from the request
	 *
	 * Return `$default` for file-upload parameters.
	 *
	 * @param string $name Parameter name to fetch
	 * @param mixed $default Default value to return if the parameter is unset.
	 * @param array $options Options array
	 * @return string|string[]|mixed A string or string[] if the parameter was found,
	 *  or $default if it was not.
	 */
	public function getValue( $name, $default, array $options );

	/**
	 * Test if a parameter exists as an upload in the request
	 * @param string $name Parameter name
	 * @param array $options Options array
	 * @return bool True if present, false if absent.
	 */
	public function hasUpload( $name, array $options );

	/**
	 * Fetch data for a file upload
	 * @param string $name Parameter name of the upload
	 * @param array $options Options array
	 * @return UploadedFileInterface|null Uploaded file, or null if there is no file for $name.
	 */
	public function getUploadedFile( $name, array $options );

	/**
	 * Record non-fatal conditions.
	 * @param DataMessageValue $message Failure message
	 * @param string $name Parameter name
	 * @param mixed $value Parameter value
	 * @param array $settings Parameter settings array
	 * @param array $options Options array
	 */
	public function recordCondition(
		DataMessageValue $message, $name, $value, array $settings, array $options
	);

	/**
	 * Indicate whether "high limits" should be used.
	 *
	 * Some settings have multiple limits, one for "normal" users and a higher
	 * one for "privileged" users. This is used to determine which class the
	 * current user is in when necessary.
	 *
	 * @param array $options Options array
	 * @return bool Whether the current user is privileged to use high limits
	 */
	public function useHighLimits( array $options );

}