Passed
Push — master ( 8abad7...76e60c )
by Joas
13:43 queued 14s
created
lib/public/IRequest.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -62,263 +62,263 @@
 block discarded – undo
62 62
  * @since 6.0.0
63 63
  */
64 64
 interface IRequest {
65
-	/**
66
-	 * @since 9.1.0
67
-	 */
68
-	public const USER_AGENT_CLIENT_ANDROID = '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/';
69
-
70
-	/**
71
-	 * @since 13.0.0
72
-	 */
73
-	public const USER_AGENT_TALK_ANDROID = '/^Mozilla\/5\.0 \(Android\) Nextcloud\-Talk v.*$/';
74
-
75
-	/**
76
-	 * @since 9.1.0
77
-	 */
78
-	public const USER_AGENT_CLIENT_DESKTOP = '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/';
79
-
80
-	/**
81
-	 * @since 26.0.0
82
-	 */
83
-	public const USER_AGENT_TALK_DESKTOP = '/^Mozilla\/5\.0 \((?!Android|iOS)[A-Za-z ]+\) Nextcloud\-Talk v.*$/';
84
-
85
-	/**
86
-	 * @since 9.1.0
87
-	 */
88
-	public const USER_AGENT_CLIENT_IOS = '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/';
89
-
90
-	/**
91
-	 * @since 13.0.0
92
-	 */
93
-	public const USER_AGENT_TALK_IOS = '/^Mozilla\/5\.0 \(iOS\) Nextcloud\-Talk v.*$/';
94
-
95
-	/**
96
-	 * @since 13.0.1
97
-	 */
98
-	public const USER_AGENT_OUTLOOK_ADDON = '/^Mozilla\/5\.0 \([A-Za-z ]+\) Nextcloud\-Outlook v.*$/';
99
-
100
-	/**
101
-	 * @since 13.0.1
102
-	 */
103
-	public const USER_AGENT_THUNDERBIRD_ADDON = '/^Mozilla\/5\.0 \([A-Za-z ]+\) Nextcloud\-Thunderbird v.*$/';
104
-
105
-	/**
106
-	 * @since 26.0.0
107
-	 */
108
-	public const JSON_CONTENT_TYPE_REGEX = '/^application\/(?:[a-z0-9.-]+\+)?json\b/';
109
-
110
-	/**
111
-	 * @param string $name
112
-	 *
113
-	 * @psalm-taint-source input
114
-	 *
115
-	 * @return string
116
-	 * @since 6.0.0
117
-	 */
118
-	public function getHeader(string $name): string;
119
-
120
-	/**
121
-	 * Lets you access post and get parameters by the index
122
-	 * In case of json requests the encoded json body is accessed
123
-	 *
124
-	 * @psalm-taint-source input
125
-	 *
126
-	 * @param string $key the key which you want to access in the URL Parameter
127
-	 *                     placeholder, $_POST or $_GET array.
128
-	 *                     The priority how they're returned is the following:
129
-	 *                     1. URL parameters
130
-	 *                     2. POST parameters
131
-	 *                     3. GET parameters
132
-	 * @param mixed $default If the key is not found, this value will be returned
133
-	 * @return mixed the content of the array
134
-	 * @since 6.0.0
135
-	 */
136
-	public function getParam(string $key, $default = null);
137
-
138
-
139
-	/**
140
-	 * Returns all params that were received, be it from the request
141
-	 *
142
-	 * (as GET or POST) or through the URL by the route
143
-	 *
144
-	 * @psalm-taint-source input
145
-	 *
146
-	 * @return array the array with all parameters
147
-	 * @since 6.0.0
148
-	 */
149
-	public function getParams(): array;
150
-
151
-	/**
152
-	 * Returns the method of the request
153
-	 *
154
-	 * @return string the method of the request (POST, GET, etc)
155
-	 * @since 6.0.0
156
-	 */
157
-	public function getMethod(): string;
158
-
159
-	/**
160
-	 * Shortcut for accessing an uploaded file through the $_FILES array
161
-	 *
162
-	 * @param string $key the key that will be taken from the $_FILES array
163
-	 * @return array the file in the $_FILES element
164
-	 * @since 6.0.0
165
-	 */
166
-	public function getUploadedFile(string $key);
167
-
168
-
169
-	/**
170
-	 * Shortcut for getting env variables
171
-	 *
172
-	 * @param string $key the key that will be taken from the $_ENV array
173
-	 * @return array the value in the $_ENV element
174
-	 * @since 6.0.0
175
-	 */
176
-	public function getEnv(string $key);
177
-
178
-
179
-	/**
180
-	 * Shortcut for getting cookie variables
181
-	 *
182
-	 * @psalm-taint-source input
183
-	 *
184
-	 * @param string $key the key that will be taken from the $_COOKIE array
185
-	 * @return string|null the value in the $_COOKIE element
186
-	 * @since 6.0.0
187
-	 */
188
-	public function getCookie(string $key);
189
-
190
-
191
-	/**
192
-	 * Checks if the CSRF check was correct
193
-	 *
194
-	 * @return bool true if CSRF check passed
195
-	 * @since 6.0.0
196
-	 */
197
-	public function passesCSRFCheck(): bool;
198
-
199
-	/**
200
-	 * Checks if the strict cookie has been sent with the request if the request
201
-	 * is including any cookies.
202
-	 *
203
-	 * @return bool
204
-	 * @since 9.0.0
205
-	 */
206
-	public function passesStrictCookieCheck(): bool;
207
-
208
-	/**
209
-	 * Checks if the lax cookie has been sent with the request if the request
210
-	 * is including any cookies.
211
-	 *
212
-	 * @return bool
213
-	 * @since 9.0.0
214
-	 */
215
-	public function passesLaxCookieCheck(): bool;
216
-
217
-	/**
218
-	 * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging
219
-	 * If `mod_unique_id` is installed this value will be taken.
220
-	 *
221
-	 * @return string
222
-	 * @since 8.1.0
223
-	 */
224
-	public function getId(): string;
225
-
226
-	/**
227
-	 * Returns the remote address, if the connection came from a trusted proxy
228
-	 * and `forwarded_for_headers` has been configured then the IP address
229
-	 * specified in this header will be returned instead.
230
-	 * Do always use this instead of $_SERVER['REMOTE_ADDR']
231
-	 *
232
-	 * @return string IP address
233
-	 * @since 8.1.0
234
-	 */
235
-	public function getRemoteAddress(): string;
236
-
237
-	/**
238
-	 * Returns the server protocol. It respects reverse proxy servers and load
239
-	 * balancers.
240
-	 *
241
-	 * @return string Server protocol (http or https)
242
-	 * @since 8.1.0
243
-	 */
244
-	public function getServerProtocol(): string;
245
-
246
-	/**
247
-	 * Returns the used HTTP protocol.
248
-	 *
249
-	 * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0.
250
-	 * @since 8.2.0
251
-	 */
252
-	public function getHttpProtocol(): string;
253
-
254
-	/**
255
-	 * Returns the request uri, even if the website uses one or more
256
-	 * reverse proxies
257
-	 *
258
-	 * @psalm-taint-source input
259
-	 *
260
-	 * @return string
261
-	 * @since 8.1.0
262
-	 */
263
-	public function getRequestUri(): string;
264
-
265
-	/**
266
-	 * Get raw PathInfo from request (not urldecoded)
267
-	 *
268
-	 * @psalm-taint-source input
269
-	 *
270
-	 * @throws \Exception
271
-	 * @return string Path info
272
-	 * @since 8.1.0
273
-	 */
274
-	public function getRawPathInfo(): string;
275
-
276
-	/**
277
-	 * Get PathInfo from request
278
-	 *
279
-	 * @psalm-taint-source input
280
-	 *
281
-	 * @throws \Exception
282
-	 * @return string|false Path info or false when not found
283
-	 * @since 8.1.0
284
-	 */
285
-	public function getPathInfo();
286
-
287
-	/**
288
-	 * Returns the script name, even if the website uses one or more
289
-	 * reverse proxies
290
-	 *
291
-	 * @return string the script name
292
-	 * @since 8.1.0
293
-	 */
294
-	public function getScriptName(): string;
295
-
296
-	/**
297
-	 * Checks whether the user agent matches a given regex
298
-	 *
299
-	 * @param array $agent array of agent names
300
-	 * @return bool true if at least one of the given agent matches, false otherwise
301
-	 * @since 8.1.0
302
-	 */
303
-	public function isUserAgent(array $agent): bool;
304
-
305
-	/**
306
-	 * Returns the unverified server host from the headers without checking
307
-	 * whether it is a trusted domain
308
-	 *
309
-	 * @psalm-taint-source input
310
-	 *
311
-	 * @return string Server host
312
-	 * @since 8.1.0
313
-	 */
314
-	public function getInsecureServerHost(): string;
315
-
316
-	/**
317
-	 * Returns the server host from the headers, or the first configured
318
-	 * trusted domain if the host isn't in the trusted list
319
-	 *
320
-	 * @return string Server host
321
-	 * @since 8.1.0
322
-	 */
323
-	public function getServerHost(): string;
65
+    /**
66
+     * @since 9.1.0
67
+     */
68
+    public const USER_AGENT_CLIENT_ANDROID = '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/';
69
+
70
+    /**
71
+     * @since 13.0.0
72
+     */
73
+    public const USER_AGENT_TALK_ANDROID = '/^Mozilla\/5\.0 \(Android\) Nextcloud\-Talk v.*$/';
74
+
75
+    /**
76
+     * @since 9.1.0
77
+     */
78
+    public const USER_AGENT_CLIENT_DESKTOP = '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/';
79
+
80
+    /**
81
+     * @since 26.0.0
82
+     */
83
+    public const USER_AGENT_TALK_DESKTOP = '/^Mozilla\/5\.0 \((?!Android|iOS)[A-Za-z ]+\) Nextcloud\-Talk v.*$/';
84
+
85
+    /**
86
+     * @since 9.1.0
87
+     */
88
+    public const USER_AGENT_CLIENT_IOS = '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/';
89
+
90
+    /**
91
+     * @since 13.0.0
92
+     */
93
+    public const USER_AGENT_TALK_IOS = '/^Mozilla\/5\.0 \(iOS\) Nextcloud\-Talk v.*$/';
94
+
95
+    /**
96
+     * @since 13.0.1
97
+     */
98
+    public const USER_AGENT_OUTLOOK_ADDON = '/^Mozilla\/5\.0 \([A-Za-z ]+\) Nextcloud\-Outlook v.*$/';
99
+
100
+    /**
101
+     * @since 13.0.1
102
+     */
103
+    public const USER_AGENT_THUNDERBIRD_ADDON = '/^Mozilla\/5\.0 \([A-Za-z ]+\) Nextcloud\-Thunderbird v.*$/';
104
+
105
+    /**
106
+     * @since 26.0.0
107
+     */
108
+    public const JSON_CONTENT_TYPE_REGEX = '/^application\/(?:[a-z0-9.-]+\+)?json\b/';
109
+
110
+    /**
111
+     * @param string $name
112
+     *
113
+     * @psalm-taint-source input
114
+     *
115
+     * @return string
116
+     * @since 6.0.0
117
+     */
118
+    public function getHeader(string $name): string;
119
+
120
+    /**
121
+     * Lets you access post and get parameters by the index
122
+     * In case of json requests the encoded json body is accessed
123
+     *
124
+     * @psalm-taint-source input
125
+     *
126
+     * @param string $key the key which you want to access in the URL Parameter
127
+     *                     placeholder, $_POST or $_GET array.
128
+     *                     The priority how they're returned is the following:
129
+     *                     1. URL parameters
130
+     *                     2. POST parameters
131
+     *                     3. GET parameters
132
+     * @param mixed $default If the key is not found, this value will be returned
133
+     * @return mixed the content of the array
134
+     * @since 6.0.0
135
+     */
136
+    public function getParam(string $key, $default = null);
137
+
138
+
139
+    /**
140
+     * Returns all params that were received, be it from the request
141
+     *
142
+     * (as GET or POST) or through the URL by the route
143
+     *
144
+     * @psalm-taint-source input
145
+     *
146
+     * @return array the array with all parameters
147
+     * @since 6.0.0
148
+     */
149
+    public function getParams(): array;
150
+
151
+    /**
152
+     * Returns the method of the request
153
+     *
154
+     * @return string the method of the request (POST, GET, etc)
155
+     * @since 6.0.0
156
+     */
157
+    public function getMethod(): string;
158
+
159
+    /**
160
+     * Shortcut for accessing an uploaded file through the $_FILES array
161
+     *
162
+     * @param string $key the key that will be taken from the $_FILES array
163
+     * @return array the file in the $_FILES element
164
+     * @since 6.0.0
165
+     */
166
+    public function getUploadedFile(string $key);
167
+
168
+
169
+    /**
170
+     * Shortcut for getting env variables
171
+     *
172
+     * @param string $key the key that will be taken from the $_ENV array
173
+     * @return array the value in the $_ENV element
174
+     * @since 6.0.0
175
+     */
176
+    public function getEnv(string $key);
177
+
178
+
179
+    /**
180
+     * Shortcut for getting cookie variables
181
+     *
182
+     * @psalm-taint-source input
183
+     *
184
+     * @param string $key the key that will be taken from the $_COOKIE array
185
+     * @return string|null the value in the $_COOKIE element
186
+     * @since 6.0.0
187
+     */
188
+    public function getCookie(string $key);
189
+
190
+
191
+    /**
192
+     * Checks if the CSRF check was correct
193
+     *
194
+     * @return bool true if CSRF check passed
195
+     * @since 6.0.0
196
+     */
197
+    public function passesCSRFCheck(): bool;
198
+
199
+    /**
200
+     * Checks if the strict cookie has been sent with the request if the request
201
+     * is including any cookies.
202
+     *
203
+     * @return bool
204
+     * @since 9.0.0
205
+     */
206
+    public function passesStrictCookieCheck(): bool;
207
+
208
+    /**
209
+     * Checks if the lax cookie has been sent with the request if the request
210
+     * is including any cookies.
211
+     *
212
+     * @return bool
213
+     * @since 9.0.0
214
+     */
215
+    public function passesLaxCookieCheck(): bool;
216
+
217
+    /**
218
+     * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging
219
+     * If `mod_unique_id` is installed this value will be taken.
220
+     *
221
+     * @return string
222
+     * @since 8.1.0
223
+     */
224
+    public function getId(): string;
225
+
226
+    /**
227
+     * Returns the remote address, if the connection came from a trusted proxy
228
+     * and `forwarded_for_headers` has been configured then the IP address
229
+     * specified in this header will be returned instead.
230
+     * Do always use this instead of $_SERVER['REMOTE_ADDR']
231
+     *
232
+     * @return string IP address
233
+     * @since 8.1.0
234
+     */
235
+    public function getRemoteAddress(): string;
236
+
237
+    /**
238
+     * Returns the server protocol. It respects reverse proxy servers and load
239
+     * balancers.
240
+     *
241
+     * @return string Server protocol (http or https)
242
+     * @since 8.1.0
243
+     */
244
+    public function getServerProtocol(): string;
245
+
246
+    /**
247
+     * Returns the used HTTP protocol.
248
+     *
249
+     * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0.
250
+     * @since 8.2.0
251
+     */
252
+    public function getHttpProtocol(): string;
253
+
254
+    /**
255
+     * Returns the request uri, even if the website uses one or more
256
+     * reverse proxies
257
+     *
258
+     * @psalm-taint-source input
259
+     *
260
+     * @return string
261
+     * @since 8.1.0
262
+     */
263
+    public function getRequestUri(): string;
264
+
265
+    /**
266
+     * Get raw PathInfo from request (not urldecoded)
267
+     *
268
+     * @psalm-taint-source input
269
+     *
270
+     * @throws \Exception
271
+     * @return string Path info
272
+     * @since 8.1.0
273
+     */
274
+    public function getRawPathInfo(): string;
275
+
276
+    /**
277
+     * Get PathInfo from request
278
+     *
279
+     * @psalm-taint-source input
280
+     *
281
+     * @throws \Exception
282
+     * @return string|false Path info or false when not found
283
+     * @since 8.1.0
284
+     */
285
+    public function getPathInfo();
286
+
287
+    /**
288
+     * Returns the script name, even if the website uses one or more
289
+     * reverse proxies
290
+     *
291
+     * @return string the script name
292
+     * @since 8.1.0
293
+     */
294
+    public function getScriptName(): string;
295
+
296
+    /**
297
+     * Checks whether the user agent matches a given regex
298
+     *
299
+     * @param array $agent array of agent names
300
+     * @return bool true if at least one of the given agent matches, false otherwise
301
+     * @since 8.1.0
302
+     */
303
+    public function isUserAgent(array $agent): bool;
304
+
305
+    /**
306
+     * Returns the unverified server host from the headers without checking
307
+     * whether it is a trusted domain
308
+     *
309
+     * @psalm-taint-source input
310
+     *
311
+     * @return string Server host
312
+     * @since 8.1.0
313
+     */
314
+    public function getInsecureServerHost(): string;
315
+
316
+    /**
317
+     * Returns the server host from the headers, or the first configured
318
+     * trusted domain if the host isn't in the trusted list
319
+     *
320
+     * @return string Server host
321
+     * @since 8.1.0
322
+     */
323
+    public function getServerHost(): string;
324 324
 }
Please login to merge, or discard this patch.