@@ -6,10 +6,10 @@ |
||
6 | 6 | trait LoaderAwareTrait |
7 | 7 | { |
8 | 8 | /** |
9 | - * 加载器 |
|
10 | - * |
|
11 | - * @var Loader |
|
12 | - */ |
|
9 | + * 加载器 |
|
10 | + * |
|
11 | + * @var Loader |
|
12 | + */ |
|
13 | 13 | protected $loader; |
14 | 14 | |
15 | 15 |
@@ -13,12 +13,12 @@ |
||
13 | 13 | * @param string $path 目标路径 |
14 | 14 | * @return string|null 返回格式化结果,如果路径不存在则返回NULL |
15 | 15 | */ |
16 | - public static function format(string $path):?string |
|
16 | + public static function format(string $path): ?string |
|
17 | 17 | { |
18 | - return static::existCharset($path, ['GBK','GB2312','BIG5']); |
|
18 | + return static::existCharset($path, ['GBK', 'GB2312', 'BIG5']); |
|
19 | 19 | } |
20 | 20 | |
21 | - public static function existCharset(string $path, array $charset):?string |
|
21 | + public static function existCharset(string $path, array $charset): ?string |
|
22 | 22 | { |
23 | 23 | $abspath = static::toAbsolutePath($path); |
24 | 24 | if (static::existCase($abspath)) { |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | { |
10 | 10 | public static function formatSeparator(string $path):string |
11 | 11 | { |
12 | - return str_replace(['\\','/'], DIRECTORY_SEPARATOR, $path); |
|
12 | + return str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public static function toAbsolutePath(string $path, string $separator = DIRECTORY_SEPARATOR):string |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | if (static::getHomePath() !== null && strpos($path, '~') === 0) { |
63 | 63 | $scheme = ''; |
64 | - $subpath = static::getHomePath() .DIRECTORY_SEPARATOR.substr($path, 1); |
|
64 | + $subpath = static::getHomePath().DIRECTORY_SEPARATOR.substr($path, 1); |
|
65 | 65 | } elseif (strpos($path, '://') !== false) { |
66 | 66 | list($scheme, $subpath) = explode('://', $path, 2); |
67 | 67 | $scheme .= '://'; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | - public static function getHomePath():?string |
|
76 | + public static function getHomePath(): ?string |
|
77 | 77 | { |
78 | 78 | if (defined('USER_HOME_PATH')) { |
79 | 79 | return constant('USER_HOME_PATH'); |
@@ -11,5 +11,5 @@ |
||
11 | 11 | |
12 | 12 | public static function toAbsolutePath(string $path, string $separator = DIRECTORY_SEPARATOR):string; |
13 | 13 | |
14 | - public static function getHomePath():?string; |
|
14 | + public static function getHomePath(): ?string; |
|
15 | 15 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | $dynmicsMethod; |
65 | 65 | $parameter = self::buildParameter($parameter); |
66 | 66 | if ($methodStart > 0) { |
67 | - $splitLength = $splitLength > 0 ? 1:2; |
|
67 | + $splitLength = $splitLength > 0 ? 1 : 2; |
|
68 | 68 | $methodName = substr($command, $methodStart + $splitLength); |
69 | 69 | $command = substr($command, 0, $methodStart); |
70 | 70 | list($className, $constructParameter) = self::splitParameter($command); |
71 | 71 | $constructParameter = self::buildParameter($constructParameter); |
72 | - $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter); |
|
72 | + $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter); |
|
73 | 73 | } else { |
74 | 74 | $target = new FunctionTarget(self::buildName($command), $parameter); |
75 | 75 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) { |
97 | 97 | throw new InvalidNameException(\sprintf('invaild name: %s ', $name)); |
98 | 98 | } |
99 | - return str_replace(['.','/'], '\\', $name); |
|
99 | + return str_replace(['.', '/'], '\\', $name); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | private static function splitParameter(string $command):array |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2); |
108 | 108 | $command = substr($command, 0, $paramStart); |
109 | 109 | } |
110 | - return [$command,$parameter]; |
|
110 | + return [$command, $parameter]; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | private static function buildParameter(?string $parameter) |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static $statusTexts = [ |
10 | 10 | 100 => 'Continue', |
11 | 11 | 101 => 'Switching Protocols', |
12 | - 102 => 'Processing', // RFC2518 |
|
12 | + 102 => 'Processing', // RFC2518 |
|
13 | 13 | 103 => 'Early Hints', |
14 | 14 | 200 => 'OK', |
15 | 15 | 201 => 'Created', |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | 204 => 'No Content', |
19 | 19 | 205 => 'Reset Content', |
20 | 20 | 206 => 'Partial Content', |
21 | - 207 => 'Multi-Status', // RFC4918 |
|
22 | - 208 => 'Already Reported', // RFC5842 |
|
23 | - 226 => 'IM Used', // RFC3229 |
|
21 | + 207 => 'Multi-Status', // RFC4918 |
|
22 | + 208 => 'Already Reported', // RFC5842 |
|
23 | + 226 => 'IM Used', // RFC3229 |
|
24 | 24 | 300 => 'Multiple Choices', |
25 | 25 | 301 => 'Moved Permanently', |
26 | 26 | 302 => 'Found', |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | 304 => 'Not Modified', |
29 | 29 | 305 => 'Use Proxy', |
30 | 30 | 307 => 'Temporary Redirect', |
31 | - 308 => 'Permanent Redirect', // RFC7238 |
|
31 | + 308 => 'Permanent Redirect', // RFC7238 |
|
32 | 32 | 400 => 'Bad Request', |
33 | 33 | 401 => 'Unauthorized', |
34 | 34 | 402 => 'Payment Required', |
@@ -47,34 +47,34 @@ discard block |
||
47 | 47 | 415 => 'Unsupported Media Type', |
48 | 48 | 416 => 'Range Not Satisfiable', |
49 | 49 | 417 => 'Expectation Failed', |
50 | - 418 => 'I\'m a teapot', // RFC2324 |
|
51 | - 421 => 'Misdirected Request', // RFC7540 |
|
52 | - 422 => 'Unprocessable Entity', // RFC4918 |
|
53 | - 423 => 'Locked', // RFC4918 |
|
54 | - 424 => 'Failed Dependency', // RFC4918 |
|
55 | - 425 => 'Too Early', // RFC-ietf-httpbis-replay-04 |
|
56 | - 426 => 'Upgrade Required', // RFC2817 |
|
57 | - 428 => 'Precondition Required', // RFC6585 |
|
58 | - 429 => 'Too Many Requests', // RFC6585 |
|
59 | - 431 => 'Request Header Fields Too Large', // RFC6585 |
|
60 | - 451 => 'Unavailable For Legal Reasons', // RFC7725 |
|
50 | + 418 => 'I\'m a teapot', // RFC2324 |
|
51 | + 421 => 'Misdirected Request', // RFC7540 |
|
52 | + 422 => 'Unprocessable Entity', // RFC4918 |
|
53 | + 423 => 'Locked', // RFC4918 |
|
54 | + 424 => 'Failed Dependency', // RFC4918 |
|
55 | + 425 => 'Too Early', // RFC-ietf-httpbis-replay-04 |
|
56 | + 426 => 'Upgrade Required', // RFC2817 |
|
57 | + 428 => 'Precondition Required', // RFC6585 |
|
58 | + 429 => 'Too Many Requests', // RFC6585 |
|
59 | + 431 => 'Request Header Fields Too Large', // RFC6585 |
|
60 | + 451 => 'Unavailable For Legal Reasons', // RFC7725 |
|
61 | 61 | 500 => 'Internal Server Error', |
62 | 62 | 501 => 'Not Implemented', |
63 | 63 | 502 => 'Bad Gateway', |
64 | 64 | 503 => 'Service Unavailable', |
65 | 65 | 504 => 'Gateway Timeout', |
66 | 66 | 505 => 'HTTP Version Not Supported', |
67 | - 506 => 'Variant Also Negotiates', // RFC2295 |
|
68 | - 507 => 'Insufficient Storage', // RFC4918 |
|
69 | - 508 => 'Loop Detected', // RFC5842 |
|
70 | - 510 => 'Not Extended', // RFC2774 |
|
71 | - 511 => 'Network Authentication Required', // RFC6585 |
|
67 | + 506 => 'Variant Also Negotiates', // RFC2295 |
|
68 | + 507 => 'Insufficient Storage', // RFC4918 |
|
69 | + 508 => 'Loop Detected', // RFC5842 |
|
70 | + 510 => 'Not Extended', // RFC2774 |
|
71 | + 511 => 'Network Authentication Required', // RFC6585 |
|
72 | 72 | ]; |
73 | 73 | |
74 | 74 | const HTTP_CONTINUE = 100; |
75 | 75 | const HTTP_SWITCHING_PROTOCOLS = 101; |
76 | - const HTTP_PROCESSING = 102; // RFC2518 |
|
77 | - const HTTP_EARLY_HINTS = 103; // RFC8297 |
|
76 | + const HTTP_PROCESSING = 102; // RFC2518 |
|
77 | + const HTTP_EARLY_HINTS = 103; // RFC8297 |
|
78 | 78 | const HTTP_OK = 200; |
79 | 79 | const HTTP_CREATED = 201; |
80 | 80 | const HTTP_ACCEPTED = 202; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | const HTTP_NO_CONTENT = 204; |
83 | 83 | const HTTP_RESET_CONTENT = 205; |
84 | 84 | const HTTP_PARTIAL_CONTENT = 206; |
85 | - const HTTP_MULTI_STATUS = 207; // RFC4918 |
|
86 | - const HTTP_ALREADY_REPORTED = 208; // RFC5842 |
|
87 | - const HTTP_IM_USED = 226; // RFC3229 |
|
85 | + const HTTP_MULTI_STATUS = 207; // RFC4918 |
|
86 | + const HTTP_ALREADY_REPORTED = 208; // RFC5842 |
|
87 | + const HTTP_IM_USED = 226; // RFC3229 |
|
88 | 88 | const HTTP_MULTIPLE_CHOICES = 300; |
89 | 89 | const HTTP_MOVED_PERMANENTLY = 301; |
90 | 90 | const HTTP_FOUND = 302; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | const HTTP_USE_PROXY = 305; |
94 | 94 | const HTTP_RESERVED = 306; |
95 | 95 | const HTTP_TEMPORARY_REDIRECT = 307; |
96 | - const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238 |
|
96 | + const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238 |
|
97 | 97 | const HTTP_BAD_REQUEST = 400; |
98 | 98 | const HTTP_UNAUTHORIZED = 401; |
99 | 99 | const HTTP_PAYMENT_REQUIRED = 402; |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | const HTTP_UNSUPPORTED_MEDIA_TYPE = 415; |
113 | 113 | const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416; |
114 | 114 | const HTTP_EXPECTATION_FAILED = 417; |
115 | - const HTTP_I_AM_A_TEAPOT = 418; // RFC2324 |
|
116 | - const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540 |
|
117 | - const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918 |
|
118 | - const HTTP_LOCKED = 423; // RFC4918 |
|
119 | - const HTTP_FAILED_DEPENDENCY = 424; // RFC4918 |
|
115 | + const HTTP_I_AM_A_TEAPOT = 418; // RFC2324 |
|
116 | + const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540 |
|
117 | + const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918 |
|
118 | + const HTTP_LOCKED = 423; // RFC4918 |
|
119 | + const HTTP_FAILED_DEPENDENCY = 424; // RFC4918 |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @deprecated |
123 | 123 | */ |
124 | - const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817 |
|
125 | - const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04 |
|
126 | - const HTTP_UPGRADE_REQUIRED = 426; // RFC2817 |
|
127 | - const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 |
|
128 | - const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 |
|
129 | - const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 |
|
124 | + const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817 |
|
125 | + const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04 |
|
126 | + const HTTP_UPGRADE_REQUIRED = 426; // RFC2817 |
|
127 | + const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 |
|
128 | + const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 |
|
129 | + const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 |
|
130 | 130 | const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; |
131 | 131 | const HTTP_INTERNAL_SERVER_ERROR = 500; |
132 | 132 | const HTTP_NOT_IMPLEMENTED = 501; |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | const HTTP_SERVICE_UNAVAILABLE = 503; |
135 | 135 | const HTTP_GATEWAY_TIMEOUT = 504; |
136 | 136 | const HTTP_VERSION_NOT_SUPPORTED = 505; |
137 | - const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295 |
|
138 | - const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918 |
|
139 | - const HTTP_LOOP_DETECTED = 508; // RFC5842 |
|
140 | - const HTTP_NOT_EXTENDED = 510; // RFC2774 |
|
137 | + const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295 |
|
138 | + const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918 |
|
139 | + const HTTP_LOOP_DETECTED = 508; // RFC5842 |
|
140 | + const HTTP_NOT_EXTENDED = 510; // RFC2774 |
|
141 | 141 | const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; |
142 | 142 | |
143 | 143 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | parse_str($query, $this->query); |
44 | 44 | } |
45 | 45 | $url = parse_url($url, PHP_URL_PATH); |
46 | - $this->uri = '/' . trim($url, '\/'); |
|
46 | + $this->uri = '/'.trim($url, '\/'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function getQuery():array |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | if (\strpos($url, $indexFile) === 0) { |
65 | 65 | // for /index.php/ |
66 | - $url = \substr($url, strlen($indexFile));// for /index.php?/ |
|
66 | + $url = \substr($url, strlen($indexFile)); // for /index.php?/ |
|
67 | 67 | if (\strpos($url, '?/') === 0) { |
68 | 68 | $url = ltrim($url, '?'); |
69 | 69 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function getScheme():string |
60 | 60 | { |
61 | - return $this->isSecure()?'https':'http'; |
|
61 | + return $this->isSecure() ? 'https' : 'http'; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return array|null |
108 | 108 | */ |
109 | - public function json():?array |
|
109 | + public function json(): ?array |
|
110 | 110 | { |
111 | - return $this->isJson?$this->parameter:null; |
|
111 | + return $this->isJson ? $this->parameter : null; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | */ |
14 | 14 | protected static $mimes = [ |
15 | 15 | # Image Type |
16 | - 'jpe' => 'image/jpeg' , |
|
17 | - 'jpeg' => 'image/jpeg' , |
|
18 | - 'jpg' => 'image/jpeg' , |
|
19 | - 'svg' => 'image/svg+xml' , |
|
20 | - 'png' => 'image/png' , |
|
21 | - 'gif' => 'image/gif' , |
|
16 | + 'jpe' => 'image/jpeg', |
|
17 | + 'jpeg' => 'image/jpeg', |
|
18 | + 'jpg' => 'image/jpeg', |
|
19 | + 'svg' => 'image/svg+xml', |
|
20 | + 'png' => 'image/png', |
|
21 | + 'gif' => 'image/gif', |
|
22 | 22 | 'ico' => 'image/x-icon', |
23 | 23 | 'webp' => 'image/webp', |
24 | 24 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | 'js' => 'text/javascript', |
27 | 27 | 'css' => 'text/css', |
28 | 28 | 'txt' => 'text/plain', |
29 | - 'html' => 'text/html' , |
|
30 | - 'csv' => 'text/csv' , |
|
29 | + 'html' => 'text/html', |
|
30 | + 'csv' => 'text/csv', |
|
31 | 31 | 'xml' => 'text/xml', |
32 | 32 | |
33 | 33 | # App type |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | # Archive |
41 | 41 | 'zip' => 'application/zip', |
42 | - 'gtar' => 'application/x-gtar' , |
|
43 | - 'gz' => 'application/x-gzip' , |
|
42 | + 'gtar' => 'application/x-gtar', |
|
43 | + 'gz' => 'application/x-gzip', |
|
44 | 44 | '7z' => 'application/x-7z-compressed', |
45 | 45 | 'rar' => 'application/x-rar-compressed', |
46 | 46 |