Completed
Branch master (aa63dc)
by
unknown
06:23 queued 04:21
created
core/services/request/Request.php 1 patch
Indentation   +491 added lines, -491 removed lines patch added patch discarded remove patch
@@ -17,495 +17,495 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_COOKIE parameters
22
-     *
23
-     * @var array
24
-     */
25
-    protected $cookies;
26
-
27
-    /**
28
-     * $_FILES parameters
29
-     *
30
-     * @var array
31
-     */
32
-    protected $files;
33
-
34
-    /**
35
-     * true if current user appears to be some kind of bot
36
-     *
37
-     * @var bool
38
-     */
39
-    protected $is_bot;
40
-
41
-    /**
42
-     * @var RequestParams
43
-     */
44
-    protected $request_params;
45
-
46
-    /**
47
-     * @var RequestTypeContextCheckerInterface
48
-     */
49
-    protected $request_type;
50
-
51
-    /**
52
-     * @var ServerParams
53
-     */
54
-    protected $server_params;
55
-
56
-
57
-    public function __construct(
58
-        RequestParams $request_params,
59
-        ServerParams $server_params,
60
-        array $cookies = [],
61
-        array $files = []
62
-    ) {
63
-        $this->cookies = ! empty($cookies)
64
-            ? $cookies
65
-            : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
-        $this->files          = ! empty($files) ? $files : $_FILES;
67
-        $this->request_params = $request_params;
68
-        $this->server_params  = $server_params;
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestTypeContextCheckerInterface $type
74
-     */
75
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
-    {
77
-        $this->request_type = $type;
78
-    }
79
-
80
-
81
-    /**
82
-     * @return array
83
-     */
84
-    public function getParams()
85
-    {
86
-        return $this->request_params->getParams();
87
-    }
88
-
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    public function postParams()
94
-    {
95
-        return $this->request_params->postParams();
96
-    }
97
-
98
-
99
-    /**
100
-     * @return array
101
-     */
102
-    public function cookieParams()
103
-    {
104
-        return $this->cookies;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return array
110
-     */
111
-    public function serverParams()
112
-    {
113
-        return $this->server_params->getAllServerParams();
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $key
119
-     * @param mixed|null $default
120
-     * @return array|int|float|string
121
-     */
122
-    public function getServerParam($key, $default = null)
123
-    {
124
-        return $this->server_params->getServerParam($key, $default);
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                 $key
130
-     * @param array|int|float|string $value
131
-     * @return void
132
-     */
133
-    public function setServerParam($key, $value)
134
-    {
135
-        $this->server_params->setServerParam($key, $value);
136
-    }
137
-
138
-
139
-    /**
140
-     * @param string $key
141
-     * @return bool
142
-     */
143
-    public function serverParamIsSet($key)
144
-    {
145
-        return $this->server_params->serverParamIsSet($key);
146
-    }
147
-
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function filesParams()
153
-    {
154
-        return $this->files;
155
-    }
156
-
157
-
158
-    /**
159
-     * returns sanitized contents of $_REQUEST
160
-     *
161
-     * @return array
162
-     */
163
-    public function requestParams()
164
-    {
165
-        return $this->request_params->requestParams();
166
-    }
167
-
168
-
169
-    /**
170
-     * @param string     $key
171
-     * @param mixed|null $value
172
-     * @param bool       $override_ee
173
-     * @return void
174
-     */
175
-    public function setRequestParam($key, $value, $override_ee = false)
176
-    {
177
-        $this->request_params->setRequestParam($key, $value, $override_ee);
178
-    }
179
-
180
-
181
-    /**
182
-     * merges the incoming array of parameters into the existing request parameters
183
-     *
184
-     * @param array $request_params
185
-     * @return void
186
-     * @since   4.10.24.p
187
-     */
188
-    public function mergeRequestParams(array $request_params)
189
-    {
190
-        $this->request_params->mergeRequestParams($request_params);
191
-    }
192
-
193
-
194
-    /**
195
-     * returns sanitized value for a request param if the given key exists
196
-     *
197
-     * @param string     $key
198
-     * @param mixed|null $default
199
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
200
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
201
-     * @param string     $delimiter for CSV type strings that should be returned as an array
202
-     * @return array|bool|float|int|string
203
-     */
204
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
205
-    {
206
-        return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
207
-    }
208
-
209
-
210
-    /**
211
-     * check if param exists
212
-     *
213
-     * @param string $key
214
-     * @return bool
215
-     */
216
-    public function requestParamIsSet($key)
217
-    {
218
-        return $this->request_params->requestParamIsSet($key);
219
-    }
220
-
221
-
222
-    /**
223
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
224
-     * and return the sanitized value for the first match found
225
-     * wildcards can be either of the following:
226
-     *      ? to represent a single character of any type
227
-     *      * to represent one or more characters of any type
228
-     *
229
-     * @param string     $pattern
230
-     * @param mixed|null $default
231
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
232
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
233
-     * @param string     $delimiter for CSV type strings that should be returned as an array
234
-     * @return array|bool|float|int|string
235
-     */
236
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
237
-    {
238
-        return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
239
-    }
240
-
241
-
242
-    /**
243
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
244
-     * wildcards can be either of the following:
245
-     *      ? to represent a single character of any type
246
-     *      * to represent one or more characters of any type
247
-     * returns true if a match is found or false if not
248
-     *
249
-     * @param string $pattern
250
-     * @return bool
251
-     */
252
-    public function matches($pattern)
253
-    {
254
-        return $this->request_params->matches($pattern);
255
-    }
256
-
257
-
258
-    /**
259
-     * remove param
260
-     *
261
-     * @param      $key
262
-     * @param bool $unset_from_global_too
263
-     */
264
-    public function unSetRequestParam($key, $unset_from_global_too = false)
265
-    {
266
-        $this->request_params->unSetRequestParam($key, $unset_from_global_too);
267
-    }
268
-
269
-
270
-    /**
271
-     * remove params
272
-     *
273
-     * @param array $keys
274
-     * @param bool  $unset_from_global_too
275
-     */
276
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
277
-    {
278
-        $this->request_params->unSetRequestParams($keys, $unset_from_global_too);
279
-    }
280
-
281
-
282
-    /**
283
-     * @return string
284
-     */
285
-    public function ipAddress()
286
-    {
287
-        return $this->server_params->ipAddress();
288
-    }
289
-
290
-
291
-    /**
292
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
293
-     *
294
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
295
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
296
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
297
-     * @return string
298
-     */
299
-    public function requestUri($relativeToWpRoot = false)
300
-    {
301
-        return $this->server_params->requestUri();
302
-    }
303
-
304
-
305
-    /**
306
-     * @return string
307
-     */
308
-    public function userAgent()
309
-    {
310
-        return $this->server_params->userAgent();
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $user_agent
316
-     */
317
-    public function setUserAgent($user_agent = '')
318
-    {
319
-        $this->server_params->setUserAgent($user_agent);
320
-    }
321
-
322
-
323
-    /**
324
-     * @return bool
325
-     */
326
-    public function isBot()
327
-    {
328
-        return $this->is_bot;
329
-    }
330
-
331
-
332
-    /**
333
-     * @param bool $is_bot
334
-     */
335
-    public function setIsBot($is_bot)
336
-    {
337
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
338
-    }
339
-
340
-
341
-    /**
342
-     * @return bool
343
-     */
344
-    public function isActivation()
345
-    {
346
-        return $this->request_type->isActivation();
347
-    }
348
-
349
-
350
-    /**
351
-     * @param $is_activation
352
-     * @return bool
353
-     */
354
-    public function setIsActivation($is_activation)
355
-    {
356
-        return $this->request_type->setIsActivation($is_activation);
357
-    }
358
-
359
-
360
-    /**
361
-     * @return bool
362
-     */
363
-    public function isAdmin()
364
-    {
365
-        return $this->request_type->isAdmin();
366
-    }
367
-
368
-
369
-    /**
370
-     * @return bool
371
-     */
372
-    public function isAdminAjax()
373
-    {
374
-        return $this->request_type->isAdminAjax();
375
-    }
376
-
377
-
378
-    /**
379
-     * @return bool
380
-     */
381
-    public function isAjax()
382
-    {
383
-        return $this->request_type->isAjax();
384
-    }
385
-
386
-
387
-    /**
388
-     * @return bool
389
-     */
390
-    public function isEeAjax()
391
-    {
392
-        return $this->request_type->isEeAjax();
393
-    }
394
-
395
-
396
-    /**
397
-     * @return bool
398
-     */
399
-    public function isOtherAjax()
400
-    {
401
-        return $this->request_type->isOtherAjax();
402
-    }
403
-
404
-
405
-    /**
406
-     * @return bool
407
-     */
408
-    public function isApi()
409
-    {
410
-        return $this->request_type->isApi();
411
-    }
412
-
413
-
414
-    /**
415
-     * @return bool
416
-     */
417
-    public function isCli()
418
-    {
419
-        return $this->request_type->isCli();
420
-    }
421
-
422
-
423
-    /**
424
-     * @return bool
425
-     */
426
-    public function isCron()
427
-    {
428
-        return $this->request_type->isCron();
429
-    }
430
-
431
-
432
-    /**
433
-     * @return bool
434
-     */
435
-    public function isFeed()
436
-    {
437
-        return $this->request_type->isFeed();
438
-    }
439
-
440
-
441
-    /**
442
-     * @return bool
443
-     */
444
-    public function isFrontend()
445
-    {
446
-        return $this->request_type->isFrontend();
447
-    }
448
-
449
-
450
-    /**
451
-     * @return bool
452
-     */
453
-    public function isFrontAjax()
454
-    {
455
-        return $this->request_type->isFrontAjax();
456
-    }
457
-
458
-
459
-    /**
460
-     * @return bool
461
-     */
462
-    public function isIframe()
463
-    {
464
-        return $this->request_type->isIframe();
465
-    }
466
-
467
-
468
-    /**
469
-     * @return bool
470
-     */
471
-    public function isWordPressApi()
472
-    {
473
-        return $this->request_type->isWordPressApi();
474
-    }
475
-
476
-
477
-    /**
478
-     * @return bool
479
-     */
480
-    public function isWordPressHeartbeat()
481
-    {
482
-        return $this->request_type->isWordPressHeartbeat();
483
-    }
484
-
485
-
486
-    /**
487
-     * @return bool
488
-     */
489
-    public function isWordPressScrape()
490
-    {
491
-        return $this->request_type->isWordPressScrape();
492
-    }
493
-
494
-
495
-    /**
496
-     * @return string
497
-     */
498
-    public function slug()
499
-    {
500
-        return $this->request_type->slug();
501
-    }
502
-
503
-
504
-    /**
505
-     * @return RequestTypeContextCheckerInterface
506
-     */
507
-    public function getRequestType()
508
-    {
509
-        return $this->request_type;
510
-    }
20
+	/**
21
+	 * $_COOKIE parameters
22
+	 *
23
+	 * @var array
24
+	 */
25
+	protected $cookies;
26
+
27
+	/**
28
+	 * $_FILES parameters
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $files;
33
+
34
+	/**
35
+	 * true if current user appears to be some kind of bot
36
+	 *
37
+	 * @var bool
38
+	 */
39
+	protected $is_bot;
40
+
41
+	/**
42
+	 * @var RequestParams
43
+	 */
44
+	protected $request_params;
45
+
46
+	/**
47
+	 * @var RequestTypeContextCheckerInterface
48
+	 */
49
+	protected $request_type;
50
+
51
+	/**
52
+	 * @var ServerParams
53
+	 */
54
+	protected $server_params;
55
+
56
+
57
+	public function __construct(
58
+		RequestParams $request_params,
59
+		ServerParams $server_params,
60
+		array $cookies = [],
61
+		array $files = []
62
+	) {
63
+		$this->cookies = ! empty($cookies)
64
+			? $cookies
65
+			: filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
+		$this->files          = ! empty($files) ? $files : $_FILES;
67
+		$this->request_params = $request_params;
68
+		$this->server_params  = $server_params;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestTypeContextCheckerInterface $type
74
+	 */
75
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
+	{
77
+		$this->request_type = $type;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return array
83
+	 */
84
+	public function getParams()
85
+	{
86
+		return $this->request_params->getParams();
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	public function postParams()
94
+	{
95
+		return $this->request_params->postParams();
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return array
101
+	 */
102
+	public function cookieParams()
103
+	{
104
+		return $this->cookies;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return array
110
+	 */
111
+	public function serverParams()
112
+	{
113
+		return $this->server_params->getAllServerParams();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $key
119
+	 * @param mixed|null $default
120
+	 * @return array|int|float|string
121
+	 */
122
+	public function getServerParam($key, $default = null)
123
+	{
124
+		return $this->server_params->getServerParam($key, $default);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                 $key
130
+	 * @param array|int|float|string $value
131
+	 * @return void
132
+	 */
133
+	public function setServerParam($key, $value)
134
+	{
135
+		$this->server_params->setServerParam($key, $value);
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param string $key
141
+	 * @return bool
142
+	 */
143
+	public function serverParamIsSet($key)
144
+	{
145
+		return $this->server_params->serverParamIsSet($key);
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function filesParams()
153
+	{
154
+		return $this->files;
155
+	}
156
+
157
+
158
+	/**
159
+	 * returns sanitized contents of $_REQUEST
160
+	 *
161
+	 * @return array
162
+	 */
163
+	public function requestParams()
164
+	{
165
+		return $this->request_params->requestParams();
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param string     $key
171
+	 * @param mixed|null $value
172
+	 * @param bool       $override_ee
173
+	 * @return void
174
+	 */
175
+	public function setRequestParam($key, $value, $override_ee = false)
176
+	{
177
+		$this->request_params->setRequestParam($key, $value, $override_ee);
178
+	}
179
+
180
+
181
+	/**
182
+	 * merges the incoming array of parameters into the existing request parameters
183
+	 *
184
+	 * @param array $request_params
185
+	 * @return void
186
+	 * @since   4.10.24.p
187
+	 */
188
+	public function mergeRequestParams(array $request_params)
189
+	{
190
+		$this->request_params->mergeRequestParams($request_params);
191
+	}
192
+
193
+
194
+	/**
195
+	 * returns sanitized value for a request param if the given key exists
196
+	 *
197
+	 * @param string     $key
198
+	 * @param mixed|null $default
199
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
200
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
201
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
202
+	 * @return array|bool|float|int|string
203
+	 */
204
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
205
+	{
206
+		return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
207
+	}
208
+
209
+
210
+	/**
211
+	 * check if param exists
212
+	 *
213
+	 * @param string $key
214
+	 * @return bool
215
+	 */
216
+	public function requestParamIsSet($key)
217
+	{
218
+		return $this->request_params->requestParamIsSet($key);
219
+	}
220
+
221
+
222
+	/**
223
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
224
+	 * and return the sanitized value for the first match found
225
+	 * wildcards can be either of the following:
226
+	 *      ? to represent a single character of any type
227
+	 *      * to represent one or more characters of any type
228
+	 *
229
+	 * @param string     $pattern
230
+	 * @param mixed|null $default
231
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
232
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
233
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
234
+	 * @return array|bool|float|int|string
235
+	 */
236
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
237
+	{
238
+		return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
239
+	}
240
+
241
+
242
+	/**
243
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
244
+	 * wildcards can be either of the following:
245
+	 *      ? to represent a single character of any type
246
+	 *      * to represent one or more characters of any type
247
+	 * returns true if a match is found or false if not
248
+	 *
249
+	 * @param string $pattern
250
+	 * @return bool
251
+	 */
252
+	public function matches($pattern)
253
+	{
254
+		return $this->request_params->matches($pattern);
255
+	}
256
+
257
+
258
+	/**
259
+	 * remove param
260
+	 *
261
+	 * @param      $key
262
+	 * @param bool $unset_from_global_too
263
+	 */
264
+	public function unSetRequestParam($key, $unset_from_global_too = false)
265
+	{
266
+		$this->request_params->unSetRequestParam($key, $unset_from_global_too);
267
+	}
268
+
269
+
270
+	/**
271
+	 * remove params
272
+	 *
273
+	 * @param array $keys
274
+	 * @param bool  $unset_from_global_too
275
+	 */
276
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
277
+	{
278
+		$this->request_params->unSetRequestParams($keys, $unset_from_global_too);
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return string
284
+	 */
285
+	public function ipAddress()
286
+	{
287
+		return $this->server_params->ipAddress();
288
+	}
289
+
290
+
291
+	/**
292
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
293
+	 *
294
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
295
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
296
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
297
+	 * @return string
298
+	 */
299
+	public function requestUri($relativeToWpRoot = false)
300
+	{
301
+		return $this->server_params->requestUri();
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return string
307
+	 */
308
+	public function userAgent()
309
+	{
310
+		return $this->server_params->userAgent();
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $user_agent
316
+	 */
317
+	public function setUserAgent($user_agent = '')
318
+	{
319
+		$this->server_params->setUserAgent($user_agent);
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return bool
325
+	 */
326
+	public function isBot()
327
+	{
328
+		return $this->is_bot;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @param bool $is_bot
334
+	 */
335
+	public function setIsBot($is_bot)
336
+	{
337
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
338
+	}
339
+
340
+
341
+	/**
342
+	 * @return bool
343
+	 */
344
+	public function isActivation()
345
+	{
346
+		return $this->request_type->isActivation();
347
+	}
348
+
349
+
350
+	/**
351
+	 * @param $is_activation
352
+	 * @return bool
353
+	 */
354
+	public function setIsActivation($is_activation)
355
+	{
356
+		return $this->request_type->setIsActivation($is_activation);
357
+	}
358
+
359
+
360
+	/**
361
+	 * @return bool
362
+	 */
363
+	public function isAdmin()
364
+	{
365
+		return $this->request_type->isAdmin();
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return bool
371
+	 */
372
+	public function isAdminAjax()
373
+	{
374
+		return $this->request_type->isAdminAjax();
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return bool
380
+	 */
381
+	public function isAjax()
382
+	{
383
+		return $this->request_type->isAjax();
384
+	}
385
+
386
+
387
+	/**
388
+	 * @return bool
389
+	 */
390
+	public function isEeAjax()
391
+	{
392
+		return $this->request_type->isEeAjax();
393
+	}
394
+
395
+
396
+	/**
397
+	 * @return bool
398
+	 */
399
+	public function isOtherAjax()
400
+	{
401
+		return $this->request_type->isOtherAjax();
402
+	}
403
+
404
+
405
+	/**
406
+	 * @return bool
407
+	 */
408
+	public function isApi()
409
+	{
410
+		return $this->request_type->isApi();
411
+	}
412
+
413
+
414
+	/**
415
+	 * @return bool
416
+	 */
417
+	public function isCli()
418
+	{
419
+		return $this->request_type->isCli();
420
+	}
421
+
422
+
423
+	/**
424
+	 * @return bool
425
+	 */
426
+	public function isCron()
427
+	{
428
+		return $this->request_type->isCron();
429
+	}
430
+
431
+
432
+	/**
433
+	 * @return bool
434
+	 */
435
+	public function isFeed()
436
+	{
437
+		return $this->request_type->isFeed();
438
+	}
439
+
440
+
441
+	/**
442
+	 * @return bool
443
+	 */
444
+	public function isFrontend()
445
+	{
446
+		return $this->request_type->isFrontend();
447
+	}
448
+
449
+
450
+	/**
451
+	 * @return bool
452
+	 */
453
+	public function isFrontAjax()
454
+	{
455
+		return $this->request_type->isFrontAjax();
456
+	}
457
+
458
+
459
+	/**
460
+	 * @return bool
461
+	 */
462
+	public function isIframe()
463
+	{
464
+		return $this->request_type->isIframe();
465
+	}
466
+
467
+
468
+	/**
469
+	 * @return bool
470
+	 */
471
+	public function isWordPressApi()
472
+	{
473
+		return $this->request_type->isWordPressApi();
474
+	}
475
+
476
+
477
+	/**
478
+	 * @return bool
479
+	 */
480
+	public function isWordPressHeartbeat()
481
+	{
482
+		return $this->request_type->isWordPressHeartbeat();
483
+	}
484
+
485
+
486
+	/**
487
+	 * @return bool
488
+	 */
489
+	public function isWordPressScrape()
490
+	{
491
+		return $this->request_type->isWordPressScrape();
492
+	}
493
+
494
+
495
+	/**
496
+	 * @return string
497
+	 */
498
+	public function slug()
499
+	{
500
+		return $this->request_type->slug();
501
+	}
502
+
503
+
504
+	/**
505
+	 * @return RequestTypeContextCheckerInterface
506
+	 */
507
+	public function getRequestType()
508
+	{
509
+		return $this->request_type;
510
+	}
511 511
 }
Please login to merge, or discard this patch.
core/services/request/RequestParams.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -14,327 +14,327 @@
 block discarded – undo
14 14
 class RequestParams
15 15
 {
16 16
 
17
-    /**
18
-     * $_GET parameters
19
-     *
20
-     * @var array
21
-     */
22
-    protected $get;
23
-
24
-    /**
25
-     * $_POST parameters
26
-     *
27
-     * @var array
28
-     */
29
-    protected $post;
30
-
31
-    /**
32
-     * $_REQUEST parameters
33
-     *
34
-     * @var array
35
-     */
36
-    protected $request;
37
-
38
-    /**
39
-     * @var RequestSanitizer
40
-     */
41
-    protected $sanitizer;
42
-
43
-
44
-    /**
45
-     * RequestParams constructor.
46
-     *
47
-     * @param RequestSanitizer $sanitizer
48
-     * @param array            $get
49
-     * @param array            $post
50
-     */
51
-    public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
-    {
53
-        $this->sanitizer = $sanitizer;
54
-        $this->get       = ! empty($get) ? $get : $_GET;
55
-        $this->post      = ! empty($post) ? $post : $_POST;
56
-        $this->request   = array_merge($this->get, $this->post);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return array
62
-     */
63
-    public function getParams()
64
-    {
65
-        return $this->get;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function postParams()
73
-    {
74
-        return $this->post;
75
-    }
76
-
77
-
78
-    /**
79
-     * returns contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams()
84
-    {
85
-        return $this->request;
86
-    }
87
-
88
-
89
-    /**
90
-     * @param string     $key
91
-     * @param mixed|null $value
92
-     * @param bool       $override_ee
93
-     * @return    void
94
-     */
95
-    public function setRequestParam($key, $value, $override_ee = false)
96
-    {
97
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
98
-        if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
-            $this->request[ $key ] = $value;
100
-        }
101
-    }
102
-
103
-
104
-    /**
105
-     * merges the incoming array of parameters into the existing request parameters
106
-     *
107
-     * @param array $request_params
108
-     * @return void
109
-     * @since   4.10.24.p
110
-     */
111
-    public function mergeRequestParams(array $request_params)
112
-    {
113
-        $this->request = array_merge_recursive($this->request, $request_params);
114
-    }
115
-
116
-
117
-    /**
118
-     * returns   the value for a request param if the given key exists
119
-     *
120
-     * @param string     $key
121
-     * @param mixed|null $default
122
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
-     * @param string     $delimiter for CSV type strings that should be returned as an array
125
-     * @return array|bool|float|int|string
126
-     */
127
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
-    {
129
-        return $this->sanitizer->clean(
130
-            $this->parameterDrillDown($key, $default, 'get'),
131
-            $type,
132
-            $is_array,
133
-            $delimiter
134
-        );
135
-    }
136
-
137
-
138
-    /**
139
-     * check if param exists
140
-     *
141
-     * @param string $key
142
-     * @return bool
143
-     */
144
-    public function requestParamIsSet($key)
145
-    {
146
-        return (bool) $this->parameterDrillDown($key);
147
-    }
148
-
149
-
150
-    /**
151
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
-     * and return the value for the first match found
153
-     * wildcards can be either of the following:
154
-     *      ? to represent a single character of any type
155
-     *      * to represent one or more characters of any type
156
-     *
157
-     * @param string     $pattern
158
-     * @param mixed|null $default
159
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
-     * @param string     $delimiter for CSV type strings that should be returned as an array
162
-     * @return array|bool|float|int|string
163
-     */
164
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
-    {
166
-        return $this->sanitizer->clean(
167
-            $this->parameterDrillDown($pattern, $default, 'match'),
168
-            $type,
169
-            $is_array,
170
-            $delimiter
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
177
-     * wildcards can be either of the following:
178
-     *      ? to represent a single character of any type
179
-     *      * to represent one or more characters of any type
180
-     * returns true if a match is found or false if not
181
-     *
182
-     * @param string $pattern
183
-     * @return bool
184
-     */
185
-    public function matches($pattern)
186
-    {
187
-        return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
-    }
189
-
190
-
191
-    /**
192
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
-     *                                      and used to search through the current request's parameter keys
195
-     * @param array  $request_params        The array of request parameters to search through
196
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
197
-     *                                      Default is null
198
-     * @param string $return                [optional] Controls what kind of value is returned.
199
-     *                                      Options are:
200
-     *                                      'bool' will return true or false if match is found or not
201
-     *                                      'key' will return the first key found that matches the supplied pattern
202
-     *                                      'value' will return the value for the first request parameter
203
-     *                                      whose key matches the supplied pattern
204
-     *                                      Default is 'value'
205
-     * @return boolean|string
206
-     */
207
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
208
-    {
209
-        $return = in_array($return, ['bool', 'key', 'value'], true)
210
-            ? $return
211
-            : 'is_set';
212
-        // replace wildcard chars with regex chars
213
-        $pattern = str_replace(
214
-            ['\*', '\?'],
215
-            ['.*', '.'],
216
-            preg_quote($pattern, '/')
217
-        );
218
-        foreach ($request_params as $key => $request_param) {
219
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
220
-                // return value for request param
221
-                if ($return === 'value') {
222
-                    return $request_param;
223
-                }
224
-                // or actual key or true just to indicate it was found
225
-                return $return === 'key' ? $key : true;
226
-            }
227
-        }
228
-        // match not found so return default value or false
229
-        return $return === 'value' ? $default : false;
230
-    }
231
-
232
-
233
-    /**
234
-     * the supplied key can be a simple string to represent a "top-level" request parameter
235
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
-     * by using square brackets to surround keys for deeper array elements.
237
-     * For example :
238
-     * if the supplied $key was: "first[second][third]"
239
-     * then this will attempt to drill down into the request parameter array to find a value.
240
-     * Given the following request parameters:
241
-     *  array(
242
-     *      'first' => array(
243
-     *          'second' => array(
244
-     *              'third' => 'has a value'
245
-     *          )
246
-     *      )
247
-     *  )
248
-     * would return true if default parameters were set
249
-     *
250
-     * @param string $callback
251
-     * @param        $key
252
-     * @param null   $default
253
-     * @param string $return
254
-     * @param mixed  $request_params
255
-     * @return bool|mixed|null
256
-     */
257
-    private function parameterDrillDown(
258
-        $key,
259
-        $default = null,
260
-        $callback = 'is_set',
261
-        $return = 'value',
262
-        $request_params = []
263
-    ) {
264
-        $callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
-            ? $callback
266
-            : 'is_set';
267
-        $request_params = ! empty($request_params)
268
-            ? $request_params
269
-            : $this->request;
270
-        // does incoming key represent an array like 'first[second][third]'  ?
271
-        if (strpos($key, '[') !== false) {
272
-            // turn it into an actual array
273
-            $key  = str_replace(']', '', $key);
274
-            $keys = explode('[', $key);
275
-            $key  = array_shift($keys);
276
-            if ($callback === 'match') {
277
-                $real_key = $this->match($key, $request_params, $default, 'key');
278
-                $key      = $real_key ?: $key;
279
-            }
280
-            // check if top level key exists
281
-            if (isset($request_params[ $key ])) {
282
-                // build a new key to pass along like: 'second[third]'
283
-                // or just 'second' depending on depth of keys
284
-                $key_string = array_shift($keys);
285
-                if (! empty($keys)) {
286
-                    $key_string .= '[' . implode('][', $keys) . ']';
287
-                }
288
-                return $this->parameterDrillDown(
289
-                    $key_string,
290
-                    $default,
291
-                    $callback,
292
-                    $return,
293
-                    $request_params[ $key ]
294
-                );
295
-            }
296
-        }
297
-        if ($callback === 'is_set') {
298
-            return isset($request_params[ $key ]);
299
-        }
300
-        if ($callback === 'match') {
301
-            return $this->match($key, $request_params, $default, $return);
302
-        }
303
-        return isset($request_params[ $key ])
304
-            ? $request_params[ $key ]
305
-            : $default;
306
-    }
307
-
308
-
309
-    /**
310
-     * remove param
311
-     *
312
-     * @param      $key
313
-     * @param bool $unset_from_global_too
314
-     */
315
-    public function unSetRequestParam($key, $unset_from_global_too = false)
316
-    {
317
-        // because unset may not actually remove var
318
-        $this->get[ $key ]     = null;
319
-        $this->post[ $key ]    = null;
320
-        $this->request[ $key ] = null;
321
-        unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
-        if ($unset_from_global_too) {
323
-            unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * remove params
330
-     *
331
-     * @param array $keys
332
-     * @param bool  $unset_from_global_too
333
-     */
334
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
-    {
336
-        foreach ($keys as $key) {
337
-            $this->unSetRequestParam($key, $unset_from_global_too);
338
-        }
339
-    }
17
+	/**
18
+	 * $_GET parameters
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected $get;
23
+
24
+	/**
25
+	 * $_POST parameters
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $post;
30
+
31
+	/**
32
+	 * $_REQUEST parameters
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $request;
37
+
38
+	/**
39
+	 * @var RequestSanitizer
40
+	 */
41
+	protected $sanitizer;
42
+
43
+
44
+	/**
45
+	 * RequestParams constructor.
46
+	 *
47
+	 * @param RequestSanitizer $sanitizer
48
+	 * @param array            $get
49
+	 * @param array            $post
50
+	 */
51
+	public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
+	{
53
+		$this->sanitizer = $sanitizer;
54
+		$this->get       = ! empty($get) ? $get : $_GET;
55
+		$this->post      = ! empty($post) ? $post : $_POST;
56
+		$this->request   = array_merge($this->get, $this->post);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return array
62
+	 */
63
+	public function getParams()
64
+	{
65
+		return $this->get;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function postParams()
73
+	{
74
+		return $this->post;
75
+	}
76
+
77
+
78
+	/**
79
+	 * returns contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams()
84
+	{
85
+		return $this->request;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param string     $key
91
+	 * @param mixed|null $value
92
+	 * @param bool       $override_ee
93
+	 * @return    void
94
+	 */
95
+	public function setRequestParam($key, $value, $override_ee = false)
96
+	{
97
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
98
+		if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
+			$this->request[ $key ] = $value;
100
+		}
101
+	}
102
+
103
+
104
+	/**
105
+	 * merges the incoming array of parameters into the existing request parameters
106
+	 *
107
+	 * @param array $request_params
108
+	 * @return void
109
+	 * @since   4.10.24.p
110
+	 */
111
+	public function mergeRequestParams(array $request_params)
112
+	{
113
+		$this->request = array_merge_recursive($this->request, $request_params);
114
+	}
115
+
116
+
117
+	/**
118
+	 * returns   the value for a request param if the given key exists
119
+	 *
120
+	 * @param string     $key
121
+	 * @param mixed|null $default
122
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
125
+	 * @return array|bool|float|int|string
126
+	 */
127
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
+	{
129
+		return $this->sanitizer->clean(
130
+			$this->parameterDrillDown($key, $default, 'get'),
131
+			$type,
132
+			$is_array,
133
+			$delimiter
134
+		);
135
+	}
136
+
137
+
138
+	/**
139
+	 * check if param exists
140
+	 *
141
+	 * @param string $key
142
+	 * @return bool
143
+	 */
144
+	public function requestParamIsSet($key)
145
+	{
146
+		return (bool) $this->parameterDrillDown($key);
147
+	}
148
+
149
+
150
+	/**
151
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
+	 * and return the value for the first match found
153
+	 * wildcards can be either of the following:
154
+	 *      ? to represent a single character of any type
155
+	 *      * to represent one or more characters of any type
156
+	 *
157
+	 * @param string     $pattern
158
+	 * @param mixed|null $default
159
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
162
+	 * @return array|bool|float|int|string
163
+	 */
164
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
+	{
166
+		return $this->sanitizer->clean(
167
+			$this->parameterDrillDown($pattern, $default, 'match'),
168
+			$type,
169
+			$is_array,
170
+			$delimiter
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
177
+	 * wildcards can be either of the following:
178
+	 *      ? to represent a single character of any type
179
+	 *      * to represent one or more characters of any type
180
+	 * returns true if a match is found or false if not
181
+	 *
182
+	 * @param string $pattern
183
+	 * @return bool
184
+	 */
185
+	public function matches($pattern)
186
+	{
187
+		return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
+	}
189
+
190
+
191
+	/**
192
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
+	 *                                      and used to search through the current request's parameter keys
195
+	 * @param array  $request_params        The array of request parameters to search through
196
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
197
+	 *                                      Default is null
198
+	 * @param string $return                [optional] Controls what kind of value is returned.
199
+	 *                                      Options are:
200
+	 *                                      'bool' will return true or false if match is found or not
201
+	 *                                      'key' will return the first key found that matches the supplied pattern
202
+	 *                                      'value' will return the value for the first request parameter
203
+	 *                                      whose key matches the supplied pattern
204
+	 *                                      Default is 'value'
205
+	 * @return boolean|string
206
+	 */
207
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
208
+	{
209
+		$return = in_array($return, ['bool', 'key', 'value'], true)
210
+			? $return
211
+			: 'is_set';
212
+		// replace wildcard chars with regex chars
213
+		$pattern = str_replace(
214
+			['\*', '\?'],
215
+			['.*', '.'],
216
+			preg_quote($pattern, '/')
217
+		);
218
+		foreach ($request_params as $key => $request_param) {
219
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
220
+				// return value for request param
221
+				if ($return === 'value') {
222
+					return $request_param;
223
+				}
224
+				// or actual key or true just to indicate it was found
225
+				return $return === 'key' ? $key : true;
226
+			}
227
+		}
228
+		// match not found so return default value or false
229
+		return $return === 'value' ? $default : false;
230
+	}
231
+
232
+
233
+	/**
234
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
235
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
+	 * by using square brackets to surround keys for deeper array elements.
237
+	 * For example :
238
+	 * if the supplied $key was: "first[second][third]"
239
+	 * then this will attempt to drill down into the request parameter array to find a value.
240
+	 * Given the following request parameters:
241
+	 *  array(
242
+	 *      'first' => array(
243
+	 *          'second' => array(
244
+	 *              'third' => 'has a value'
245
+	 *          )
246
+	 *      )
247
+	 *  )
248
+	 * would return true if default parameters were set
249
+	 *
250
+	 * @param string $callback
251
+	 * @param        $key
252
+	 * @param null   $default
253
+	 * @param string $return
254
+	 * @param mixed  $request_params
255
+	 * @return bool|mixed|null
256
+	 */
257
+	private function parameterDrillDown(
258
+		$key,
259
+		$default = null,
260
+		$callback = 'is_set',
261
+		$return = 'value',
262
+		$request_params = []
263
+	) {
264
+		$callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
+			? $callback
266
+			: 'is_set';
267
+		$request_params = ! empty($request_params)
268
+			? $request_params
269
+			: $this->request;
270
+		// does incoming key represent an array like 'first[second][third]'  ?
271
+		if (strpos($key, '[') !== false) {
272
+			// turn it into an actual array
273
+			$key  = str_replace(']', '', $key);
274
+			$keys = explode('[', $key);
275
+			$key  = array_shift($keys);
276
+			if ($callback === 'match') {
277
+				$real_key = $this->match($key, $request_params, $default, 'key');
278
+				$key      = $real_key ?: $key;
279
+			}
280
+			// check if top level key exists
281
+			if (isset($request_params[ $key ])) {
282
+				// build a new key to pass along like: 'second[third]'
283
+				// or just 'second' depending on depth of keys
284
+				$key_string = array_shift($keys);
285
+				if (! empty($keys)) {
286
+					$key_string .= '[' . implode('][', $keys) . ']';
287
+				}
288
+				return $this->parameterDrillDown(
289
+					$key_string,
290
+					$default,
291
+					$callback,
292
+					$return,
293
+					$request_params[ $key ]
294
+				);
295
+			}
296
+		}
297
+		if ($callback === 'is_set') {
298
+			return isset($request_params[ $key ]);
299
+		}
300
+		if ($callback === 'match') {
301
+			return $this->match($key, $request_params, $default, $return);
302
+		}
303
+		return isset($request_params[ $key ])
304
+			? $request_params[ $key ]
305
+			: $default;
306
+	}
307
+
308
+
309
+	/**
310
+	 * remove param
311
+	 *
312
+	 * @param      $key
313
+	 * @param bool $unset_from_global_too
314
+	 */
315
+	public function unSetRequestParam($key, $unset_from_global_too = false)
316
+	{
317
+		// because unset may not actually remove var
318
+		$this->get[ $key ]     = null;
319
+		$this->post[ $key ]    = null;
320
+		$this->request[ $key ] = null;
321
+		unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
+		if ($unset_from_global_too) {
323
+			unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * remove params
330
+	 *
331
+	 * @param array $keys
332
+	 * @param bool  $unset_from_global_too
333
+	 */
334
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
+	{
336
+		foreach ($keys as $key) {
337
+			$this->unSetRequestParam($key, $unset_from_global_too);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -16,195 +16,195 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23 23
 
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    public function getParams();
29
-
30
-
31
-    /**
32
-     * @return array
33
-     */
34
-    public function postParams();
35
-
36
-
37
-    /**
38
-     * @return array
39
-     */
40
-    public function cookieParams();
41
-
42
-
43
-    /**
44
-     * @return array
45
-     */
46
-    public function serverParams();
47
-
48
-
49
-    /**
50
-     * @param string $key
51
-     * @param mixed|null $default
52
-     * @return array|int|float|string
53
-     */
54
-    public function getServerParam($key, $default = null);
55
-
56
-
57
-    /**
58
-     * @param string                 $key
59
-     * @param array|int|float|string $value
60
-     * @return void
61
-     */
62
-    public function setServerParam($key, $value);
63
-
64
-
65
-    /**
66
-     * @param string $key
67
-     * @return bool
68
-     */
69
-    public function serverParamIsSet($key);
70
-
71
-
72
-    /**
73
-     * @return array
74
-     */
75
-    public function filesParams();
76
-
77
-
78
-    /**
79
-     * returns sanitized contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams();
84
-
85
-
86
-    /**
87
-     * @param string $key
88
-     * @param string $value
89
-     * @param bool   $override_ee
90
-     * @return void
91
-     */
92
-    public function setRequestParam($key, $value, $override_ee = false);
93
-
94
-
95
-    /**
96
-     * returns   the value for a request param if the given key exists
97
-     *
98
-     * @param string     $key
99
-     * @param mixed|null $default
100
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
102
-     * @param string     $delimiter for CSV type strings that should be returned as an array
103
-     * @return array|bool|float|int|string
104
-     */
105
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '');
106
-
107
-
108
-    /**
109
-     * check if param exists
110
-     *
111
-     * @param string $key
112
-     * @return bool
113
-     */
114
-    public function requestParamIsSet($key);
115
-
116
-
117
-    /**
118
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
119
-     * and return the value for the first match found
120
-     * wildcards can be either of the following:
121
-     *      ? to represent a single character of any type
122
-     *      * to represent one or more characters of any type
123
-     *
124
-     * @param string     $pattern
125
-     * @param mixed|null $default
126
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
127
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
128
-     * @param string     $delimiter for CSV type strings that should be returned as an array
129
-     * @return array|bool|float|int|string
130
-     */
131
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '');
132
-
133
-
134
-    /**
135
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
136
-     * wildcards can be either of the following:
137
-     *      ? to represent a single character of any type
138
-     *      * to represent one or more characters of any type
139
-     * returns true if a match is found or false if not
140
-     *
141
-     * @param string $pattern
142
-     * @return false|int
143
-     */
144
-    public function matches($pattern);
145
-
146
-
147
-    /**
148
-     * remove param
149
-     *
150
-     * @param string $key
151
-     * @param bool   $unset_from_global_too
152
-     */
153
-    public function unSetRequestParam($key, $unset_from_global_too = false);
154
-
155
-
156
-    /**
157
-     * remove params
158
-     *
159
-     * @param array $keys
160
-     * @param bool  $unset_from_global_too
161
-     */
162
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false);
163
-
164
-
165
-    /**
166
-     * @return string
167
-     */
168
-    public function ipAddress();
169
-
170
-
171
-    /**
172
-     * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
173
-     * @return string
174
-     */
175
-    public function requestUri($relativeToWpRoot = false);
176
-
177
-
178
-    /**
179
-     * @return string
180
-     */
181
-    public function userAgent();
182
-
183
-
184
-    /**
185
-     * @param string $user_agent
186
-     */
187
-    public function setUserAgent($user_agent = '');
188
-
189
-
190
-    /**
191
-     * @return bool
192
-     */
193
-    public function isBot();
194
-
195
-
196
-    /**
197
-     * @param bool $is_bot
198
-     */
199
-    public function setIsBot($is_bot);
200
-
201
-
202
-    /**
203
-     * merges the incoming array of parameters into the existing request parameters
204
-     *
205
-     * @param array $request_params
206
-     * @return mixed
207
-     * @since   4.10.24.p
208
-     */
209
-    public function mergeRequestParams(array $request_params);
25
+	/**
26
+	 * @return array
27
+	 */
28
+	public function getParams();
29
+
30
+
31
+	/**
32
+	 * @return array
33
+	 */
34
+	public function postParams();
35
+
36
+
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function cookieParams();
41
+
42
+
43
+	/**
44
+	 * @return array
45
+	 */
46
+	public function serverParams();
47
+
48
+
49
+	/**
50
+	 * @param string $key
51
+	 * @param mixed|null $default
52
+	 * @return array|int|float|string
53
+	 */
54
+	public function getServerParam($key, $default = null);
55
+
56
+
57
+	/**
58
+	 * @param string                 $key
59
+	 * @param array|int|float|string $value
60
+	 * @return void
61
+	 */
62
+	public function setServerParam($key, $value);
63
+
64
+
65
+	/**
66
+	 * @param string $key
67
+	 * @return bool
68
+	 */
69
+	public function serverParamIsSet($key);
70
+
71
+
72
+	/**
73
+	 * @return array
74
+	 */
75
+	public function filesParams();
76
+
77
+
78
+	/**
79
+	 * returns sanitized contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams();
84
+
85
+
86
+	/**
87
+	 * @param string $key
88
+	 * @param string $value
89
+	 * @param bool   $override_ee
90
+	 * @return void
91
+	 */
92
+	public function setRequestParam($key, $value, $override_ee = false);
93
+
94
+
95
+	/**
96
+	 * returns   the value for a request param if the given key exists
97
+	 *
98
+	 * @param string     $key
99
+	 * @param mixed|null $default
100
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
102
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
103
+	 * @return array|bool|float|int|string
104
+	 */
105
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '');
106
+
107
+
108
+	/**
109
+	 * check if param exists
110
+	 *
111
+	 * @param string $key
112
+	 * @return bool
113
+	 */
114
+	public function requestParamIsSet($key);
115
+
116
+
117
+	/**
118
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
119
+	 * and return the value for the first match found
120
+	 * wildcards can be either of the following:
121
+	 *      ? to represent a single character of any type
122
+	 *      * to represent one or more characters of any type
123
+	 *
124
+	 * @param string     $pattern
125
+	 * @param mixed|null $default
126
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
127
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
128
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
129
+	 * @return array|bool|float|int|string
130
+	 */
131
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '');
132
+
133
+
134
+	/**
135
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
136
+	 * wildcards can be either of the following:
137
+	 *      ? to represent a single character of any type
138
+	 *      * to represent one or more characters of any type
139
+	 * returns true if a match is found or false if not
140
+	 *
141
+	 * @param string $pattern
142
+	 * @return false|int
143
+	 */
144
+	public function matches($pattern);
145
+
146
+
147
+	/**
148
+	 * remove param
149
+	 *
150
+	 * @param string $key
151
+	 * @param bool   $unset_from_global_too
152
+	 */
153
+	public function unSetRequestParam($key, $unset_from_global_too = false);
154
+
155
+
156
+	/**
157
+	 * remove params
158
+	 *
159
+	 * @param array $keys
160
+	 * @param bool  $unset_from_global_too
161
+	 */
162
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false);
163
+
164
+
165
+	/**
166
+	 * @return string
167
+	 */
168
+	public function ipAddress();
169
+
170
+
171
+	/**
172
+	 * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
173
+	 * @return string
174
+	 */
175
+	public function requestUri($relativeToWpRoot = false);
176
+
177
+
178
+	/**
179
+	 * @return string
180
+	 */
181
+	public function userAgent();
182
+
183
+
184
+	/**
185
+	 * @param string $user_agent
186
+	 */
187
+	public function setUserAgent($user_agent = '');
188
+
189
+
190
+	/**
191
+	 * @return bool
192
+	 */
193
+	public function isBot();
194
+
195
+
196
+	/**
197
+	 * @param bool $is_bot
198
+	 */
199
+	public function setIsBot($is_bot);
200
+
201
+
202
+	/**
203
+	 * merges the incoming array of parameters into the existing request parameters
204
+	 *
205
+	 * @param array $request_params
206
+	 * @return mixed
207
+	 * @since   4.10.24.p
208
+	 */
209
+	public function mergeRequestParams(array $request_params);
210 210
 }
Please login to merge, or discard this patch.