@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array|null |
50 | 50 | */ |
51 | - public function json():?array { |
|
51 | + public function json(): ?array { |
|
52 | 52 | if (isset($this->json)) { |
53 | 53 | return $this->json; |
54 | 54 | } |
55 | - $data =json_decode($this->input(), true, 512, JSON_BIGINT_AS_STRING); |
|
56 | - if (json_last_error()!==JSON_ERROR_NONE) { |
|
55 | + $data = json_decode($this->input(), true, 512, JSON_BIGINT_AS_STRING); |
|
56 | + if (json_last_error() !== JSON_ERROR_NONE) { |
|
57 | 57 | $this->json = null; |
58 | 58 | } |
59 | 59 | return $this->json = $data; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param mixed $default |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | - public function get(?string $name=null, $default =null) |
|
69 | + public function get(?string $name = null, $default = null) |
|
70 | 70 | { |
71 | 71 | return $this->getParameter($name, $default); |
72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param mixed $default |
79 | 79 | * @return mixed 获取的值 |
80 | 80 | */ |
81 | - public static function post(?string $name=null, $default=null) |
|
81 | + public static function post(?string $name = null, $default = null) |
|
82 | 82 | { |
83 | 83 | if (is_null($name)) { |
84 | 84 | return $_POST; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string|null $name |
129 | 129 | * @return boolean |
130 | 130 | */ |
131 | - public function hasGet(?string $name=null) |
|
131 | + public function hasGet(?string $name = null) |
|
132 | 132 | { |
133 | 133 | $get = $this->getParameter(); |
134 | 134 | if (is_null($name)) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return boolean |
159 | 159 | */ |
160 | - public function hasPost(?string $name=null) |
|
160 | + public function hasPost(?string $name = null) |
|
161 | 161 | { |
162 | 162 | $post = $this->post(); |
163 | 163 | if ($name) { |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param mixed $default |
181 | 181 | * @return mixed |
182 | 182 | */ |
183 | - abstract public function getHeader(string $name, $default =null); |
|
183 | + abstract public function getHeader(string $name, $default = null); |
|
184 | 184 | /** |
185 | 185 | * 获取请求参数 |
186 | 186 | * |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|null |
46 | 46 | */ |
47 | - public function json():?array; |
|
47 | + public function json(): ?array; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * 获取GET参数 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param mixed $default |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function get(?string $name=null, $default =null); |
|
56 | + public function get(?string $name = null, $default = null); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * 获取POST请求的值 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param mixed $default |
63 | 63 | * @return mixed 获取的值 |
64 | 64 | */ |
65 | - public static function post(?string $name=null, $default=null); |
|
65 | + public static function post(?string $name = null, $default = null); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * 获取HTTP输入 |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string|null $name |
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | - public function hasGet(?string $name=null); |
|
88 | + public function hasGet(?string $name = null); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * 判断是否有JSON数据请求 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function hasPost(?string $name=null); |
|
102 | + public function hasPost(?string $name = null); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * 获取参数 |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param mixed $default |
116 | 116 | * @return mixed |
117 | 117 | */ |
118 | - public function getHeader(string $name, $default =null); |
|
118 | + public function getHeader(string $name, $default = null); |
|
119 | 119 | |
120 | 120 | // Uri |
121 | 121 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } else { |
153 | 153 | $indexFile = substr($this->getEntranceFile(), strlen($this->getDocumentRoot())); |
154 | 154 | } |
155 | - return $this->indexFile = str_replace('\\', '/' ,$indexFile); |
|
155 | + return $this->indexFile = str_replace('\\', '/', $indexFile); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,26 +165,26 @@ discard block |
||
165 | 165 | { |
166 | 166 | $url = $this->uri; |
167 | 167 | |
168 | - $queryString=''; |
|
168 | + $queryString = ''; |
|
169 | 169 | // for /?/xx |
170 | 170 | if (\strpos($url, '/?/') === 0) { |
171 | 171 | $url = substr($url, 2); |
172 | 172 | } |
173 | 173 | $indexFile = $this->getIndexFile(); |
174 | - if (\strpos($url, $indexFile) ===0) { |
|
174 | + if (\strpos($url, $indexFile) === 0) { |
|
175 | 175 | // for /index.php/ |
176 | - $url = \substr($url, strlen($indexFile));// for /index.php?/ |
|
176 | + $url = \substr($url, strlen($indexFile)); // for /index.php?/ |
|
177 | 177 | if (\strpos($url, '?/') === 0) { |
178 | 178 | $url = ltrim($url, '?'); |
179 | 179 | } |
180 | 180 | // for /index.php |
181 | - elseif (\strpos($url, '/')!== 0) { |
|
181 | + elseif (\strpos($url, '/') !== 0) { |
|
182 | 182 | $url = '/'.$url; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | $queryStart = \strpos($url, '?'); |
186 | 186 | if ($queryStart !== false) { |
187 | - $queryString = \substr($url, $queryStart+1); |
|
187 | + $queryString = \substr($url, $queryStart + 1); |
|
188 | 188 | $url = \substr($url, 0, $queryStart); |
189 | 189 | } |
190 | 190 | $this->url = $url; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | parse_str($queryString, $this->queryParameter); |
193 | 193 | } |
194 | 194 | if ($applyServer) { |
195 | - $_SERVER['PATH_INFO'] = $this->url; |
|
195 | + $_SERVER['PATH_INFO'] = $this->url; |
|
196 | 196 | $_SERVER['SCRIPT_NAME'] = $this->getIndexFile(); |
197 | 197 | $_SERVER['PHP_SELF'] = $this->getIndexFile(); |
198 | 198 | $_GET = $this->queryParameter; |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | } |
211 | 211 | $serverBasicUri = $this->getServerUri(); |
212 | 212 | $indexFile = $this->getIndexFile(); |
213 | - $isWindows = DIRECTORY_SEPARATOR === '\\'; |
|
214 | - $isRoot= in_array(substr($indexFile, 1), static::getDefaultIndexs()); |
|
213 | + $isWindows = DIRECTORY_SEPARATOR === '\\'; |
|
214 | + $isRoot = in_array(substr($indexFile, 1), static::getDefaultIndexs()); |
|
215 | 215 | if ($this->enabledRewrite && $isRoot) { |
216 | 216 | if ($isWindows && !$this->enabledBeautifyUrl) { |
217 | 217 | return $this->basicUri = $serverBasicUri.'/?/'; |
@@ -7,7 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * HTTP请求文件 |
9 | 9 | */ |
10 | -class UploadedFile extends File { |
|
10 | +class UploadedFile extends File { |
|
11 | 11 | |
12 | 12 | private $originalName; |
13 | 13 | private $mimeType; |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * HTTP请求文件 |
7 | 7 | */ |
8 | -class File extends \SplFileInfo { |
|
8 | +class File extends \SplFileInfo { |
|
9 | 9 | /** |
10 | 10 | * 创建文件 |
11 | 11 | * |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @var array |
29 | 29 | */ |
30 | - protected static $headers =[ |
|
30 | + protected static $headers = [ |
|
31 | 31 | 'content-type' => ContentTypeItem::class, |
32 | 32 | ]; |
33 | 33 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | if ($value instanceof HeaderItem) { |
70 | 70 | $header = $value; |
71 | 71 | } elseif (array_key_exists($name, static::$headers)) { |
72 | - $class =static::$headers[$name]; |
|
72 | + $class = static::$headers[$name]; |
|
73 | 73 | $header = new $class($name, $value); |
74 | 74 | } else { |
75 | 75 | $header = new HeaderItem($name, $value); |
@@ -85,7 +85,7 @@ |
||
85 | 85 | if (is_null($this->pdo)) { |
86 | 86 | try { |
87 | 87 | $this->pdo = new PDO($this->getDsn(), $this->config['database-user'], $this->config['database-password']); |
88 | - static::$connetionCount ++; |
|
88 | + static::$connetionCount++; |
|
89 | 89 | } catch (PDOException $e) { |
90 | 90 | throw new ConnectionException($e->getMessage(), $e->getCode()); |
91 | 91 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param string $name |
57 | 57 | * @return string|null |
58 | 58 | */ |
59 | - public static function get(string $filename):?string; |
|
59 | + public static function get(string $filename): ?string; |
|
60 | 60 | |
61 | 61 | |
62 | 62 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param boolean $full |
78 | 78 | * @return \Iterator |
79 | 79 | */ |
80 | - public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator; |
|
80 | + public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator; |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * 读目录下文件夹 |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param boolean $full |
89 | 89 | * @return \Iterator |
90 | 90 | */ |
91 | - public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
91 | + public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * 读目录,包括文件,文件夹 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param boolean $full |
100 | 100 | * @return \Iterator |
101 | 101 | */ |
102 | - public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
102 | + public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * 截断部分目录 |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param boolean $move |
120 | 120 | * @return boolean |
121 | 121 | */ |
122 | - public static function copyDir(string $path, string $toPath, ?string $regex=null, bool $move = false):bool; |
|
122 | + public static function copyDir(string $path, string $toPath, ?string $regex = null, bool $move = false):bool; |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * 移动文件夹 |
@@ -129,5 +129,5 @@ discard block |
||
129 | 129 | * @param string|null $regex |
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | - public static function moveDir(string $path, string $toPath, ?string $regex=null):bool; |
|
132 | + public static function moveDir(string $path, string $toPath, ?string $regex = null):bool; |
|
133 | 133 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public static function delete(string $filename):bool |
27 | 27 | { |
28 | - if (($path=Path::format($filename)) !== null) { |
|
28 | + if (($path = Path::format($filename)) !== null) { |
|
29 | 29 | if (!is_writable($path)) { |
30 | 30 | return false; |
31 | 31 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function move(string $src, string $dest):bool |
45 | 45 | { |
46 | - if (($path=Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
46 | + if (($path = Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
47 | 47 | return rename($path, $dest); |
48 | 48 | } |
49 | 49 | return false; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function copy(string $src, string $dest):bool |
60 | 60 | { |
61 | - if (($path=Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
61 | + if (($path = Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
62 | 62 | return copy($path, $dest); |
63 | 63 | } |
64 | 64 | return false; |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param string $name |
87 | 87 | * @return string|null |
88 | 88 | */ |
89 | - public static function get(string $filename):?string |
|
89 | + public static function get(string $filename): ?string |
|
90 | 90 | { |
91 | - if (is_readable($filename) && ($path=Path::format($filename)) !== null) { |
|
91 | + if (is_readable($filename) && ($path = Path::format($filename)) !== null) { |
|
92 | 92 | return file_get_contents($path); |
93 | 93 | } |
94 | 94 | return null; |