-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathRequest.php
More file actions
2300 lines (2011 loc) · 58.4 KB
/
Copy pathRequest.php
File metadata and controls
2300 lines (2011 loc) · 58.4 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace think;
use ArrayAccess;
use think\facade\Lang;
use think\file\UploadedFile;
use think\route\Rule;
/**
* 请求管理类
* @package think
*/
class Request implements ArrayAccess
{
/**
* 兼容PATH_INFO获取
* @var array
*/
protected $pathinfoFetch = ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL', 'PHP_SELF'];
/**
* PATHINFO变量名 用于兼容模式
* @var string
*/
protected $varPathinfo = 's';
/**
* 请求类型
* @var string
*/
protected $varMethod = '_method';
/**
* 表单ajax伪装变量
* @var string
*/
protected $varAjax = '_ajax';
/**
* 表单pjax伪装变量
* @var string
*/
protected $varPjax = '_pjax';
/**
* 域名根
* @var string
*/
protected $rootDomain = '';
/**
* 特殊域名根标识 用于识别com.cn org.cn 这种
* @var array
*/
protected $domainSpecialSuffix = ['com', 'net', 'org', 'edu', 'gov', 'mil', 'co', 'info'];
/**
* HTTPS代理标识
* @var string
*/
protected $httpsAgentName = '';
/**
* 前端代理服务器IP
* @var array
*/
protected $proxyServerIp = [];
/**
* 可信任的Host白名单(为空则不校验,支持 *.example.com 通配).
*
* @var array
*/
protected $trustedHosts = [];
/**
* 前端代理服务器真实IP头
* @var array
*/
protected $proxyServerIpHeader = ['HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP'];
/**
* 请求类型
* @var string
*/
protected $method;
/**
* 域名(含协议及端口)
* @var string
*/
protected $domain;
/**
* HOST(含端口)
* @var string
*/
protected $host;
/**
* 子域名
* @var string
*/
protected $subDomain;
/**
* 泛域名
* @var string
*/
protected $panDomain;
/**
* 当前URL地址
* @var string
*/
protected $url;
/**
* 基础URL
* @var string
*/
protected $baseUrl;
/**
* 当前执行的文件
* @var string
*/
protected $baseFile;
/**
* 访问的ROOT地址
* @var string
*/
protected $root;
/**
* pathinfo
* @var string
*/
protected $pathinfo;
/**
* pathinfo(不含后缀)
* @var string
*/
protected $path;
/**
* 当前请求的IP地址
* @var string
*/
protected $realIP;
/**
* 当前控制器分层名
* @var string
*/
protected $layer;
/**
* 当前控制器名
* @var string
*/
protected $controller;
/**
* 当前操作名
* @var string
*/
protected $action;
/**
* 当前请求参数
* @var array
*/
protected $param = [];
/**
* 当前GET参数
* @var array
*/
protected $get = [];
/**
* 当前POST参数
* @var array
*/
protected $post = [];
/**
* 当前REQUEST参数
* @var array
*/
protected $request = [];
/**
* 当前路由对象
* @var Rule
*/
protected $rule;
/**
* 当前ROUTE参数
* @var array
*/
protected $route = [];
/**
* 中间件传递的参数
* @var array
*/
protected $middleware = [];
/**
* 当前PUT参数
* @var array
*/
protected $put;
/**
* SESSION对象
* @var Session
*/
protected $session;
/**
* COOKIE数据
* @var array
*/
protected $cookie = [];
/**
* ENV对象
* @var Env
*/
protected $env;
/**
* 当前SERVER参数
* @var array
*/
protected $server = [];
/**
* 当前FILE参数
* @var array
*/
protected $file = [];
/**
* 当前HEADER参数
* @var array
*/
protected $header = [];
/**
* 资源类型定义
* @var array
*/
protected $mimeType = [
'xml' => 'application/xml,text/xml,application/x-xml',
'json' => 'application/json,text/x-json,application/jsonrequest,text/json',
'js' => 'text/javascript,application/javascript,application/x-javascript',
'css' => 'text/css',
'rss' => 'application/rss+xml',
'yaml' => 'application/x-yaml,text/yaml',
'atom' => 'application/atom+xml',
'pdf' => 'application/pdf',
'text' => 'text/plain',
'image' => 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/webp,image/*',
'csv' => 'text/csv',
'html' => 'text/html,application/xhtml+xml,*/*',
];
/**
* 当前请求内容
* @var string
*/
protected $content;
/**
* 全局过滤规则
* @var array
*/
protected $filter;
/**
* php://input内容
* @var string
*/
// php://input
protected $input;
/**
* 请求安全Key
* @var string
*/
protected $secureKey;
/**
* 是否合并Param
* @var bool
*/
protected $mergeParam = false;
/**
* 架构函数
* @access public
*/
public function __construct()
{
// 保存 php://input
$this->input = file_get_contents('php://input');
}
public static function __make(App $app)
{
$request = new static();
if (function_exists('apache_request_headers') && $result = apache_request_headers()) {
$header = $result;
} else {
$header = [];
$server = $_SERVER;
foreach ($server as $key => $val) {
if (str_starts_with($key, 'HTTP_')) {
$key = str_replace('_', '-', strtolower(substr($key, 5)));
$header[$key] = $val;
}
}
if (isset($server['CONTENT_TYPE'])) {
$header['content-type'] = $server['CONTENT_TYPE'];
}
if (isset($server['CONTENT_LENGTH'])) {
$header['content-length'] = $server['CONTENT_LENGTH'];
}
}
$request->header = array_change_key_case($header);
$request->server = $_SERVER;
$request->env = $app->env;
$inputData = $request->getInputData($request->input);
$request->get = $_GET;
$request->post = $_POST ?: $inputData;
$request->put = $inputData;
$request->request = $_REQUEST;
$request->cookie = $_COOKIE;
$request->file = $_FILES ?? [];
return $request;
}
/**
* 设置当前包含协议的域名
* @access public
* @param string $domain 域名
* @return $this
*/
public function setDomain(string $domain)
{
$this->domain = $domain;
return $this;
}
/**
* 获取当前包含协议的域名
* @access public
* @param bool $port 是否需要去除端口号
* @return string
*/
public function domain(bool $port = false): string
{
return $this->scheme() . '://' . $this->host($port);
}
/**
* 设置根域名
* @param string $domain
* @return $this
*/
public function setRootDomain(string $domain)
{
$this->rootDomain = $domain;
return $this;
}
/**
* 获取当前根域名
* @access public
* @return string
*/
public function rootDomain(): string
{
$root = $this->rootDomain;
if (!$root) {
$item = explode('.', $this->host(true));
$count = count($item);
if ($count > 1) {
$root = $item[$count - 2] . '.' . $item[$count - 1];
if ($count > 2 && in_array($item[$count - 2], $this->domainSpecialSuffix)) {
$root = $item[$count - 3] . '.' . $root;
}
} else {
$root = $item[0];
}
}
return $root;
}
/**
* 设置当前泛域名的值
* @access public
* @param string $domain 域名
* @return $this
*/
public function setSubDomain(string $domain)
{
$this->subDomain = $domain;
return $this;
}
/**
* 获取当前子域名
* @access public
* @return string
*/
public function subDomain(): string
{
if (is_null($this->subDomain)) {
// 获取当前主域名
$rootDomain = $this->rootDomain();
if ($rootDomain) {
$sub = stristr($this->host(), $rootDomain, true);
$this->subDomain = $sub ? rtrim($sub, '.') : '';
} else {
$this->subDomain = '';
}
}
return $this->subDomain;
}
/**
* 设置当前泛域名的值
* @access public
* @param string $domain 域名
* @return $this
*/
public function setPanDomain(string $domain)
{
$this->panDomain = $domain;
return $this;
}
/**
* 获取当前泛域名的值
* @access public
* @return string
*/
public function panDomain(): string
{
return $this->panDomain ?: '';
}
/**
* 设置当前完整URL 包括QUERY_STRING
* @access public
* @param string $url URL地址
* @return $this
*/
public function setUrl(string $url)
{
$this->url = $url;
return $this;
}
/**
* 获取当前完整URL 包括QUERY_STRING
* @access public
* @param bool $complete 是否包含完整域名
* @return string
*/
public function url(bool $complete = false): string
{
if ($this->url) {
$url = $this->url;
} elseif ($this->server('HTTP_X_REWRITE_URL')) {
$url = $this->server('HTTP_X_REWRITE_URL');
} elseif ($this->server('REQUEST_URI')) {
$url = $this->server('REQUEST_URI');
} elseif ($this->server('ORIG_PATH_INFO')) {
$url = $this->server('ORIG_PATH_INFO') . (!empty($this->server('QUERY_STRING')) ? '?' . $this->server('QUERY_STRING') : '');
} elseif (isset($_SERVER['argv'][1])) {
$url = $_SERVER['argv'][1];
} else {
$url = '';
}
return $complete ? $this->domain() . $url : $url;
}
/**
* 设置当前URL 不含QUERY_STRING
* @access public
* @param string $url URL地址
* @return $this
*/
public function setBaseUrl(string $url)
{
$this->baseUrl = $url;
return $this;
}
/**
* 获取当前URL 不含QUERY_STRING
* @access public
* @param bool $complete 是否包含完整域名
* @return string
*/
public function baseUrl(bool $complete = false): string
{
if (!$this->baseUrl) {
$str = $this->url();
$this->baseUrl = str_contains($str, '?') ? strstr($str, '?', true) : $str;
}
return $complete ? $this->domain() . $this->baseUrl : $this->baseUrl;
}
/**
* 获取当前执行的文件 SCRIPT_NAME
* @access public
* @param bool $complete 是否包含完整域名
* @return string
*/
public function baseFile(bool $complete = false): string
{
if (!$this->baseFile) {
$url = '';
if (!$this->isCli()) {
$script_name = basename($this->server('SCRIPT_FILENAME'));
if (basename($this->server('SCRIPT_NAME')) === $script_name) {
$url = $this->server('SCRIPT_NAME');
} elseif (basename($this->server('PHP_SELF')) === $script_name) {
$url = $this->server('PHP_SELF');
} elseif (basename($this->server('ORIG_SCRIPT_NAME')) === $script_name) {
$url = $this->server('ORIG_SCRIPT_NAME');
} elseif (($pos = strpos($this->server('PHP_SELF'), '/' . $script_name)) !== false) {
$url = substr($this->server('SCRIPT_NAME'), 0, $pos) . '/' . $script_name;
} elseif ($this->server('DOCUMENT_ROOT') && str_starts_with($this->server('SCRIPT_FILENAME'), $this->server('DOCUMENT_ROOT'))) {
$url = str_replace('\\', '/', str_replace($this->server('DOCUMENT_ROOT'), '', $this->server('SCRIPT_FILENAME')));
}
}
$this->baseFile = $url;
}
return $complete ? $this->domain() . $this->baseFile : $this->baseFile;
}
/**
* 设置URL访问根地址
* @access public
* @param string $url URL地址
* @return $this
*/
public function setRoot(string $url)
{
$this->root = $url;
return $this;
}
/**
* 获取URL访问根地址
* @access public
* @param bool $complete 是否包含完整域名
* @return string
*/
public function root(bool $complete = false): string
{
if (!$this->root) {
$file = $this->baseFile();
if ($file && !str_starts_with($this->url(), $file)) {
$file = str_replace('\\', '/', dirname($file));
}
$this->root = rtrim($file, '/');
}
return $complete ? $this->domain() . $this->root : $this->root;
}
/**
* 获取URL访问根目录
* @access public
* @return string
*/
public function rootUrl(): string
{
$base = $this->root();
$root = str_contains($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base;
if ('' != $root) {
$root = '/' . ltrim($root, '/');
}
return $root;
}
/**
* 设置当前请求的pathinfo
* @access public
* @param string $pathinfo
* @return $this
*/
public function setPathinfo(string $pathinfo)
{
$this->pathinfo = $pathinfo;
return $this;
}
/**
* 获取当前请求URL的pathinfo信息(含URL后缀)
* @access public
* @return string
*/
public function pathinfo(): string
{
if (is_null($this->pathinfo)) {
if (isset($_GET[$this->varPathinfo])) {
// 判断URL里面是否有兼容模式参数
$pathinfo = $_GET[$this->varPathinfo];
unset($_GET[$this->varPathinfo]);
unset($this->get[$this->varPathinfo]);
} elseif ($this->server('PATH_INFO')) {
$pathinfo = $this->server('PATH_INFO');
} elseif (str_contains(PHP_SAPI, 'cli')) {
$pathinfo = str_contains($this->server('REQUEST_URI'), '?') ? strstr($this->server('REQUEST_URI'), '?', true) : $this->server('REQUEST_URI');
}
// 分析PATHINFO信息
if (!isset($pathinfo)) {
foreach ($this->pathinfoFetch as $type) {
if ($this->server($type)) {
$pathinfo = str_starts_with($this->server($type), $this->server('SCRIPT_NAME')) ?
substr($this->server($type), strlen($this->server('SCRIPT_NAME'))) : $this->server($type);
break;
}
}
}
if (!empty($pathinfo)) {
unset($this->get[$pathinfo], $this->request[$pathinfo]);
}
$this->pathinfo = empty($pathinfo) || '/' == $pathinfo ? '' : ltrim($pathinfo, '/');
}
return $this->pathinfo;
}
/**
* 当前URL的访问后缀
* @access public
* @return string
*/
public function ext(): string
{
return pathinfo($this->pathinfo(), PATHINFO_EXTENSION);
}
/**
* 获取当前请求的时间
* @access public
* @param bool $float 是否使用浮点类型
* @return int|float
*/
public function time(bool $float = false)
{
return $float ? $this->server('REQUEST_TIME_FLOAT') : $this->server('REQUEST_TIME');
}
/**
* 当前请求的资源类型
* @access public
* @return string
*/
public function type(): string
{
$accept = $this->server('HTTP_ACCEPT');
if (empty($accept)) {
return '';
}
foreach ($this->mimeType as $key => $val) {
$array = explode(',', $val);
foreach ($array as $k => $v) {
if (stristr($accept, $v)) {
return $key;
}
}
}
return '';
}
/**
* 设置资源类型
* @access public
* @param string|array $type 资源类型名
* @param string $val 资源类型
* @return void
*/
public function mimeType($type, $val = ''): void
{
if (is_array($type)) {
$this->mimeType = array_merge($this->mimeType, $type);
} else {
$this->mimeType[$type] = $val;
}
}
/**
* 设置请求类型
* @access public
* @param string $method 请求类型
* @return $this
*/
public function setMethod(string $method)
{
$this->method = strtoupper($method);
return $this;
}
/**
* 当前的请求类型
* @access public
* @param bool $origin 是否获取原始请求类型
* @return string
*/
public function method(bool $origin = false): string
{
if ($origin) {
// 获取原始请求类型
return $this->server('REQUEST_METHOD') ?: 'GET';
}
if (!$this->method) {
if (isset($this->post[$this->varMethod])) {
$method = strtolower($this->post[$this->varMethod]);
if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) {
$this->method = strtoupper($method);
$this->{$method} = $this->post;
} else {
$this->method = 'POST';
}
unset($this->post[$this->varMethod]);
} elseif ($this->server('HTTP_X_HTTP_METHOD_OVERRIDE')) {
$this->method = strtoupper($this->server('HTTP_X_HTTP_METHOD_OVERRIDE'));
} else {
$this->method = $this->server('REQUEST_METHOD') ?: 'GET';
}
}
return $this->method;
}
/**
* 是否为GET请求
* @access public
* @return bool
*/
public function isGet(): bool
{
return $this->method() == 'GET';
}
/**
* 是否为POST请求
* @access public
* @return bool
*/
public function isPost(): bool
{
return $this->method() == 'POST';
}
/**
* 是否为PUT请求
* @access public
* @return bool
*/
public function isPut(): bool
{
return $this->method() == 'PUT';
}
/**
* 是否为DELTE请求
* @access public
* @return bool
*/
public function isDelete(): bool
{
return $this->method() == 'DELETE';
}
/**
* 是否为HEAD请求
* @access public
* @return bool
*/
public function isHead(): bool
{
return $this->method() == 'HEAD';
}
/**
* 是否为PATCH请求
* @access public
* @return bool
*/
public function isPatch(): bool
{
return $this->method() == 'PATCH';
}
/**
* 是否为OPTIONS请求
* @access public
* @return bool
*/
public function isOptions(): bool
{
return $this->method() == 'OPTIONS';
}
/**
* 是否为cli
* @access public
* @return bool
*/
public function isCli(): bool
{
return PHP_SAPI == 'cli';
}
/**
* 是否为cgi
* @access public
* @return bool
*/
public function isCgi(): bool
{
return str_starts_with(PHP_SAPI, 'cgi');
}
/**
* 获取当前请求的参数
* @access public
* @param string|array $name 变量名
* @param mixed $default 默认值
* @param string|array|null $filter 过滤方法
* @return mixed
*/
public function param($name = '', $default = null, string | array | null $filter = '')
{
if (empty($this->mergeParam)) {
$method = $this->method(true);
// 自动获取请求变量
$vars = match ($method) {
'POST' => $this->post(false),
'PUT', 'DELETE', 'PATCH' => $this->put(false),
default => [],
};
// 当前请求参数和URL地址中的参数合并
$this->param = array_merge($this->param, $this->route(false), $this->get(false), $vars);
$this->mergeParam = true;
}
if (is_array($name)) {
return $this->only($name, $this->param, $filter);
}
return $this->input($this->param, $name, $default, $filter);
}
/**
* 获取包含文件在内的请求参数
* @access public
* @param string|array $name 变量名
* @param string|array|null $filter 过滤方法
* @return mixed
*/
public function all(string | array $name = '', string | array | null $filter = '')
{
$data = array_merge($this->param(), $this->file() ?: []);
if (is_array($name)) {
$data = $this->only($name, $data, $filter);
} elseif ($name) {
$data = $data[$name] ?? null;
}
return $data;
}
/**
* 设置路由变量
* @access public
* @param Rule $rule 路由对象
* @return $this
*/
public function setRule(Rule $rule)
{
$this->rule = $rule;
return $this;
}
/**
* 获取当前路由对象
* @access public
* @return Rule|null
*/
public function rule()
{
return $this->rule;
}
/**
* 设置路由变量
* @access public
* @param array $route 路由变量
* @return $this
*/
public function setRoute(array $route)
{
$this->route = array_merge($this->route, $route);
$this->mergeParam = false;
return $this;
}
/**
* 获取路由参数
* @access public
* @param string|array|bool $name 变量名
* @param mixed $default 默认值
* @param string|array|null $filter 过滤方法
* @return mixed
*/
public function route(string | array | bool $name = '', $default = null, string | array | null $filter = '')
{
if (is_array($name)) {
return $this->only($name, $this->route, $filter);
}
return $this->input($this->route, $name, $default, $filter);
}
/**
* 获取GET参数
* @access public
* @param string|array|bool $name 变量名
* @param mixed $default 默认值
* @param string|array|null $filter 过滤方法
* @return mixed
*/
public function get(string | array | bool $name = '', $default = null, string | array | null $filter = '')
{
if (is_array($name)) {
return $this->only($name, $this->get, $filter);
}
return $this->input($this->get, $name, $default, $filter);
}
/**
* 获取中间件传递的参数
* @access public
* @param string|null $name 变量名
* @param mixed $default 默认值