Passed
Push — master ( 34a83f...053766 )
by kill
03:49
created
core/App.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 use Dotenv\Dotenv;
10 10
 use puck\Config;
11 11
 use puck\Route;
12
-use puck\tools\Arr;
13 12
 use Whoops\Run;
14 13
 
15 14
 class App extends Container {
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      *
19 19
      * @var array
20 20
      */
21
-    protected $loadedConfigurations = [];
21
+    protected $loadedConfigurations=[];
22 22
 
23 23
     /**
24 24
      * 应用的根目录.
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
         $this->initContainer();
33 33
         $this->initConfig();
34 34
     }
35
-    private function initConfig(){
35
+    private function initConfig() {
36 36
         $this->configure('core');
37 37
     }
38 38
 
39
-    private function initEnv(){
40
-        $dotEnv = new Dotenv($this->basePath);
39
+    private function initEnv() {
40
+        $dotEnv=new Dotenv($this->basePath);
41 41
         $dotEnv->load();
42 42
         date_default_timezone_set(env('APP_TIMEZONE', 'Asia/Shanghai'));
43 43
         define('IS_CLI', $this->runningInConsole());
44
-        define('IS_DEBUG',env('DEBUG',false));
44
+        define('IS_DEBUG', env('DEBUG', false));
45 45
         if (IS_DEBUG) {
46 46
             error_reporting(E_ALL);
47 47
             @ini_set('display_errors', 'On');
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
      */
64 64
     private function initContainer() {
65 65
         static::setInstance($this);
66
-        $this->instance('app',$this);
67
-        $this->instance('config',new Config());
68
-        $this->instance('request',new Request($this->config));
69
-        $this->instance('route',new Route($this->request));
70
-        $this->bind('pinyin','\puck\helpers\PinYin');
66
+        $this->instance('app', $this);
67
+        $this->instance('config', new Config());
68
+        $this->instance('request', new Request($this->config));
69
+        $this->instance('route', new Route($this->request));
70
+        $this->bind('pinyin', '\puck\helpers\PinYin');
71 71
     }
72 72
 
73 73
     /**
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
      * @param  string|null  $path
77 77
      * @return string
78 78
      */
79
-    public function basePath($path = null)
79
+    public function basePath($path=null)
80 80
     {
81 81
         if (isset($this->basePath)) {
82 82
             return $this->basePath.($path ? '/'.$path : $path);
83 83
         }
84 84
 
85 85
         if ($this->runningInConsole()) {
86
-            $this->basePath = getcwd();
86
+            $this->basePath=getcwd();
87 87
         } else {
88
-            $this->basePath = realpath(getcwd().'/../');
88
+            $this->basePath=realpath(getcwd().'/../');
89 89
         }
90 90
 
91 91
         return $this->basePath($path);
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
             return;
112 112
         }
113 113
         //标记为已加载
114
-        $this->loadedConfigurations[$name] = true;
115
-        $path = $this->getConfigurationPath($name);
114
+        $this->loadedConfigurations[$name]=true;
115
+        $path=$this->getConfigurationPath($name);
116 116
         if ($path) {
117 117
             $this->make('config')->set($name, require $path);
118 118
         }
@@ -129,21 +129,21 @@  discard block
 block discarded – undo
129 129
      * @param  string|null  $name
130 130
      * @return string
131 131
      */
132
-    public function getConfigurationPath($name = null)
132
+    public function getConfigurationPath($name=null)
133 133
     {
134
-        if (! $name) {
135
-            $appConfigDir = $this->basePath('configs').'/';
134
+        if (!$name) {
135
+            $appConfigDir=$this->basePath('configs').'/';
136 136
 
137 137
             if (file_exists($appConfigDir)) {
138 138
                 return $appConfigDir;
139
-            } elseif (file_exists($path = __DIR__.'/configs/')) {
139
+            } elseif (file_exists($path=__DIR__.'/configs/')) {
140 140
                 return $path;
141 141
             }
142 142
         } else {
143
-            $appConfigPath = $this->basePath('configs').'/'.$name.'.php';
143
+            $appConfigPath=$this->basePath('configs').'/'.$name.'.php';
144 144
             if (file_exists($appConfigPath)) {
145 145
                 return $appConfigPath;
146
-            } elseif (file_exists($path = __DIR__.'/configs/'.$name.'.php')) {
146
+            } elseif (file_exists($path=__DIR__.'/configs/'.$name.'.php')) {
147 147
                 return $path;
148 148
             }
149 149
         }
Please login to merge, or discard this patch.
core/Config.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     /**
53 53
      * Set a given configuration value.
54 54
      *
55
-     * @param  array|string  $key
55
+     * @param  string  $key
56 56
      * @param  mixed   $value
57 57
      * @return void
58 58
      */
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      *
14 14
      * @var array
15 15
      */
16
-    protected $items = [];
16
+    protected $items=[];
17 17
 
18 18
     /**
19 19
      * Create a new configuration repository.
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
      * @param  array  $items
22 22
      * @return void
23 23
      */
24
-    public function __construct(array $items = [])
24
+    public function __construct(array $items=[])
25 25
     {
26
-        $this->items = $items;
26
+        $this->items=$items;
27 27
     }
28 28
 
29 29
     /**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param  mixed   $default
45 45
      * @return mixed
46 46
      */
47
-    public function get($key, $default = null)
47
+    public function get($key, $default=null)
48 48
     {
49 49
         return Arr::get($this->items, $key, $default);
50 50
     }
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      * @param  mixed   $value
57 57
      * @return void
58 58
      */
59
-    public function set($key, $value = null)
59
+    public function set($key, $value=null)
60 60
     {
61
-        $keys = is_array($key) ? $key : [$key => $value];
61
+        $keys=is_array($key) ? $key : [$key => $value];
62 62
 
63 63
         foreach ($keys as $key => $value) {
64 64
             Arr::set($this->items, $key, $value);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function prepend($key, $value)
76 76
     {
77
-        $array = $this->get($key);
77
+        $array=$this->get($key);
78 78
 
79 79
         array_unshift($array, $value);
80 80
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function push($key, $value)
92 92
     {
93
-        $array = $this->get($key);
93
+        $array=$this->get($key);
94 94
 
95
-        $array[] = $value;
95
+        $array[]=$value;
96 96
 
97 97
         $this->set($key, $array);
98 98
     }
Please login to merge, or discard this patch.
core/Request.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @param array     $files
171 171
      * @param array     $server
172 172
      * @param string    $content
173
-     * @return \think\Request
173
+     * @return Request
174 174
      */
175 175
     public function create($uri, $method = 'GET', $params = [], $cookie = [], $files = [], $server = [], $content = null)
176 176
     {
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
     /**
613 613
      * 设置获取获取路由参数
614 614
      * @access public
615
-     * @param string|array  $name 变量名
615
+     * @param boolean  $name 变量名
616 616
      * @param mixed         $default 默认值
617 617
      * @param string|array  $filter 过滤方法
618 618
      * @return mixed
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
     /**
630 630
      * 设置获取获取GET参数
631 631
      * @access public
632
-     * @param string|array  $name 变量名
632
+     * @param boolean  $name 变量名
633 633
      * @param mixed         $default 默认值
634 634
      * @param string|array  $filter 过滤方法
635 635
      * @return mixed
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
     /**
784 784
      * 获取server参数
785 785
      * @access public
786
-     * @param string|array  $name 数据名称
786
+     * @param string  $name 数据名称
787 787
      * @param string        $default 默认值
788
-     * @param string|array  $filter 过滤方法
788
+     * @param string  $filter 过滤方法
789 789
      * @return mixed
790 790
      */
791 791
     public function server($name = '', $default = null, $filter = '')
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
      * @param string    $name 变量名
1087 1087
      * @param string    $type 变量类型
1088 1088
      * @param bool      $checkEmpty 是否检测空值
1089
-     * @return mixed
1089
+     * @return boolean
1090 1090
      */
1091 1091
     public function has($name, $type = 'param', $checkEmpty = false)
1092 1092
     {
Please login to merge, or discard this patch.
Spacing   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
     /**
52 52
      * @var array 当前路由信息
53 53
      */
54
-    protected $routeInfo = [];
54
+    protected $routeInfo=[];
55 55
 
56 56
     /**
57 57
      * @var array 当前调度信息
58 58
      */
59
-    protected $dispatch = [];
59
+    protected $dispatch=[];
60 60
     protected $module;
61 61
     protected $controller;
62 62
     protected $action;
@@ -66,22 +66,22 @@  discard block
 block discarded – undo
66 66
     /**
67 67
      * @var array 请求参数
68 68
      */
69
-    protected $param   = [];
70
-    protected $get     = [];
71
-    protected $post    = [];
72
-    protected $request = [];
73
-    protected $route   = [];
69
+    protected $param=[];
70
+    protected $get=[];
71
+    protected $post=[];
72
+    protected $request=[];
73
+    protected $route=[];
74 74
     protected $put;
75
-    protected $session = [];
76
-    protected $file    = [];
77
-    protected $cookie  = [];
78
-    protected $server  = [];
79
-    protected $header  = [];
75
+    protected $session=[];
76
+    protected $file=[];
77
+    protected $cookie=[];
78
+    protected $server=[];
79
+    protected $header=[];
80 80
 
81 81
     /**
82 82
      * @var array 资源类型
83 83
      */
84
-    protected $mimeType = [
84
+    protected $mimeType=[
85 85
         'xml'  => 'application/xml,text/xml,application/x-xml',
86 86
         'json' => 'application/json,text/x-json,application/jsonrequest,text/json',
87 87
         'js'   => 'text/javascript,application/javascript,application/x-javascript',
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
     // 全局过滤规则
104 104
     protected $filter;
105 105
     // Hook扩展方法
106
-    protected static $hook = [];
106
+    protected static $hook=[];
107 107
     // 绑定的属性
108
-    protected $bind = [];
108
+    protected $bind=[];
109 109
     // php://input
110 110
     protected $input;
111 111
     // 请求缓存
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
      * @access public
119 119
      * @param array $options 参数
120 120
      */
121
-    public function __construct(Config $config, $options = [])
121
+    public function __construct(Config $config, $options=[])
122 122
     {
123 123
         $this->server();
124 124
         foreach ($options as $name => $item) {
125 125
             if (property_exists($this, $name)) {
126
-                $this->$name = $item;
126
+                $this->$name=$item;
127 127
             }
128 128
         }
129
-        $this->config = $config;
129
+        $this->config=$config;
130 130
         if (is_null($this->filter)) {
131
-            $this->filter = $this->config->get('default_filter');
131
+            $this->filter=$this->config->get('default_filter');
132 132
         }
133 133
         // 保存 php://input
134
-        $this->input = file_get_contents('php://input');
134
+        $this->input=file_get_contents('php://input');
135 135
     }
136 136
 
137 137
     public function __call($method, $args)
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             array_unshift($args, $this);
141 141
             return call_user_func_array($this->hook[$method], $args);
142 142
         } else {
143
-            throw new Exception('method not exists:' . __CLASS__ . '->' . $method);
143
+            throw new Exception('method not exists:'.__CLASS__.'->'.$method);
144 144
         }
145 145
     }
146 146
 
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
      * @param mixed         $callback callable
152 152
      * @return void
153 153
      */
154
-    public function hook($method, $callback = null)
154
+    public function hook($method, $callback=null)
155 155
     {
156 156
         if (is_array($method)) {
157
-            $this->hook = array_merge($this->hook, $method);
157
+            $this->hook=array_merge($this->hook, $method);
158 158
         } else {
159
-            $this->hook[$method] = $callback;
159
+            $this->hook[$method]=$callback;
160 160
         }
161 161
     }
162 162
 
@@ -172,72 +172,72 @@  discard block
 block discarded – undo
172 172
      * @param string    $content
173 173
      * @return \think\Request
174 174
      */
175
-    public function create($uri, $method = 'GET', $params = [], $cookie = [], $files = [], $server = [], $content = null)
175
+    public function create($uri, $method='GET', $params=[], $cookie=[], $files=[], $server=[], $content=null)
176 176
     {
177
-        $server['PATH_INFO']      = '';
178
-        $server['REQUEST_METHOD'] = strtoupper($method);
179
-        $info                     = parse_url($uri);
177
+        $server['PATH_INFO']='';
178
+        $server['REQUEST_METHOD']=strtoupper($method);
179
+        $info=parse_url($uri);
180 180
         if (isset($info['host'])) {
181
-            $server['SERVER_NAME'] = $info['host'];
182
-            $server['HTTP_HOST']   = $info['host'];
181
+            $server['SERVER_NAME']=$info['host'];
182
+            $server['HTTP_HOST']=$info['host'];
183 183
         }
184 184
         if (isset($info['scheme'])) {
185 185
             if ('https' === $info['scheme']) {
186
-                $server['HTTPS']       = 'on';
187
-                $server['SERVER_PORT'] = 443;
186
+                $server['HTTPS']='on';
187
+                $server['SERVER_PORT']=443;
188 188
             } else {
189 189
                 unset($server['HTTPS']);
190
-                $server['SERVER_PORT'] = 80;
190
+                $server['SERVER_PORT']=80;
191 191
             }
192 192
         }
193 193
         if (isset($info['port'])) {
194
-            $server['SERVER_PORT'] = $info['port'];
195
-            $server['HTTP_HOST']   = $server['HTTP_HOST'] . ':' . $info['port'];
194
+            $server['SERVER_PORT']=$info['port'];
195
+            $server['HTTP_HOST']=$server['HTTP_HOST'].':'.$info['port'];
196 196
         }
197 197
         if (isset($info['user'])) {
198
-            $server['PHP_AUTH_USER'] = $info['user'];
198
+            $server['PHP_AUTH_USER']=$info['user'];
199 199
         }
200 200
         if (isset($info['pass'])) {
201
-            $server['PHP_AUTH_PW'] = $info['pass'];
201
+            $server['PHP_AUTH_PW']=$info['pass'];
202 202
         }
203 203
         if (!isset($info['path'])) {
204
-            $info['path'] = '/';
204
+            $info['path']='/';
205 205
         }
206
-        $options                      = [];
207
-        $options[strtolower($method)] = $params;
208
-        $queryString                  = '';
206
+        $options=[];
207
+        $options[strtolower($method)]=$params;
208
+        $queryString='';
209 209
         if (isset($info['query'])) {
210 210
             parse_str(html_entity_decode($info['query']), $query);
211 211
             if (!empty($params)) {
212
-                $params      = array_replace($query, $params);
213
-                $queryString = http_build_query($query, '', '&');
212
+                $params=array_replace($query, $params);
213
+                $queryString=http_build_query($query, '', '&');
214 214
             } else {
215
-                $params      = $query;
216
-                $queryString = $info['query'];
215
+                $params=$query;
216
+                $queryString=$info['query'];
217 217
             }
218 218
         } elseif (!empty($params)) {
219
-            $queryString = http_build_query($params, '', '&');
219
+            $queryString=http_build_query($params, '', '&');
220 220
         }
221 221
         if ($queryString) {
222 222
             parse_str($queryString, $get);
223
-            $options['get'] = isset($options['get']) ? array_merge($get, $options['get']) : $get;
224
-        }
225
-
226
-        $server['REQUEST_URI']  = $info['path'] . ('' !== $queryString ? '?' . $queryString : '');
227
-        $server['QUERY_STRING'] = $queryString;
228
-        $options['cookie']      = $cookie;
229
-        $options['param']       = $params;
230
-        $options['file']        = $files;
231
-        $options['server']      = $server;
232
-        $options['url']         = $server['REQUEST_URI'];
233
-        $options['baseUrl']     = $info['path'];
234
-        $options['pathinfo']    = '/' == $info['path'] ? '/' : ltrim($info['path'], '/');
235
-        $options['method']      = $server['REQUEST_METHOD'];
236
-        $options['domain']      = isset($info['scheme']) ? $info['scheme'] . '://' . $server['HTTP_HOST'] : '';
237
-        $options['content']     = $content;
223
+            $options['get']=isset($options['get']) ? array_merge($get, $options['get']) : $get;
224
+        }
225
+
226
+        $server['REQUEST_URI']=$info['path'].('' !== $queryString ? '?'.$queryString : '');
227
+        $server['QUERY_STRING']=$queryString;
228
+        $options['cookie']=$cookie;
229
+        $options['param']=$params;
230
+        $options['file']=$files;
231
+        $options['server']=$server;
232
+        $options['url']=$server['REQUEST_URI'];
233
+        $options['baseUrl']=$info['path'];
234
+        $options['pathinfo']='/' == $info['path'] ? '/' : ltrim($info['path'], '/');
235
+        $options['method']=$server['REQUEST_METHOD'];
236
+        $options['domain']=isset($info['scheme']) ? $info['scheme'].'://'.$server['HTTP_HOST'] : '';
237
+        $options['content']=$content;
238 238
         foreach ($options as $name => $item) {
239 239
             if (property_exists($this, $name)) {
240
-                $this->$name = $item;
240
+                $this->$name=$item;
241 241
             }
242 242
         }
243 243
         return $this;
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
      * @param string $domain 域名
250 250
      * @return string
251 251
      */
252
-    public function domain($domain = null)
252
+    public function domain($domain=null)
253 253
     {
254 254
         if (!is_null($domain)) {
255
-            $this->domain = $domain;
255
+            $this->domain=$domain;
256 256
             return $this;
257 257
         } elseif (!$this->domain) {
258
-            $this->domain = $this->scheme() . '://' . $this->host();
258
+            $this->domain=$this->scheme().'://'.$this->host();
259 259
         }
260 260
         return $this->domain;
261 261
     }
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
      * @param string|true $url URL地址 true 带域名获取
267 267
      * @return string
268 268
      */
269
-    public function url($url = null)
269
+    public function url($url=null)
270 270
     {
271 271
         if (!is_null($url) && true !== $url) {
272
-            $this->url = $url;
272
+            $this->url=$url;
273 273
             return $this;
274 274
         } elseif (!$this->url) {
275 275
             if ($this->isCli()) {
276
-                $this->url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
276
+                $this->url=isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
277 277
             } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
278
-                $this->url = $_SERVER['HTTP_X_REWRITE_URL'];
278
+                $this->url=$_SERVER['HTTP_X_REWRITE_URL'];
279 279
             } elseif (isset($_SERVER['REQUEST_URI'])) {
280
-                $this->url = $_SERVER['REQUEST_URI'];
280
+                $this->url=$_SERVER['REQUEST_URI'];
281 281
             } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
282
-                $this->url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
282
+                $this->url=$_SERVER['ORIG_PATH_INFO'].(!empty($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : '');
283 283
             } else {
284
-                $this->url = '';
284
+                $this->url='';
285 285
             }
286 286
         }
287
-        return true === $url ? $this->domain() . $this->url : $this->url;
287
+        return true === $url ? $this->domain().$this->url : $this->url;
288 288
     }
289 289
 
290 290
     /**
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
      * @param string $url URL地址
294 294
      * @return string
295 295
      */
296
-    public function baseUrl($url = null)
296
+    public function baseUrl($url=null)
297 297
     {
298 298
         if (!is_null($url) && true !== $url) {
299
-            $this->baseUrl = $url;
299
+            $this->baseUrl=$url;
300 300
             return $this;
301 301
         } elseif (!$this->baseUrl) {
302
-            $str           = $this->url();
303
-            $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str;
302
+            $str=$this->url();
303
+            $this->baseUrl=strpos($str, '?') ? strstr($str, '?', true) : $str;
304 304
         }
305
-        return true === $url ? $this->domain() . $this->baseUrl : $this->baseUrl;
305
+        return true === $url ? $this->domain().$this->baseUrl : $this->baseUrl;
306 306
     }
307 307
 
308 308
     /**
@@ -311,30 +311,30 @@  discard block
 block discarded – undo
311 311
      * @param string $file 当前执行的文件
312 312
      * @return string
313 313
      */
314
-    public function baseFile($file = null)
314
+    public function baseFile($file=null)
315 315
     {
316 316
         if (!is_null($file) && true !== $file) {
317
-            $this->baseFile = $file;
317
+            $this->baseFile=$file;
318 318
             return $this;
319 319
         } elseif (!$this->baseFile) {
320
-            $url = '';
320
+            $url='';
321 321
             if (!$this->isCli()) {
322
-                $script_name = basename($_SERVER['SCRIPT_FILENAME']);
322
+                $script_name=basename($_SERVER['SCRIPT_FILENAME']);
323 323
                 if (basename($_SERVER['SCRIPT_NAME']) === $script_name) {
324
-                    $url = $_SERVER['SCRIPT_NAME'];
324
+                    $url=$_SERVER['SCRIPT_NAME'];
325 325
                 } elseif (basename($_SERVER['PHP_SELF']) === $script_name) {
326
-                    $url = $_SERVER['PHP_SELF'];
326
+                    $url=$_SERVER['PHP_SELF'];
327 327
                 } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name) {
328
-                    $url = $_SERVER['ORIG_SCRIPT_NAME'];
329
-                } elseif (($pos = strpos($_SERVER['PHP_SELF'], '/' . $script_name)) !== false) {
330
-                    $url = substr($_SERVER['SCRIPT_NAME'], 0, $pos) . '/' . $script_name;
328
+                    $url=$_SERVER['ORIG_SCRIPT_NAME'];
329
+                } elseif (($pos=strpos($_SERVER['PHP_SELF'], '/'.$script_name)) !== false) {
330
+                    $url=substr($_SERVER['SCRIPT_NAME'], 0, $pos).'/'.$script_name;
331 331
                 } elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) {
332
-                    $url = str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
332
+                    $url=str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
333 333
                 }
334 334
             }
335
-            $this->baseFile = $url;
335
+            $this->baseFile=$url;
336 336
         }
337
-        return true === $file ? $this->domain() . $this->baseFile : $this->baseFile;
337
+        return true === $file ? $this->domain().$this->baseFile : $this->baseFile;
338 338
     }
339 339
 
340 340
     /**
@@ -343,19 +343,19 @@  discard block
 block discarded – undo
343 343
      * @param string $url URL地址
344 344
      * @return string
345 345
      */
346
-    public function root($url = null)
346
+    public function root($url=null)
347 347
     {
348 348
         if (!is_null($url) && true !== $url) {
349
-            $this->root = $url;
349
+            $this->root=$url;
350 350
             return $this;
351 351
         } elseif (!$this->root) {
352
-            $file = $this->baseFile();
352
+            $file=$this->baseFile();
353 353
             if ($file && 0 !== strpos($this->url(), $file)) {
354
-                $file = str_replace('\\', '/', dirname($file));
354
+                $file=str_replace('\\', '/', dirname($file));
355 355
             }
356
-            $this->root = rtrim($file, '/');
356
+            $this->root=rtrim($file, '/');
357 357
         }
358
-        return true === $url ? $this->domain() . $this->root : $this->root;
358
+        return true === $url ? $this->domain().$this->root : $this->root;
359 359
     }
360 360
 
361 361
     /**
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
      */
366 366
     public function rootUrl()
367 367
     {
368
-        $base = $this->root();
369
-        $root = strpos($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base;
368
+        $base=$this->root();
369
+        $root=strpos($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base;
370 370
         if ('' != $root) {
371
-            $root = '/' . ltrim($root, '/');
371
+            $root='/'.ltrim($root, '/');
372 372
         }
373 373
         return $root;
374 374
     }
@@ -382,17 +382,17 @@  discard block
 block discarded – undo
382 382
     public function path()
383 383
     {
384 384
         if (is_null($this->path)) {
385
-            $suffix   = $this->config->get('core.url_html_suffix');
386
-            $pathinfo = $this->baseUrl();
385
+            $suffix=$this->config->get('core.url_html_suffix');
386
+            $pathinfo=$this->baseUrl();
387 387
             if (false === $suffix) {
388 388
                 // 禁止伪静态访问
389
-                $this->path = $pathinfo;
389
+                $this->path=$pathinfo;
390 390
             } elseif ($suffix) {
391 391
                 // 去除正常的URL后缀
392
-                $this->path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo);
392
+                $this->path=preg_replace('/\.('.ltrim($suffix, '.').')$/i', '', $pathinfo);
393 393
             } else {
394 394
                 // 允许任何后缀访问
395
-                $this->path = preg_replace('/\.' . $this->ext() . '$/i', '', $pathinfo);
395
+                $this->path=preg_replace('/\.'.$this->ext().'$/i', '', $pathinfo);
396 396
             }
397 397
         }
398 398
         return $this->path;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
      * @param bool $float 是否使用浮点类型
415 415
      * @return integer|float
416 416
      */
417
-    public function time($float = false)
417
+    public function time($float=false)
418 418
     {
419 419
         return $float ? $_SERVER['REQUEST_TIME_FLOAT'] : $_SERVER['REQUEST_TIME'];
420 420
     }
@@ -426,13 +426,13 @@  discard block
 block discarded – undo
426 426
      */
427 427
     public function type()
428 428
     {
429
-        $accept = $this->server('HTTP_ACCEPT');
429
+        $accept=$this->server('HTTP_ACCEPT');
430 430
         if (empty($accept)) {
431 431
             return false;
432 432
         }
433 433
 
434 434
         foreach ($this->mimeType as $key => $val) {
435
-            $array = explode(',', $val);
435
+            $array=explode(',', $val);
436 436
             foreach ($array as $k => $v) {
437 437
                 if (stristr($accept, $v)) {
438 438
                     return $key;
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
      * @param string        $val 资源类型
450 450
      * @return void
451 451
      */
452
-    public function mimeType($type, $val = '')
452
+    public function mimeType($type, $val='')
453 453
     {
454 454
         if (is_array($type)) {
455
-            $this->mimeType = array_merge($this->mimeType, $type);
455
+            $this->mimeType=array_merge($this->mimeType, $type);
456 456
         } else {
457
-            $this->mimeType[$type] = $val;
457
+            $this->mimeType[$type]=$val;
458 458
         }
459 459
     }
460 460
 
@@ -464,19 +464,19 @@  discard block
 block discarded – undo
464 464
      * @param bool $method  true 获取原始请求类型
465 465
      * @return string
466 466
      */
467
-    public function method($method = false)
467
+    public function method($method=false)
468 468
     {
469 469
         if (true === $method) {
470 470
             // 获取原始请求类型
471 471
             return $this->isCli() ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
472 472
         } elseif (!$this->method) {
473 473
             if (isset($_POST[$this->config->get('var_method')])) {
474
-                $this->method = strtoupper($_POST[$this->config->get('var_method')]);
474
+                $this->method=strtoupper($_POST[$this->config->get('var_method')]);
475 475
                 $this->{$this->method}($_POST);
476 476
             } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) {
477
-                $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
477
+                $this->method=strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']);
478 478
             } else {
479
-                $this->method = $this->isCli() ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
479
+                $this->method=$this->isCli() ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
480 480
             }
481 481
         }
482 482
         return $this->method;
@@ -580,30 +580,30 @@  discard block
 block discarded – undo
580 580
      * @param string|array  $filter 过滤方法
581 581
      * @return mixed
582 582
      */
583
-    public function param($name = '', $default = null, $filter = '')
583
+    public function param($name='', $default=null, $filter='')
584 584
     {
585 585
         if (empty($this->param)) {
586
-            $method = $this->method(true);
586
+            $method=$this->method(true);
587 587
             // 自动获取请求变量
588 588
             switch ($method) {
589 589
                 case 'POST':
590
-                    $vars = $this->post(false);
590
+                    $vars=$this->post(false);
591 591
                     break;
592 592
                 case 'PUT':
593 593
                 case 'DELETE':
594 594
                 case 'PATCH':
595
-                    $vars = $this->put(false);
595
+                    $vars=$this->put(false);
596 596
                     break;
597 597
                 default:
598
-                    $vars = [];
598
+                    $vars=[];
599 599
             }
600 600
             // 当前请求参数和URL地址中的参数合并
601
-            $this->param = array_merge($this->get(false), $vars, $this->route(false));
601
+            $this->param=array_merge($this->get(false), $vars, $this->route(false));
602 602
         }
603 603
         if (true === $name) {
604 604
             // 获取包含文件上传信息的数组
605
-            $file = $this->file();
606
-            $data = is_array($file) ? array_merge($this->param, $file) : $this->param;
605
+            $file=$this->file();
606
+            $data=is_array($file) ? array_merge($this->param, $file) : $this->param;
607 607
             return $this->input($data, '', $default, $filter);
608 608
         }
609 609
         return $this->input($this->param, $name, $default, $filter);
@@ -617,11 +617,11 @@  discard block
 block discarded – undo
617 617
      * @param string|array  $filter 过滤方法
618 618
      * @return mixed
619 619
      */
620
-    public function route($name = '', $default = null, $filter = '')
620
+    public function route($name='', $default=null, $filter='')
621 621
     {
622 622
         if (is_array($name)) {
623
-            $this->param        = [];
624
-            return $this->route = array_merge($this->route, $name);
623
+            $this->param=[];
624
+            return $this->route=array_merge($this->route, $name);
625 625
         }
626 626
         return $this->input($this->route, $name, $default, $filter);
627 627
     }
@@ -634,14 +634,14 @@  discard block
 block discarded – undo
634 634
      * @param string|array  $filter 过滤方法
635 635
      * @return mixed
636 636
      */
637
-    public function get($name = '', $default = null, $filter = '')
637
+    public function get($name='', $default=null, $filter='')
638 638
     {
639 639
         if (empty($this->get)) {
640
-            $this->get = $_GET;
640
+            $this->get=$_GET;
641 641
         }
642 642
         if (is_array($name)) {
643
-            $this->param      = [];
644
-            return $this->get = array_merge($this->get, $name);
643
+            $this->param=[];
644
+            return $this->get=array_merge($this->get, $name);
645 645
         }
646 646
         return $this->input($this->get, $name, $default, $filter);
647 647
     }
@@ -654,19 +654,19 @@  discard block
 block discarded – undo
654 654
      * @param string|array  $filter 过滤方法
655 655
      * @return mixed
656 656
      */
657
-    public function post($name = '', $default = null, $filter = '')
657
+    public function post($name='', $default=null, $filter='')
658 658
     {
659 659
         if (empty($this->post)) {
660
-            $content = $this->input;
660
+            $content=$this->input;
661 661
             if (empty($_POST) && false !== strpos($this->contentType(), 'application/json')) {
662
-                $this->post = (array) json_decode($content, true);
662
+                $this->post=(array) json_decode($content, true);
663 663
             } else {
664
-                $this->post = $_POST;
664
+                $this->post=$_POST;
665 665
             }
666 666
         }
667 667
         if (is_array($name)) {
668
-            $this->param       = [];
669
-            return $this->post = array_merge($this->post, $name);
668
+            $this->param=[];
669
+            return $this->post=array_merge($this->post, $name);
670 670
         }
671 671
         return $this->input($this->post, $name, $default, $filter);
672 672
     }
@@ -679,19 +679,19 @@  discard block
 block discarded – undo
679 679
      * @param string|array      $filter 过滤方法
680 680
      * @return mixed
681 681
      */
682
-    public function put($name = '', $default = null, $filter = '')
682
+    public function put($name='', $default=null, $filter='')
683 683
     {
684 684
         if (is_null($this->put)) {
685
-            $content = $this->input;
685
+            $content=$this->input;
686 686
             if (false !== strpos($this->contentType(), 'application/json')) {
687
-                $this->put = (array) json_decode($content, true);
687
+                $this->put=(array) json_decode($content, true);
688 688
             } else {
689 689
                 parse_str($content, $this->put);
690 690
             }
691 691
         }
692 692
         if (is_array($name)) {
693
-            $this->param      = [];
694
-            return $this->put = is_null($this->put) ? $name : array_merge($this->put, $name);
693
+            $this->param=[];
694
+            return $this->put=is_null($this->put) ? $name : array_merge($this->put, $name);
695 695
         }
696 696
 
697 697
         return $this->input($this->put, $name, $default, $filter);
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
      * @param string|array      $filter 过滤方法
706 706
      * @return mixed
707 707
      */
708
-    public function delete($name = '', $default = null, $filter = '')
708
+    public function delete($name='', $default=null, $filter='')
709 709
     {
710 710
         return $this->put($name, $default, $filter);
711 711
     }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
      * @param string|array      $filter 过滤方法
719 719
      * @return mixed
720 720
      */
721
-    public function patch($name = '', $default = null, $filter = '')
721
+    public function patch($name='', $default=null, $filter='')
722 722
     {
723 723
         return $this->put($name, $default, $filter);
724 724
     }
@@ -730,14 +730,14 @@  discard block
 block discarded – undo
730 730
      * @param string|array  $filter 过滤方法
731 731
      * @return mixed
732 732
      */
733
-    public function request($name = '', $default = null, $filter = '')
733
+    public function request($name='', $default=null, $filter='')
734 734
     {
735 735
         if (empty($this->request)) {
736
-            $this->request = $_REQUEST;
736
+            $this->request=$_REQUEST;
737 737
         }
738 738
         if (is_array($name)) {
739
-            $this->param          = [];
740
-            return $this->request = array_merge($this->request, $name);
739
+            $this->param=[];
740
+            return $this->request=array_merge($this->request, $name);
741 741
         }
742 742
         return $this->input($this->request, $name, $default, $filter);
743 743
     }
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
      * @param string|array  $filter 过滤方法
751 751
      * @return mixed
752 752
      */
753
-    public function session($name = '', $default = null, $filter = '')
753
+    public function session($name='', $default=null, $filter='')
754 754
     {
755 755
         if (empty($this->session)) {
756
-            $this->session = Session::get();
756
+            $this->session=Session::get();
757 757
         }
758 758
         if (is_array($name)) {
759
-            return $this->session = array_merge($this->session, $name);
759
+            return $this->session=array_merge($this->session, $name);
760 760
         }
761 761
         return $this->input($this->session, $name, $default, $filter);
762 762
     }
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
      * @param string|array  $filter 过滤方法
770 770
      * @return mixed
771 771
      */
772
-    public function cookie($name = '', $default = null, $filter = '')
772
+    public function cookie($name='', $default=null, $filter='')
773 773
     {
774 774
         if (empty($this->cookie)) {
775
-            $this->cookie = $_COOKIE;
775
+            $this->cookie=$_COOKIE;
776 776
         }
777 777
         if (is_array($name)) {
778
-            return $this->cookie = array_merge($this->cookie, $name);
778
+            return $this->cookie=array_merge($this->cookie, $name);
779 779
         }
780 780
         return $this->input($this->cookie, $name, $default, $filter);
781 781
     }
@@ -788,13 +788,13 @@  discard block
 block discarded – undo
788 788
      * @param string|array  $filter 过滤方法
789 789
      * @return mixed
790 790
      */
791
-    public function server($name = '', $default = null, $filter = '')
791
+    public function server($name='', $default=null, $filter='')
792 792
     {
793 793
         if (empty($this->server)) {
794
-            $this->server = $_SERVER;
794
+            $this->server=$_SERVER;
795 795
         }
796 796
         if (is_array($name)) {
797
-            return $this->server = array_merge($this->server, $name);
797
+            return $this->server=array_merge($this->server, $name);
798 798
         }
799 799
         return $this->input($this->server, false === $name ? false : strtoupper($name), $default, $filter);
800 800
     }
@@ -805,47 +805,47 @@  discard block
 block discarded – undo
805 805
      * @param string|array $name 名称
806 806
      * @return null|array|\think\File
807 807
      */
808
-    public function file($name = '')
808
+    public function file($name='')
809 809
     {
810 810
         if (empty($this->file)) {
811
-            $this->file = isset($_FILES) ? $_FILES : [];
811
+            $this->file=isset($_FILES) ? $_FILES : [];
812 812
         }
813 813
         if (is_array($name)) {
814
-            return $this->file = array_merge($this->file, $name);
814
+            return $this->file=array_merge($this->file, $name);
815 815
         }
816
-        $files = $this->file;
816
+        $files=$this->file;
817 817
         if (!empty($files)) {
818 818
             // 处理上传文件
819
-            $array = [];
819
+            $array=[];
820 820
             foreach ($files as $key => $file) {
821 821
                 if (is_array($file['name'])) {
822
-                    $item  = [];
823
-                    $keys  = array_keys($file);
824
-                    $count = count($file['name']);
825
-                    for ($i = 0; $i < $count; $i++) {
822
+                    $item=[];
823
+                    $keys=array_keys($file);
824
+                    $count=count($file['name']);
825
+                    for ($i=0; $i < $count; $i++) {
826 826
                         if (empty($file['tmp_name'][$i]) || !is_file($file['tmp_name'][$i])) {
827 827
                             continue;
828 828
                         }
829
-                        $temp['key'] = $key;
829
+                        $temp['key']=$key;
830 830
                         foreach ($keys as $_key) {
831
-                            $temp[$_key] = $file[$_key][$i];
831
+                            $temp[$_key]=$file[$_key][$i];
832 832
                         }
833
-                        $item[] = (new File($temp['tmp_name']))->setUploadInfo($temp);
833
+                        $item[]=(new File($temp['tmp_name']))->setUploadInfo($temp);
834 834
                     }
835
-                    $array[$key] = $item;
835
+                    $array[$key]=$item;
836 836
                 } else {
837 837
                     if ($file instanceof File) {
838
-                        $array[$key] = $file;
838
+                        $array[$key]=$file;
839 839
                     } else {
840 840
                         if (empty($file['tmp_name']) || !is_file($file['tmp_name'])) {
841 841
                             continue;
842 842
                         }
843
-                        $array[$key] = (new File($file['tmp_name']))->setUploadInfo($file);
843
+                        $array[$key]=(new File($file['tmp_name']))->setUploadInfo($file);
844 844
                     }
845 845
                 }
846 846
             }
847 847
             if (strpos($name, '.')) {
848
-                list($name, $sub) = explode('.', $name);
848
+                list($name, $sub)=explode('.', $name);
849 849
             }
850 850
             if ('' === $name) {
851 851
                 // 获取全部文件
@@ -866,13 +866,13 @@  discard block
 block discarded – undo
866 866
      * @param string|array  $filter 过滤方法
867 867
      * @return mixed
868 868
      */
869
-    public function env($name = '', $default = null, $filter = '')
869
+    public function env($name='', $default=null, $filter='')
870 870
     {
871 871
         if (empty($this->env)) {
872
-            $this->env = $_ENV;
872
+            $this->env=$_ENV;
873 873
         }
874 874
         if (is_array($name)) {
875
-            return $this->env = array_merge($this->env, $name);
875
+            return $this->env=array_merge($this->env, $name);
876 876
         }
877 877
         return $this->input($this->env, false === $name ? false : strtoupper($name), $default, $filter);
878 878
     }
@@ -884,36 +884,36 @@  discard block
 block discarded – undo
884 884
      * @param string        $default 默认值
885 885
      * @return string
886 886
      */
887
-    public function header($name = '', $default = null)
887
+    public function header($name='', $default=null)
888 888
     {
889 889
         if (empty($this->header)) {
890
-            $header = [];
891
-            if (function_exists('apache_request_headers') && $result = apache_request_headers()) {
892
-                $header = $result;
890
+            $header=[];
891
+            if (function_exists('apache_request_headers') && $result=apache_request_headers()) {
892
+                $header=$result;
893 893
             } else {
894
-                $server = $this->server ?: $_SERVER;
894
+                $server=$this->server ?: $_SERVER;
895 895
                 foreach ($server as $key => $val) {
896 896
                     if (0 === strpos($key, 'HTTP_')) {
897
-                        $key          = str_replace('_', '-', strtolower(substr($key, 5)));
898
-                        $header[$key] = $val;
897
+                        $key=str_replace('_', '-', strtolower(substr($key, 5)));
898
+                        $header[$key]=$val;
899 899
                     }
900 900
                 }
901 901
                 if (isset($server['CONTENT_TYPE'])) {
902
-                    $header['content-type'] = $server['CONTENT_TYPE'];
902
+                    $header['content-type']=$server['CONTENT_TYPE'];
903 903
                 }
904 904
                 if (isset($server['CONTENT_LENGTH'])) {
905
-                    $header['content-length'] = $server['CONTENT_LENGTH'];
905
+                    $header['content-length']=$server['CONTENT_LENGTH'];
906 906
                 }
907 907
             }
908
-            $this->header = array_change_key_case($header);
908
+            $this->header=array_change_key_case($header);
909 909
         }
910 910
         if (is_array($name)) {
911
-            return $this->header = array_merge($this->header, $name);
911
+            return $this->header=array_merge($this->header, $name);
912 912
         }
913 913
         if ('' === $name) {
914 914
             return $this->header;
915 915
         }
916
-        $name = str_replace('_', '-', strtolower($name));
916
+        $name=str_replace('_', '-', strtolower($name));
917 917
         return isset($this->header[$name]) ? $this->header[$name] : $default;
918 918
     }
919 919
 
@@ -925,24 +925,24 @@  discard block
 block discarded – undo
925 925
      * @param string|array  $filter 过滤函数
926 926
      * @return mixed
927 927
      */
928
-    public function input($data = [], $name = '', $default = null, $filter = '')
928
+    public function input($data=[], $name='', $default=null, $filter='')
929 929
     {
930 930
         if (false === $name) {
931 931
             // 获取原始数据
932 932
             return $data;
933 933
         }
934
-        $name = (string) $name;
934
+        $name=(string) $name;
935 935
         if ('' != $name) {
936 936
             // 解析name
937 937
             if (strpos($name, '/')) {
938
-                list($name, $type) = explode('/', $name);
938
+                list($name, $type)=explode('/', $name);
939 939
             } else {
940
-                $type = 's';
940
+                $type='s';
941 941
             }
942 942
             // 按.拆分成多维数组进行判断
943 943
             foreach (explode('.', $name) as $val) {
944 944
                 if (isset($data[$val])) {
945
-                    $data = $data[$val];
945
+                    $data=$data[$val];
946 946
                 } else {
947 947
                     // 无输入数据,返回默认值
948 948
                     return $default;
@@ -955,17 +955,17 @@  discard block
 block discarded – undo
955 955
 
956 956
         // 解析过滤器
957 957
         if (is_null($filter)) {
958
-            $filter = [];
958
+            $filter=[];
959 959
         } else {
960
-            $filter = $filter ?: $this->filter;
960
+            $filter=$filter ?: $this->filter;
961 961
             if (is_string($filter)) {
962
-                $filter = explode(',', $filter);
962
+                $filter=explode(',', $filter);
963 963
             } else {
964
-                $filter = (array) $filter;
964
+                $filter=(array) $filter;
965 965
             }
966 966
         }
967 967
 
968
-        $filter[] = $default;
968
+        $filter[]=$default;
969 969
         if (is_array($data)) {
970 970
             array_walk_recursive($data, [$this, 'filterValue'], $filter);
971 971
             reset($data);
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
      * @param mixed $filter 过滤规则
986 986
      * @return mixed
987 987
      */
988
-    public function filter($filter = null)
988
+    public function filter($filter=null)
989 989
     {
990 990
         if (is_null($filter)) {
991 991
             return $this->filter;
992 992
         } else {
993
-            $this->filter = $filter;
993
+            $this->filter=$filter;
994 994
         }
995 995
     }
996 996
 
@@ -1003,25 +1003,25 @@  discard block
 block discarded – undo
1003 1003
      */
1004 1004
     private function filterValue(&$value, $key, $filters)
1005 1005
     {
1006
-        $default = array_pop($filters);
1006
+        $default=array_pop($filters);
1007 1007
         foreach ($filters as $filter) {
1008 1008
             if (is_callable($filter)) {
1009 1009
                 // 调用函数或者方法过滤
1010
-                $value = call_user_func($filter, $value);
1010
+                $value=call_user_func($filter, $value);
1011 1011
             } elseif (is_scalar($value)) {
1012 1012
                 if (strpos($filter, '/')) {
1013 1013
                     // 正则过滤
1014 1014
                     if (!preg_match($filter, $value)) {
1015 1015
                         // 匹配不成功返回默认值
1016
-                        $value = $default;
1016
+                        $value=$default;
1017 1017
                         break;
1018 1018
                     }
1019 1019
                 } elseif (!empty($filter)) {
1020 1020
                     // filter函数不存在时, 则使用filter_var进行过滤
1021 1021
                     // filter为非整形值时, 调用filter_id取得过滤id
1022
-                    $value = filter_var($value, is_int($filter) ? $filter : filter_id($filter));
1022
+                    $value=filter_var($value, is_int($filter) ? $filter : filter_id($filter));
1023 1023
                     if (false === $value) {
1024
-                        $value = $default;
1024
+                        $value=$default;
1025 1025
                         break;
1026 1026
                     }
1027 1027
                 }
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
     {
1040 1040
         // 过滤查询特殊字符
1041 1041
         if (is_string($value) && preg_match('/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOTIN|NOT IN|IN)$/i', $value)) {
1042
-            $value .= ' ';
1042
+            $value.=' ';
1043 1043
         }
1044 1044
         // TODO 其他安全过滤
1045 1045
     }
@@ -1055,27 +1055,27 @@  discard block
 block discarded – undo
1055 1055
         switch (strtolower($type)) {
1056 1056
             // 数组
1057 1057
             case 'a':
1058
-                $data = (array) $data;
1058
+                $data=(array) $data;
1059 1059
                 break;
1060 1060
             // 数字
1061 1061
             case 'd':
1062
-                $data = (int) $data;
1062
+                $data=(int) $data;
1063 1063
                 break;
1064 1064
             // 浮点
1065 1065
             case 'f':
1066
-                $data = (float) $data;
1066
+                $data=(float) $data;
1067 1067
                 break;
1068 1068
             // 布尔
1069 1069
             case 'b':
1070
-                $data = (boolean) $data;
1070
+                $data=(boolean) $data;
1071 1071
                 break;
1072 1072
             // 字符串
1073 1073
             case 's':
1074 1074
             default:
1075 1075
                 if (is_scalar($data)) {
1076
-                    $data = (string) $data;
1076
+                    $data=(string) $data;
1077 1077
                 } else {
1078
-                    throw new \InvalidArgumentException('variable type error:' . gettype($data));
1078
+                    throw new \InvalidArgumentException('variable type error:'.gettype($data));
1079 1079
                 }
1080 1080
         }
1081 1081
     }
@@ -1088,17 +1088,17 @@  discard block
 block discarded – undo
1088 1088
      * @param bool      $checkEmpty 是否检测空值
1089 1089
      * @return mixed
1090 1090
      */
1091
-    public function has($name, $type = 'param', $checkEmpty = false)
1091
+    public function has($name, $type='param', $checkEmpty=false)
1092 1092
     {
1093 1093
         if (empty($this->$type)) {
1094
-            $param = $this->$type();
1094
+            $param=$this->$type();
1095 1095
         } else {
1096
-            $param = $this->$type;
1096
+            $param=$this->$type;
1097 1097
         }
1098 1098
         // 按.拆分成多维数组进行判断
1099 1099
         foreach (explode('.', $name) as $val) {
1100 1100
             if (isset($param[$val])) {
1101
-                $param = $param[$val];
1101
+                $param=$param[$val];
1102 1102
             } else {
1103 1103
                 return false;
1104 1104
             }
@@ -1113,16 +1113,16 @@  discard block
 block discarded – undo
1113 1113
      * @param string        $type 变量类型
1114 1114
      * @return mixed
1115 1115
      */
1116
-    public function only($name, $type = 'param')
1116
+    public function only($name, $type='param')
1117 1117
     {
1118
-        $param = $this->$type();
1118
+        $param=$this->$type();
1119 1119
         if (is_string($name)) {
1120
-            $name = explode(',', $name);
1120
+            $name=explode(',', $name);
1121 1121
         }
1122
-        $item = [];
1122
+        $item=[];
1123 1123
         foreach ($name as $key) {
1124 1124
             if (isset($param[$key])) {
1125
-                $item[$key] = $param[$key];
1125
+                $item[$key]=$param[$key];
1126 1126
             }
1127 1127
         }
1128 1128
         return $item;
@@ -1135,11 +1135,11 @@  discard block
 block discarded – undo
1135 1135
      * @param string        $type 变量类型
1136 1136
      * @return mixed
1137 1137
      */
1138
-    public function except($name, $type = 'param')
1138
+    public function except($name, $type='param')
1139 1139
     {
1140
-        $param = $this->$type();
1140
+        $param=$this->$type();
1141 1141
         if (is_string($name)) {
1142
-            $name = explode(',', $name);
1142
+            $name=explode(',', $name);
1143 1143
         }
1144 1144
         foreach ($name as $key) {
1145 1145
             if (isset($param[$key])) {
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
      */
1157 1157
     public function isSsl()
1158 1158
     {
1159
-        $server = array_merge($_SERVER, $this->server);
1159
+        $server=array_merge($_SERVER, $this->server);
1160 1160
         if (isset($server['HTTPS']) && ('1' == $server['HTTPS'] || 'on' == strtolower($server['HTTPS']))) {
1161 1161
             return true;
1162 1162
         } elseif (isset($server['REQUEST_SCHEME']) && 'https' == $server['REQUEST_SCHEME']) {
@@ -1175,10 +1175,10 @@  discard block
 block discarded – undo
1175 1175
      * @param bool $ajax  true 获取原始ajax请求
1176 1176
      * @return bool
1177 1177
      */
1178
-    public function isAjax($ajax = false)
1178
+    public function isAjax($ajax=false)
1179 1179
     {
1180
-        $value  = $this->server('HTTP_X_REQUESTED_WITH', '', 'strtolower');
1181
-        $result = ('xmlhttprequest' == $value) ? true : false;
1180
+        $value=$this->server('HTTP_X_REQUESTED_WITH', '', 'strtolower');
1181
+        $result=('xmlhttprequest' == $value) ? true : false;
1182 1182
         if (true === $ajax) {
1183 1183
             return $result;
1184 1184
         } else {
@@ -1192,9 +1192,9 @@  discard block
 block discarded – undo
1192 1192
      * @param bool $pjax  true 获取原始pjax请求
1193 1193
      * @return bool
1194 1194
      */
1195
-    public function isPjax($pjax = false)
1195
+    public function isPjax($pjax=false)
1196 1196
     {
1197
-        $result = !is_null($this->server('HTTP_X_PJAX')) ? true : false;
1197
+        $result=!is_null($this->server('HTTP_X_PJAX')) ? true : false;
1198 1198
         if (true === $pjax) {
1199 1199
             return $result;
1200 1200
         } else {
@@ -1208,33 +1208,33 @@  discard block
 block discarded – undo
1208 1208
      * @param boolean   $adv 是否进行高级模式获取(有可能被伪装)
1209 1209
      * @return mixed
1210 1210
      */
1211
-    public function ip($type = 0, $adv = false)
1211
+    public function ip($type=0, $adv=false)
1212 1212
     {
1213
-        $type      = $type ? 1 : 0;
1214
-        static $ip = null;
1213
+        $type=$type ? 1 : 0;
1214
+        static $ip=null;
1215 1215
         if (null !== $ip) {
1216 1216
             return $ip[$type];
1217 1217
         }
1218 1218
 
1219 1219
         if ($adv) {
1220 1220
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
1221
-                $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
1222
-                $pos = array_search('unknown', $arr);
1221
+                $arr=explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
1222
+                $pos=array_search('unknown', $arr);
1223 1223
                 if (false !== $pos) {
1224 1224
                     unset($arr[$pos]);
1225 1225
                 }
1226
-                $ip = trim(current($arr));
1226
+                $ip=trim(current($arr));
1227 1227
             } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
1228
-                $ip = $_SERVER['HTTP_CLIENT_IP'];
1228
+                $ip=$_SERVER['HTTP_CLIENT_IP'];
1229 1229
             } elseif (isset($_SERVER['REMOTE_ADDR'])) {
1230
-                $ip = $_SERVER['REMOTE_ADDR'];
1230
+                $ip=$_SERVER['REMOTE_ADDR'];
1231 1231
             }
1232 1232
         } elseif (isset($_SERVER['REMOTE_ADDR'])) {
1233
-            $ip = $_SERVER['REMOTE_ADDR'];
1233
+            $ip=$_SERVER['REMOTE_ADDR'];
1234 1234
         }
1235 1235
         // IP地址合法验证
1236
-        $long = sprintf("%u", ip2long($ip));
1237
-        $ip   = $long ? [$ip, $long] : ['0.0.0.0', 0];
1236
+        $long=sprintf("%u", ip2long($ip));
1237
+        $ip=$long ? [$ip, $long] : ['0.0.0.0', 0];
1238 1238
         return $ip[$type];
1239 1239
     }
1240 1240
 
@@ -1325,12 +1325,12 @@  discard block
 block discarded – undo
1325 1325
      */
1326 1326
     public function contentType()
1327 1327
     {
1328
-        $contentType = $this->server('CONTENT_TYPE');
1328
+        $contentType=$this->server('CONTENT_TYPE');
1329 1329
         if ($contentType) {
1330 1330
             if (strpos($contentType, ';')) {
1331
-                list($type) = explode(';', $contentType);
1331
+                list($type)=explode(';', $contentType);
1332 1332
             } else {
1333
-                $type = $contentType;
1333
+                $type=$contentType;
1334 1334
             }
1335 1335
             return trim($type);
1336 1336
         }
@@ -1343,10 +1343,10 @@  discard block
 block discarded – undo
1343 1343
      * @param array $route 路由名称
1344 1344
      * @return array
1345 1345
      */
1346
-    public function routeInfo($route = [])
1346
+    public function routeInfo($route=[])
1347 1347
     {
1348 1348
         if (!empty($route)) {
1349
-            $this->routeInfo = $route;
1349
+            $this->routeInfo=$route;
1350 1350
         } else {
1351 1351
             return $this->routeInfo;
1352 1352
         }
@@ -1358,10 +1358,10 @@  discard block
 block discarded – undo
1358 1358
      * @param array  $dispatch 调度信息
1359 1359
      * @return array
1360 1360
      */
1361
-    public function dispatch($dispatch = null)
1361
+    public function dispatch($dispatch=null)
1362 1362
     {
1363 1363
         if (!is_null($dispatch)) {
1364
-            $this->dispatch = $dispatch;
1364
+            $this->dispatch=$dispatch;
1365 1365
         }
1366 1366
         return $this->dispatch;
1367 1367
     }
@@ -1372,10 +1372,10 @@  discard block
 block discarded – undo
1372 1372
      * @param string $module 模块名
1373 1373
      * @return string|Request
1374 1374
      */
1375
-    public function module($module = null)
1375
+    public function module($module=null)
1376 1376
     {
1377 1377
         if (!is_null($module)) {
1378
-            $this->module = $module;
1378
+            $this->module=$module;
1379 1379
             return $this;
1380 1380
         } else {
1381 1381
             return $this->module ?: '';
@@ -1388,10 +1388,10 @@  discard block
 block discarded – undo
1388 1388
      * @param string $controller 控制器名
1389 1389
      * @return string|Request
1390 1390
      */
1391
-    public function controller($controller = null)
1391
+    public function controller($controller=null)
1392 1392
     {
1393 1393
         if (!is_null($controller)) {
1394
-            $this->controller = $controller;
1394
+            $this->controller=$controller;
1395 1395
             return $this;
1396 1396
         } else {
1397 1397
             return $this->controller ?: '';
@@ -1404,10 +1404,10 @@  discard block
 block discarded – undo
1404 1404
      * @param string $action 操作名
1405 1405
      * @return string|Request
1406 1406
      */
1407
-    public function action($action = null)
1407
+    public function action($action=null)
1408 1408
     {
1409 1409
         if (!is_null($action)) {
1410
-            $this->action = $action;
1410
+            $this->action=$action;
1411 1411
             return $this;
1412 1412
         } else {
1413 1413
             return $this->action ?: '';
@@ -1420,10 +1420,10 @@  discard block
 block discarded – undo
1420 1420
      * @param string $lang 语言名
1421 1421
      * @return string|Request
1422 1422
      */
1423
-    public function langset($lang = null)
1423
+    public function langset($lang=null)
1424 1424
     {
1425 1425
         if (!is_null($lang)) {
1426
-            $this->langset = $lang;
1426
+            $this->langset=$lang;
1427 1427
             return $this;
1428 1428
         } else {
1429 1429
             return $this->langset ?: '';
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
     public function getContent()
1439 1439
     {
1440 1440
         if (is_null($this->content)) {
1441
-            $this->content = $this->input;
1441
+            $this->content=$this->input;
1442 1442
         }
1443 1443
         return $this->content;
1444 1444
     }
@@ -1460,12 +1460,12 @@  discard block
 block discarded – undo
1460 1460
      * @param mixed  $type 令牌生成方法
1461 1461
      * @return string
1462 1462
      */
1463
-    public function token($name = '__token__', $type = 'md5')
1463
+    public function token($name='__token__', $type='md5')
1464 1464
     {
1465
-        $type  = is_callable($type) ? $type : 'md5';
1466
-        $token = call_user_func($type, $_SERVER['REQUEST_TIME_FLOAT']);
1465
+        $type=is_callable($type) ? $type : 'md5';
1466
+        $token=call_user_func($type, $_SERVER['REQUEST_TIME_FLOAT']);
1467 1467
         if ($this->isAjax()) {
1468
-            header($name . ': ' . $token);
1468
+            header($name.': '.$token);
1469 1469
         }
1470 1470
         Session::set($name, $token);
1471 1471
         return $token;
@@ -1479,17 +1479,17 @@  discard block
 block discarded – undo
1479 1479
      * @param array  $except 缓存排除
1480 1480
      * @return void
1481 1481
      */
1482
-    public function cache($key, $expire = null, $except = [])
1482
+    public function cache($key, $expire=null, $except=[])
1483 1483
     {
1484 1484
         if (false !== $key && $this->isGet() && !$this->isCheckCache) {
1485 1485
             // 标记请求缓存检查
1486
-            $this->isCheckCache = true;
1486
+            $this->isCheckCache=true;
1487 1487
             if (false === $expire) {
1488 1488
                 // 关闭当前缓存
1489 1489
                 return;
1490 1490
             }
1491 1491
             if ($key instanceof \Closure) {
1492
-                $key = call_user_func_array($key, [$this]);
1492
+                $key=call_user_func_array($key, [$this]);
1493 1493
             } elseif (true === $key) {
1494 1494
                 foreach ($except as $rule) {
1495 1495
                     if (0 === strpos($this->url(), $rule)) {
@@ -1497,44 +1497,44 @@  discard block
 block discarded – undo
1497 1497
                     }
1498 1498
                 }
1499 1499
                 // 自动缓存功能
1500
-                $key = md5($this->host()) . '__URL__';
1500
+                $key=md5($this->host()).'__URL__';
1501 1501
             } elseif (strpos($key, '|')) {
1502
-                list($key, $fun) = explode('|', $key);
1502
+                list($key, $fun)=explode('|', $key);
1503 1503
             }
1504 1504
             // 特殊规则替换
1505 1505
             if (false !== strpos($key, '__')) {
1506
-                $key = str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__', ''], [$this->module, $this->controller, $this->action, md5($this->url())], $key);
1506
+                $key=str_replace(['__MODULE__', '__CONTROLLER__', '__ACTION__', '__URL__', ''], [$this->module, $this->controller, $this->action, md5($this->url())], $key);
1507 1507
             }
1508 1508
 
1509 1509
             if (false !== strpos($key, ':')) {
1510
-                $param = $this->param();
1510
+                $param=$this->param();
1511 1511
                 foreach ($param as $item => $val) {
1512
-                    if (is_string($val) && false !== strpos($key, ':' . $item)) {
1513
-                        $key = str_replace(':' . $item, $val, $key);
1512
+                    if (is_string($val) && false !== strpos($key, ':'.$item)) {
1513
+                        $key=str_replace(':'.$item, $val, $key);
1514 1514
                     }
1515 1515
                 }
1516 1516
             } elseif (strpos($key, ']')) {
1517
-                if ('[' . $this->ext() . ']' == $key) {
1517
+                if ('['.$this->ext().']' == $key) {
1518 1518
                     // 缓存某个后缀的请求
1519
-                    $key = md5($this->url());
1519
+                    $key=md5($this->url());
1520 1520
                 } else {
1521 1521
                     return;
1522 1522
                 }
1523 1523
             }
1524 1524
             if (isset($fun)) {
1525
-                $key = $fun($key);
1525
+                $key=$fun($key);
1526 1526
             }
1527 1527
 
1528 1528
             if (strtotime($this->server('HTTP_IF_MODIFIED_SINCE')) + $expire > $_SERVER['REQUEST_TIME']) {
1529 1529
                 // 读取缓存
1530
-                $response = Response::create()->code(304);
1530
+                $response=Response::create()->code(304);
1531 1531
                 throw new \think\exception\HttpResponseException($response);
1532 1532
             } elseif (Cache::has($key)) {
1533
-                list($content, $header) = Cache::get($key);
1534
-                $response               = Response::create($content)->header($header);
1533
+                list($content, $header)=Cache::get($key);
1534
+                $response=Response::create($content)->header($header);
1535 1535
                 throw new \think\exception\HttpResponseException($response);
1536 1536
             } else {
1537
-                $this->cache = [$key, $expire];
1537
+                $this->cache=[$key, $expire];
1538 1538
             }
1539 1539
         }
1540 1540
     }
@@ -1556,12 +1556,12 @@  discard block
 block discarded – undo
1556 1556
      * @param mixed  $obj 绑定的对象实例
1557 1557
      * @return mixed
1558 1558
      */
1559
-    public function bind($name, $obj = null)
1559
+    public function bind($name, $obj=null)
1560 1560
     {
1561 1561
         if (is_array($name)) {
1562
-            $this->bind = array_merge($this->bind, $name);
1562
+            $this->bind=array_merge($this->bind, $name);
1563 1563
         } else {
1564
-            $this->bind[$name] = $obj;
1564
+            $this->bind[$name]=$obj;
1565 1565
         }
1566 1566
     }
1567 1567
 
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 
1573 1573
     public function __set($name, $value)
1574 1574
     {
1575
-        $this->bind[$name] = $value;
1575
+        $this->bind[$name]=$value;
1576 1576
     }
1577 1577
 
1578 1578
     public function __get($name)
Please login to merge, or discard this patch.
core/tools/Arr.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -260,7 +260,7 @@
 block discarded – undo
260 260
      * Check if an item or items exist in an array using "dot" notation.
261 261
      *
262 262
      * @param  \ArrayAccess|array $array
263
-     * @param  string|array $keys
263
+     * @param  string $keys
264 264
      * @return bool
265 265
      */
266 266
     public static function has($array, $keys) {
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
      * @return array
43 43
      */
44 44
     public static function collapse($array) {
45
-        $results = [];
45
+        $results=[];
46 46
 
47 47
         foreach ($array as $values) {
48 48
             if ($values instanceof Collection) {
49
-                $values = $values->all();
49
+                $values=$values->all();
50 50
             } elseif (!is_array($values)) {
51 51
                 continue;
52 52
             }
53 53
 
54
-            $results = array_merge($results, $values);
54
+            $results=array_merge($results, $values);
55 55
         }
56 56
 
57 57
         return $results;
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
      * @param  string $prepend
75 75
      * @return array
76 76
      */
77
-    public static function dot($array, $prepend = '') {
78
-        $results = [];
77
+    public static function dot($array, $prepend='') {
78
+        $results=[];
79 79
 
80 80
         foreach ($array as $key => $value) {
81 81
             if (is_array($value) && !empty($value)) {
82
-                $results = array_merge($results, static::dot($value, $prepend . $key . '.'));
82
+                $results=array_merge($results, static::dot($value, $prepend.$key.'.'));
83 83
             } else {
84
-                $results[$prepend . $key] = $value;
84
+                $results[$prepend.$key]=$value;
85 85
             }
86 86
         }
87 87
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @param  mixed $default
125 125
      * @return mixed
126 126
      */
127
-    public static function first($array, callable $callback = null, $default = null) {
127
+    public static function first($array, callable $callback=null, $default=null) {
128 128
         if (is_null($callback)) {
129 129
             if (empty($array)) {
130 130
                 return value($default);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      * @param  mixed $default
153 153
      * @return mixed
154 154
      */
155
-    public static function last($array, callable $callback = null, $default = null) {
155
+    public static function last($array, callable $callback=null, $default=null) {
156 156
         if (is_null($callback)) {
157 157
             return empty($array) ? value($default) : end($array);
158 158
         }
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
      * @param  int $depth
168 168
      * @return array
169 169
      */
170
-    public static function flatten($array, $depth = INF) {
171
-        return array_reduce($array, function ($result, $item) use ($depth) {
172
-            $item = $item instanceof Collection ? $item->all() : $item;
170
+    public static function flatten($array, $depth=INF) {
171
+        return array_reduce($array, function($result, $item) use ($depth) {
172
+            $item=$item instanceof Collection ? $item->all() : $item;
173 173
 
174 174
             if (!is_array($item)) {
175 175
                 return array_merge($result, [$item]);
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
      * @return void
190 190
      */
191 191
     public static function forget(&$array, $keys) {
192
-        $original = &$array;
192
+        $original=&$array;
193 193
 
194
-        $keys = (array)$keys;
194
+        $keys=(array) $keys;
195 195
 
196 196
         if (count($keys) === 0) {
197 197
             return;
@@ -205,16 +205,16 @@  discard block
 block discarded – undo
205 205
                 continue;
206 206
             }
207 207
 
208
-            $parts = explode('.', $key);
208
+            $parts=explode('.', $key);
209 209
 
210 210
             // clean up before each pass
211
-            $array = &$original;
211
+            $array=&$original;
212 212
 
213 213
             while (count($parts) > 1) {
214
-                $part = array_shift($parts);
214
+                $part=array_shift($parts);
215 215
 
216 216
                 if (isset($array[$part]) && is_array($array[$part])) {
217
-                    $array = &$array[$part];
217
+                    $array=&$array[$part];
218 218
                 } else {
219 219
                     continue 2;
220 220
                 }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      * @param  mixed $default
233 233
      * @return mixed
234 234
      */
235
-    public static function get($array, $key, $default = null) {
235
+    public static function get($array, $key, $default=null) {
236 236
         if (!static::accessible($array)) {
237 237
             return value($default);
238 238
         }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
         foreach (explode('.', $key) as $segment) {
249 249
             if (static::accessible($array) && static::exists($array, $segment)) {
250
-                $array = $array[$segment];
250
+                $array=$array[$segment];
251 251
             } else {
252 252
                 return value($default);
253 253
             }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
             return false;
269 269
         }
270 270
 
271
-        $keys = (array)$keys;
271
+        $keys=(array) $keys;
272 272
 
273 273
         if (!$array) {
274 274
             return false;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         foreach ($keys as $key) {
282
-            $subKeyArray = $array;
282
+            $subKeyArray=$array;
283 283
 
284 284
             if (static::exists($array, $key)) {
285 285
                 continue;
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
             foreach (explode('.', $key) as $segment) {
289 289
                 if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) {
290
-                    $subKeyArray = $subKeyArray[$segment];
290
+                    $subKeyArray=$subKeyArray[$segment];
291 291
                 } else {
292 292
                     return false;
293 293
                 }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      * @return bool
307 307
      */
308 308
     public static function isAssoc(array $array) {
309
-        $keys = array_keys($array);
309
+        $keys=array_keys($array);
310 310
 
311 311
         return array_keys($keys) !== $keys;
312 312
     }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
      * @return array
320 320
      */
321 321
     public static function only($array, $keys) {
322
-        return array_intersect_key($array, array_flip((array)$keys));
322
+        return array_intersect_key($array, array_flip((array) $keys));
323 323
     }
324 324
 
325 325
     /**
@@ -330,23 +330,23 @@  discard block
 block discarded – undo
330 330
      * @param  string|array|null $key
331 331
      * @return array
332 332
      */
333
-    public static function pluck($array, $value, $key = null) {
334
-        $results = [];
333
+    public static function pluck($array, $value, $key=null) {
334
+        $results=[];
335 335
 
336
-        list($value, $key) = static::explodePluckParameters($value, $key);
336
+        list($value, $key)=static::explodePluckParameters($value, $key);
337 337
 
338 338
         foreach ($array as $item) {
339
-            $itemValue = data_get($item, $value);
339
+            $itemValue=data_get($item, $value);
340 340
 
341 341
             // If the key is "null", we will just append the value to the array and keep
342 342
             // looping. Otherwise we will key the array using the value of the key we
343 343
             // received from the developer. Then we'll return the final array form.
344 344
             if (is_null($key)) {
345
-                $results[] = $itemValue;
345
+                $results[]=$itemValue;
346 346
             } else {
347
-                $itemKey = data_get($item, $key);
347
+                $itemKey=data_get($item, $key);
348 348
 
349
-                $results[$itemKey] = $itemValue;
349
+                $results[$itemKey]=$itemValue;
350 350
             }
351 351
         }
352 352
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
      * @return array
362 362
      */
363 363
     protected static function explodePluckParameters($value, $key) {
364
-        $value = is_string($value) ? explode('.', $value) : $value;
364
+        $value=is_string($value) ? explode('.', $value) : $value;
365 365
 
366
-        $key = is_null($key) || is_array($key) ? $key : explode('.', $key);
366
+        $key=is_null($key) || is_array($key) ? $key : explode('.', $key);
367 367
 
368 368
         return [$value, $key];
369 369
     }
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
      * @param  mixed $key
377 377
      * @return array
378 378
      */
379
-    public static function prepend($array, $value, $key = null) {
379
+    public static function prepend($array, $value, $key=null) {
380 380
         if (is_null($key)) {
381 381
             array_unshift($array, $value);
382 382
         } else {
383
-            $array = [$key => $value] + $array;
383
+            $array=[$key => $value] + $array;
384 384
         }
385 385
 
386 386
         return $array;
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
      * @param  mixed $default
395 395
      * @return mixed
396 396
      */
397
-    public static function pull(&$array, $key, $default = null) {
398
-        $value = static::get($array, $key, $default);
397
+    public static function pull(&$array, $key, $default=null) {
398
+        $value=static::get($array, $key, $default);
399 399
 
400 400
         static::forget($array, $key);
401 401
 
@@ -414,25 +414,25 @@  discard block
 block discarded – undo
414 414
      */
415 415
     public static function set(&$array, $key, $value) {
416 416
         if (is_null($key)) {
417
-            return $array = $value;
417
+            return $array=$value;
418 418
         }
419 419
 
420
-        $keys = explode('.', $key);
420
+        $keys=explode('.', $key);
421 421
 
422 422
         while (count($keys) > 1) {
423
-            $key = array_shift($keys);
423
+            $key=array_shift($keys);
424 424
 
425 425
             // If the key doesn't exist at this depth, we will just create an empty array
426 426
             // to hold the next value, allowing us to create the arrays to hold final
427 427
             // values at the correct depth. Then we'll keep digging into the array.
428 428
             if (!isset($array[$key]) || !is_array($array[$key])) {
429
-                $array[$key] = [];
429
+                $array[$key]=[];
430 430
             }
431 431
 
432
-            $array = &$array[$key];
432
+            $array=&$array[$key];
433 433
         }
434 434
 
435
-        $array[array_shift($keys)] = $value;
435
+        $array[array_shift($keys)]=$value;
436 436
 
437 437
         return $array;
438 438
     }
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
     public static function sortRecursive($array) {
470 470
         foreach ($array as &$value) {
471 471
             if (is_array($value)) {
472
-                $value = static::sortRecursive($value);
472
+                $value=static::sortRecursive($value);
473 473
             }
474 474
         }
475 475
 
Please login to merge, or discard this patch.
function.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -462,7 +462,7 @@
 block discarded – undo
462 462
      * 获取环境变量
463 463
      *
464 464
      * @param  string  $key
465
-     * @param  mixed   $default
465
+     * @param  string|false   $default
466 466
      * @return mixed
467 467
      */
468 468
     function env($key, $default = null)
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
     // 过滤查询特殊字符
410 410
     if (preg_match('/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOTIN|NOT IN|IN)$/i', $value)) {
411
-        $value .= ' ';
411
+        $value.=' ';
412 412
     }
413 413
 }
414 414
 /**
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
  *
417 417
  * @return string|null
418 418
  */
419
-function config($name=null,$value=null,$default=null){
419
+function config($name=null, $value=null, $default=null) {
420 420
     $config=\puck\Conf::load();
421
-    if ($name===null){
421
+    if ($name === null) {
422 422
         return $config->all();
423 423
     }
424
-    if ($value===null){
425
-        return $config->get($name,$default);
424
+    if ($value === null) {
425
+        return $config->get($name, $default);
426 426
     }
427
-    $config->set($name,$value);
427
+    $config->set($name, $value);
428 428
 }
429 429
 /**
430 430
  * 字符串命名风格转换
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
     }
442 442
 }
443 443
 
444
-if (! function_exists('app')) {
444
+if (!function_exists('app')) {
445 445
     /**
446 446
      * 获取容器实例
447 447
      *
448 448
      * @param  string  $make
449 449
      * @return mixed|\puck\App
450 450
      */
451
-    function app($make = null)
451
+    function app($make=null)
452 452
     {
453 453
         if (is_null($make)) {
454 454
             return Container::getInstance();
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
     }
458 458
 }
459 459
 
460
-if (! function_exists('env')) {
460
+if (!function_exists('env')) {
461 461
     /**
462 462
      * 获取环境变量
463 463
      *
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
      * @param  mixed   $default
466 466
      * @return mixed
467 467
      */
468
-    function env($key, $default = null)
468
+    function env($key, $default=null)
469 469
     {
470
-        $value = getenv($key);
470
+        $value=getenv($key);
471 471
         if ($value === false) {
472 472
             return value($default);
473 473
         }
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
         return $value;
492 492
     }
493 493
 }
494
-if (! function_exists('value')) {
494
+if (!function_exists('value')) {
495 495
     /**
496 496
      * 返回给定的表达式的结果
497 497
      *
Please login to merge, or discard this patch.
core/Route.php 2 patches
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,18 +9,18 @@  discard block
 block discarded – undo
9 9
     private $request;
10 10
 
11 11
     public function __construct(Request $request) {
12
-        $this->request = $request;
13
-        $this->errorCallback=function (){
12
+        $this->request=$request;
13
+        $this->errorCallback=function() {
14 14
             die("404");
15 15
         };
16 16
     }
17 17
 
18
-    public static $halts = false;
19
-    private $routes = array();
20
-    private $regexRoutes = [];
21
-    public static $methods = array();
22
-    public static $callbacks = array();
23
-    private $patterns = array(
18
+    public static $halts=false;
19
+    private $routes=array();
20
+    private $regexRoutes=[];
21
+    public static $methods=array();
22
+    public static $callbacks=array();
23
+    private $patterns=array(
24 24
         ':any' => '[^/]+',
25 25
         ':num' => '[0-9]+',
26 26
         ':all' => '.*'
@@ -41,29 +41,29 @@  discard block
 block discarded – undo
41 41
      * @param mixed $callBack
42 42
      */
43 43
     public function addRoute($method, $uri, $callBack) {
44
-        $method = strtoupper($method);
44
+        $method=strtoupper($method);
45 45
         //预定义正则路由
46 46
         if (strpos($uri, ':') !== false) {
47
-            $searches = array_keys($this->patterns);
48
-            $replaces = array_values($this->patterns);
49
-            $uri = str_replace($searches, $replaces, $uri);
50
-            $this->regexRoutes[] = [
47
+            $searches=array_keys($this->patterns);
48
+            $replaces=array_values($this->patterns);
49
+            $uri=str_replace($searches, $replaces, $uri);
50
+            $this->regexRoutes[]=[
51 51
                 'method' => $method,
52
-                'regex' => '#^' . $uri . '$#',
52
+                'regex' => '#^'.$uri.'$#',
53 53
                 'callback' => $callBack
54 54
             ];
55 55
         } //自定义正则路由
56 56
         elseif ($uri[0] == '#'
57 57
             || (strlen($uri) > 2 && tools\Str::endsWith($uri, '/') && tools\Str::startsWith($uri, '/'))
58 58
         ) {
59
-            $this->regexRoutes[] = [
59
+            $this->regexRoutes[]=[
60 60
                 'method' => $method,
61 61
                 'regex' => $uri,
62 62
                 'callback' => $callBack
63 63
             ];
64 64
         } //直接定义的路由
65 65
         else {
66
-            $this->routes[$method . $uri] = [
66
+            $this->routes[$method.$uri]=[
67 67
                 'method' => $method,
68 68
                 'uri' => $uri,
69 69
                 'callback' => $callBack
@@ -75,25 +75,25 @@  discard block
 block discarded – undo
75 75
      * Defines callback if route is not found
76 76
      */
77 77
     public function error($callback) {
78
-        $this->errorCallback = $callback;
78
+        $this->errorCallback=$callback;
79 79
     }
80 80
 
81
-    public static function haltOnMatch($flag = true) {
82
-        self::$halts = $flag;
81
+    public static function haltOnMatch($flag=true) {
82
+        self::$halts=$flag;
83 83
     }
84 84
 
85 85
 
86
-    private function foundRoute($route, $param = []) {
86
+    private function foundRoute($route, $param=[]) {
87 87
         try {
88 88
             if ($route['callback'] instanceof \Closure) {
89
-                app()->invokeFunction($route['callback'],$param);
89
+                app()->invokeFunction($route['callback'], $param);
90 90
             } else {
91 91
                 // Grab all parts based on a / separator
92
-                $parts = explode('/', $route['callback']);
92
+                $parts=explode('/', $route['callback']);
93 93
                 // Collect the last index of the array
94
-                $last = end($parts);
94
+                $last=end($parts);
95 95
                 // Grab the controller name and method call
96
-                $segments = explode('@', $last);
96
+                $segments=explode('@', $last);
97 97
                 app()->invokeMethod($segments, $param);
98 98
             }
99 99
         } catch (\ReflectionException $e) {
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function dispatch() {
127 127
 
128
-        $current['uri'] = $this->request->path();
129
-        $current['method'] = $this->request->method();
128
+        $current['uri']=$this->request->path();
129
+        $current['method']=$this->request->method();
130 130
         # 第一种情况,直接命中
131
-        if (isset($this->routes[$current['method'] . $current['uri']])) {
132
-            $this->foundRoute($this->routes[$current['method'] . $current['uri']]);
131
+        if (isset($this->routes[$current['method'].$current['uri']])) {
132
+            $this->foundRoute($this->routes[$current['method'].$current['uri']]);
133 133
         } # 第二种情况,any命中
134
-        else if (isset($this->routes['ANY' . $current['uri']])) {
135
-            $this->foundRoute($this->routes['ANY' . $current['method']]);
134
+        else if (isset($this->routes['ANY'.$current['uri']])) {
135
+            $this->foundRoute($this->routes['ANY'.$current['method']]);
136 136
         } # 第三种情况,正则命中
137 137
         else {
138 138
             if ($this->foundRegexRoute($current)) {
139 139
 
140 140
             } else {
141
-                $route['callback'] = $this->errorCallback;
141
+                $route['callback']=$this->errorCallback;
142 142
                 $this->foundRoute($route);
143 143
             }
144 144
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@
 block discarded – undo
98 98
             }
99 99
         } catch (\ReflectionException $e) {
100 100
             return false;
101
-        }
102
-        catch (\InvalidArgumentException $e) {
101
+        } catch (\InvalidArgumentException $e) {
103 102
             return false;
104 103
         }
105 104
         return true;
Please login to merge, or discard this patch.