@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | // 接收十六进制(如:0xFF0000和'FF0000')和颜色名字 |
309 | 309 | $hex = I::get(self::$_names, $color, $color); |
310 | 310 | if ($hex) { |
311 | - C::assertNotTrue($hex > 0xFFFFFF || $hex < 0 || hexdec($hex) === 0 && $hex !== '000000' && $hex !== '#000000' , '错误的颜色值:' . $color); |
|
311 | + C::assertNotTrue($hex > 0xFFFFFF || $hex < 0 || hexdec($hex) === 0 && $hex !== '000000' && $hex !== '#000000', '错误的颜色值:' . $color); |
|
312 | 312 | } |
313 | 313 | // 如果是字符形式的十六进制数,则先转成十进制再作后续运算 |
314 | 314 | if (is_string($hex)) { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | $type = $this->_type; |
335 | 335 | if (self::TYPE_RGB === $type) { |
336 | - $this->_color = array_map(function ($i) { |
|
336 | + $this->_color = array_map(function($i) { |
|
337 | 337 | return (0.5 + $i) | 0; |
338 | 338 | }, $this->_color); |
339 | 339 | } elseif (self::TYPE_HEX === $type) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | { |
387 | 387 | $type = $this->_type; |
388 | 388 | if (self::TYPE_CMYK === $type) { |
389 | - $this->_color = array_map(function ($i) { |
|
389 | + $this->_color = array_map(function($i) { |
|
390 | 390 | return sprintf('%01.4f', $i); |
391 | 391 | }, $this->_color); |
392 | 392 | $this->_type = self::TYPE_CMYK; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | setlocale(LC_ALL, $locale); |
52 | 52 | clearstatcache(); |
53 | - $this->_functions['loader'] = function ($fileName) { |
|
53 | + $this->_functions['loader'] = function($fileName) { |
|
54 | 54 | $hashName = $this->__hash($fileName); |
55 | 55 | $this->_attributes[$hashName] = I::get($this->_attributes, $hashName, [ |
56 | 56 | 'isCached' => false, |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | curl_close($curl); |
86 | - } elseif ((bool) ini_get('allow_url_fopen')) { |
|
87 | - $headArray = (array) get_headers($fileName, 1); |
|
86 | + } elseif ((bool)ini_get('allow_url_fopen')) { |
|
87 | + $headArray = (array)get_headers($fileName, 1); |
|
88 | 88 | if (preg_match('/200/', $headArray[0])) { |
89 | 89 | $this->_attributes[$hashName]['isExists'] = true; |
90 | 90 | $this->_attributes[$hashName]['fileSize'] = $headArray['Content-Length']; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | } else { |
93 | 93 | $url = parse_url($fileName); |
94 | 94 | $host = $url['host']; |
95 | - $path = (string) I::get($url, 'path', '/'); |
|
96 | - $port = (int) I::get($url, 'port', 80); |
|
95 | + $path = (string)I::get($url, 'path', '/'); |
|
96 | + $port = (int)I::get($url, 'port', 80); |
|
97 | 97 | $fp = fsockopen($host, $port); |
98 | 98 | if (is_resource($fp)) { |
99 | 99 | $header = [ |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function __file($file) |
148 | 148 | { |
149 | - return (string) I::getAlias($file); |
|
149 | + return (string)I::getAlias($file); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function getFilesize($fileName) |
332 | 332 | { |
333 | - return (int) $this->attribute($fileName, 'fileSize'); |
|
333 | + return (int)$this->attribute($fileName, 'fileSize'); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function isFile($file) |
364 | 364 | { |
365 | - return (bool) $this->attribute($file, 'isExists'); |
|
365 | + return (bool)$this->attribute($file, 'isExists'); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | chmod($subFile, $mode); |
559 | 559 | } |
560 | 560 | } |
561 | - return (bool) chmod($file, $mode); |
|
561 | + return (bool)chmod($file, $mode); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -86,7 +86,7 @@ |
||
86 | 86 | if (Strings::isStartsWith(trim($line), '#')) { |
87 | 87 | continue; |
88 | 88 | } |
89 | - list($name, $value) = Arrays::lists(explode('=', $line), 2, function ($row) { |
|
89 | + list($name, $value) = Arrays::lists(explode('=', $line), 2, function($row) { |
|
90 | 90 | return trim($row); |
91 | 91 | }); |
92 | 92 | $array[$name] = $value; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | public function dayRange($offset = 0, $time = null) |
39 | 39 | { |
40 | 40 | null === $time && $time = time(); |
41 | - $y = (int) (date('Y', $time)); |
|
42 | - $m = (int) (date('m', $time)); |
|
43 | - $d = (int) (date('d', $time) + $offset); |
|
41 | + $y = (int)(date('Y', $time)); |
|
42 | + $m = (int)(date('m', $time)); |
|
43 | + $d = (int)(date('d', $time) + $offset); |
|
44 | 44 | return [ |
45 | 45 | mktime(0, 0, 0, $m, $d, $y), |
46 | 46 | mktime(23, 59, 59, $m, $d, $y), |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function weekRange($offset = 0, $time = null) |
61 | 61 | { |
62 | 62 | null === $time && $time = time(); |
63 | - $offset = (int) $offset; |
|
63 | + $offset = (int)$offset; |
|
64 | 64 | return [ |
65 | 65 | strtotime(date('Y-m-d', strtotime('Sunday ' . ($offset - 1) . ' week', $time))), |
66 | 66 | strtotime(date('Y-m-d', strtotime('Saturday ' . $offset . ' week', $time))) + 24 * 3600 - 1, |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | public function monthRange($offset = 0, $time = null) |
79 | 79 | { |
80 | 80 | null === $time && $time = time(); |
81 | - $y = (int) (date('Y', $time)); |
|
82 | - $m = (int) (date('m', $time) + $offset); |
|
81 | + $y = (int)(date('Y', $time)); |
|
82 | + $m = (int)(date('m', $time) + $offset); |
|
83 | 83 | $begin = mktime(0, 0, 0, $m, 1, $y); |
84 | - $end = mktime(23, 59, 59, $m, (int) date('t', $begin), $y); |
|
84 | + $end = mktime(23, 59, 59, $m, (int)date('t', $begin), $y); |
|
85 | 85 | |
86 | 86 | return [$begin, $end]; |
87 | 87 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | public function yearRange($offset = 0, $time = null) |
98 | 98 | { |
99 | 99 | null === $time && $time = time(); |
100 | - $year = (int) (date('Y', $time) + $offset); |
|
100 | + $year = (int)(date('Y', $time) + $offset); |
|
101 | 101 | return [ |
102 | 102 | mktime(0, 0, 0, 1, 1, $year), |
103 | 103 | mktime(23, 59, 59, 12, 31, $year), |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function day($offset = 0, $time = null) |
116 | 116 | { |
117 | 117 | null === $time && $time = time(); |
118 | - $offset = (int) $offset; |
|
118 | + $offset = (int)$offset; |
|
119 | 119 | return $time + 3600 * 24 * $offset; |
120 | 120 | } |
121 | 121 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function week($offset = 0, $time = null) |
131 | 131 | { |
132 | 132 | null === $time && $time = time(); |
133 | - $offset = (int) $offset; |
|
133 | + $offset = (int)$offset; |
|
134 | 134 | return $time + 3600 * 24 * 7 * $offset; |
135 | 135 | } |
136 | 136 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function month($offset = 0, $time = null) |
146 | 146 | { |
147 | 147 | null === $time && $time = time(); |
148 | - $offset = (int) $offset; |
|
148 | + $offset = (int)$offset; |
|
149 | 149 | return $time + 3600 * 24 * date('t', $time) * $offset; |
150 | 150 | } |
151 | 151 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | public function year($offset = 0, $time = null) |
161 | 161 | { |
162 | 162 | null === $time && $time = time(); |
163 | - $offset = (int) $offset; |
|
164 | - return $time + 3600 * 24 * (date('z', mktime(0, 0, 0, 12, 31, (int) date('Y', $time))) + 1) * $offset; |
|
163 | + $offset = (int)$offset; |
|
164 | + return $time + 3600 * 24 * (date('z', mktime(0, 0, 0, 12, 31, (int)date('Y', $time))) + 1) * $offset; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function isLeapYear($time = null) |
201 | 201 | { |
202 | 202 | null === $time && $time = time(); |
203 | - return (bool) date('L', $time); |
|
203 | + return (bool)date('L', $time); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -215,6 +215,6 @@ discard block |
||
215 | 215 | public function yearPosition($time = null) |
216 | 216 | { |
217 | 217 | null === $time && $time = time(); |
218 | - return (int) date('z', $time) + 1; |
|
218 | + return (int)date('z', $time) + 1; |
|
219 | 219 | } |
220 | 220 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function getCallArray() |
214 | 214 | { |
215 | - C::assertTrue($this->isSuccess(), (string) I::get($this->_result, 'return_msg')); |
|
215 | + C::assertTrue($this->isSuccess(), (string)I::get($this->_result, 'return_msg')); |
|
216 | 216 | $array = []; |
217 | 217 | if ('APP' === I::get($this->_values, 'trade_type')) { |
218 | 218 | $array = [ |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | $xml = (new Request())->getRawBody(); |
246 | 246 | $array = Xml::toArray($xml); |
247 | - C::assertTrue('SUCCESS' === I::get($array, 'return_code') && 'SUCCESS' === I::get($array, 'result_code'), (string) I::get($array, 'return_msg')); |
|
247 | + C::assertTrue('SUCCESS' === I::get($array, 'return_code') && 'SUCCESS' === I::get($array, 'result_code'), (string)I::get($array, 'return_msg')); |
|
248 | 248 | $temp = $array; |
249 | 249 | $sign = $temp['sign']; |
250 | 250 | unset($temp['sign']); |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function shortUrl() |
481 | 481 | { |
482 | - C::assertTrue(null !== ($longUrl = (string) I::get($this->_values, 'long_url')), '缺少 long_url 参数!'); |
|
482 | + C::assertTrue(null !== ($longUrl = (string)I::get($this->_values, 'long_url')), '缺少 long_url 参数!'); |
|
483 | 483 | $values = array_filter([ |
484 | 484 | 'appid' => $this->_appId, |
485 | 485 | 'mch_id' => $this->_mchId, |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function getQrcodeUrl() |
506 | 506 | { |
507 | - C::assertTrue(null !== ($productId = (string) I::get($this->_values, 'product_id')), '缺少 product_id 参数!'); |
|
507 | + C::assertTrue(null !== ($productId = (string)I::get($this->_values, 'product_id')), '缺少 product_id 参数!'); |
|
508 | 508 | $values = [ |
509 | 509 | 'appid' => $this->_appId, |
510 | 510 | 'mch_id' => $this->_mchId, |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | 'charset' => 'UTF-8', |
76 | 76 | ])); |
77 | 77 | |
78 | - $this->_toArrayCall = function ($result) { |
|
79 | - return Arrays::column((array) I::get($result, 'items', []), 'item'); |
|
78 | + $this->_toArrayCall = function($result) { |
|
79 | + return Arrays::column((array)I::get($result, 'items', []), 'item'); |
|
80 | 80 | }; |
81 | 81 | |
82 | 82 | return $this; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | 'access_token' => $this->_token, |
104 | 104 | 'charset' => 'UTF-8', |
105 | 105 | ])); |
106 | - $this->_toArrayCall = function ($result) { |
|
107 | - return Arrays::column((array) I::get($result, 'items', []), 'word'); |
|
106 | + $this->_toArrayCall = function($result) { |
|
107 | + return Arrays::column((array)I::get($result, 'items', []), 'word'); |
|
108 | 108 | }; |
109 | 109 | |
110 | 110 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'access_token' => $this->_token, |
135 | 135 | 'charset' => 'UTF-8', |
136 | 136 | ])); |
137 | - $this->_toArrayCall = function ($result) { |
|
137 | + $this->_toArrayCall = function($result) { |
|
138 | 138 | return I::get($result, 'score'); |
139 | 139 | }; |
140 | 140 |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } catch (ClientException $e) { |
158 | 158 | throw new Exception("access_token 获取失败,接口返回为:" . $e->getResponse()->getBody()->getContents()); |
159 | 159 | } |
160 | - $this->_token = (string) $this->getResult(self::RESULT_TOKEN); |
|
160 | + $this->_token = (string)$this->getResult(self::RESULT_TOKEN); |
|
161 | 161 | } |
162 | 162 | return $this; |
163 | 163 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function getError() |
184 | 184 | { |
185 | - return (string) I::get($this->_errorMap, I::get($this->_result, 'error_code', 0), '未知错误'); |
|
185 | + return (string)I::get($this->_errorMap, I::get($this->_result, 'error_code', 0), '未知错误'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function toArray() |
227 | 227 | { |
228 | - return (array) I::call($this->_toArrayCall, [$this->getResult()]); |
|
228 | + return (array)I::call($this->_toArrayCall, [$this->getResult()]); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | ]), [ |
77 | 77 | 'access_token' => $this->_token, |
78 | 78 | ])); |
79 | - $this->_toArrayCall = function ($result) { |
|
80 | - return Arrays::column((array) I::get($result, 'words_result', []), 'words'); |
|
79 | + $this->_toArrayCall = function($result) { |
|
80 | + return Arrays::column((array)I::get($result, 'words_result', []), 'words'); |
|
81 | 81 | }; |
82 | 82 | |
83 | 83 | return $this; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | ]), [ |
103 | 103 | 'access_token' => $this->_token, |
104 | 104 | ])); |
105 | - $this->_toArrayCall = function ($result) { |
|
106 | - return Arrays::column((array) I::get($result, 'words_result', []), 'words'); |
|
105 | + $this->_toArrayCall = function($result) { |
|
106 | + return Arrays::column((array)I::get($result, 'words_result', []), 'words'); |
|
107 | 107 | }; |
108 | 108 | |
109 | 109 | return $this; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ]), [ |
133 | 133 | 'access_token' => $this->_token, |
134 | 134 | ])); |
135 | - $this->_toArrayCall = function ($result) { |
|
135 | + $this->_toArrayCall = function($result) { |
|
136 | 136 | return I::get($result, 'words_result'); |
137 | 137 | }; |
138 | 138 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ]), [ |
161 | 161 | 'access_token' => $this->_token, |
162 | 162 | ])); |
163 | - $this->_toArrayCall = function ($result) { |
|
163 | + $this->_toArrayCall = function($result) { |
|
164 | 164 | return I::get($result, 'words_result'); |
165 | 165 | }; |
166 | 166 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | ]), [ |
187 | 187 | 'access_token' => $this->_token, |
188 | 188 | ])); |
189 | - $this->_toArrayCall = function ($result) { |
|
189 | + $this->_toArrayCall = function($result) { |
|
190 | 190 | return I::get($result, 'words_result'); |
191 | 191 | }; |
192 | 192 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $this->_result = Json::decode(Http::post('https://aip.baidubce.com/rest/2.0/ocr/v1/idcard', $options, [ |
215 | 215 | 'access_token' => $this->_token, |
216 | 216 | ])); |
217 | - $this->_toArrayCall = function ($result) { |
|
217 | + $this->_toArrayCall = function($result) { |
|
218 | 218 | $return = []; |
219 | 219 | $words = I::get($result, 'words_result', []); |
220 | 220 | foreach ($words as $name => $word) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $this->_result = Json::decode(Http::post('https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard', $options, [ |
241 | 241 | 'access_token' => $this->_token, |
242 | 242 | ])); |
243 | - $this->_toArrayCall = function ($result) { |
|
243 | + $this->_toArrayCall = function($result) { |
|
244 | 244 | return I::get($result, 'result'); |
245 | 245 | }; |
246 | 246 | return $this; |
@@ -107,7 +107,7 @@ |
||
107 | 107 | $params = array_filter($params); |
108 | 108 | foreach ($params as $key => $value) { |
109 | 109 | if ('sign' !== $key && false === Strings::isStartsWith($value, '@')) { |
110 | - $array[] = $key . '=' . Charset::convertTo($value, (string) I::get($this->_values, 'charset', 'utf-8')); |
|
110 | + $array[] = $key . '=' . Charset::convertTo($value, (string)I::get($this->_values, 'charset', 'utf-8')); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | $string = implode('&', $array); |