@@ -78,7 +78,7 @@ |
||
| 78 | 78 | */ |
| 79 | 79 | public static function convertTo($string, $targetCharset, $fromCharset = null) |
| 80 | 80 | { |
| 81 | - $charset = null === $fromCharset ? self::detect($string): $fromCharset; |
|
| 81 | + $charset = null === $fromCharset ? self::detect($string) : $fromCharset; |
|
| 82 | 82 | $converted = @iconv($charset, $targetCharset . '//TRANSLIT//IGNORE', $string); |
| 83 | 83 | // if (false === $converted) { |
| 84 | 84 | // $converted = mb_convert_encoding($string, $targetCharset); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public static function combine($keys, $values) |
| 179 | 179 | { |
| 180 | 180 | if (count($keys) == count($values)) { |
| 181 | - return (array) array_combine($keys, $values); |
|
| 181 | + return (array)array_combine($keys, $values); |
|
| 182 | 182 | } |
| 183 | 183 | $array = []; |
| 184 | 184 | foreach ($keys as $index => $key) { |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } else { |
| 495 | 495 | $function = $callback; |
| 496 | 496 | if (false === is_callable($callback)) { |
| 497 | - $function = function ($row) use ($callback, $isStrict) { |
|
| 497 | + $function = function($row) use ($callback, $isStrict) { |
|
| 498 | 498 | return true === $isStrict ? $row === $callback : $row == $callback; |
| 499 | 499 | }; |
| 500 | 500 | } |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | } |
| 841 | 841 | $header = array_keys($records[0]); |
| 842 | 842 | $arrays = self::values($records); |
| 843 | - return implode(',', $header) . PHP_EOL . implode(PHP_EOL, self::map($arrays, function ($array) { |
|
| 843 | + return implode(',', $header) . PHP_EOL . implode(PHP_EOL, self::map($arrays, function($array) { |
|
| 844 | 844 | return implode(',', $array); |
| 845 | 845 | })); |
| 846 | 846 | } |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | return in_array($value, $array, $isStrict); |
| 932 | 932 | } else { |
| 933 | 933 | $value = Json::decode(strtolower(Json::encode($value))); |
| 934 | - $array = (array) Json::decode(strtolower(Json::encode($array))); |
|
| 934 | + $array = (array)Json::decode(strtolower(Json::encode($array))); |
|
| 935 | 935 | return in_array($value, $array, $isStrict); |
| 936 | 936 | } |
| 937 | 937 | } |
@@ -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 mktime((int) date('H', $time), (int) date('i', $time), (int) date('s', $time), (int) date('m', $time), (int) date('d', $time), (int) date('Y', $time) + $offset); |
|
| 163 | + $offset = (int)$offset; |
|
| 164 | + return mktime((int)date('H', $time), (int)date('i', $time), (int)date('s', $time), (int)date('m', $time), (int)date('d', $time), (int)date('Y', $time) + $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,7 +215,7 @@ 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 | |
| 221 | 221 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $this->_result = Json::decode(Http::get('https://api.weixin.qq.com/cgi-bin/token', $this->filterOptions([ |
| 40 | 40 | 'grant_type', 'appid', 'secret', |
| 41 | 41 | ]))); |
| 42 | - $this->_toArrayCall = function ($array) { |
|
| 42 | + $this->_toArrayCall = function($array) { |
|
| 43 | 43 | return Arrays::columns1($array, ['access_token', 'expires_in']); |
| 44 | 44 | }; |
| 45 | 45 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'appid', 'secret', 'js_code', 'grant_type', |
| 55 | 55 | ]))); |
| 56 | 56 | // 这个接口返回没有 errcode |
| 57 | - $this->_toArrayCall = function ($array) { |
|
| 57 | + $this->_toArrayCall = function($array) { |
|
| 58 | 58 | return Arrays::columns1($array, ['openid', 'session_key', 'unionid']); |
| 59 | 59 | }; |
| 60 | 60 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function getCallArray() |
| 207 | 207 | { |
| 208 | - C::assertTrue($this->isSuccess(), (string) I::get($this->_result, 'return_msg')); |
|
| 208 | + C::assertTrue($this->isSuccess(), (string)I::get($this->_result, 'return_msg')); |
|
| 209 | 209 | $array = []; |
| 210 | 210 | if (self::TRADE_TYPE_APP === I::get($this->_options, 'trade_type')) { |
| 211 | 211 | $array = [ |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | 'nonceStr' => Strings::random(), |
| 230 | 230 | 'package' => 'prepay_id=' . I::get($this->_result, 'prepay_id'), |
| 231 | 231 | 'signType' => I::get($this->_options, 'sign_type', 'MD5'), |
| 232 | - 'timeStamp' => (string) time(), |
|
| 232 | + 'timeStamp' => (string)time(), |
|
| 233 | 233 | ]; |
| 234 | 234 | $array['paySign'] = $this->getSign($array); |
| 235 | 235 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | { |
| 248 | 248 | $xml = (new Request())->getRawBody(); |
| 249 | 249 | $array = Xml::toArray($xml); |
| 250 | - C::assertTrue('SUCCESS' === I::get($array, 'return_code') && 'SUCCESS' === I::get($array, 'result_code'), (string) I::get($array, 'return_msg')); |
|
| 250 | + C::assertTrue('SUCCESS' === I::get($array, 'return_code') && 'SUCCESS' === I::get($array, 'result_code'), (string)I::get($array, 'return_msg')); |
|
| 251 | 251 | $temp = $array; |
| 252 | 252 | $sign = $temp['sign']; |
| 253 | 253 | unset($temp['sign']); |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | public function shortUrl() |
| 490 | 490 | { |
| 491 | - C::assertTrue(null !== ($longUrl = (string) I::get($this->_options, 'long_url')), '缺少 long_url 参数!'); |
|
| 491 | + C::assertTrue(null !== ($longUrl = (string)I::get($this->_options, 'long_url')), '缺少 long_url 参数!'); |
|
| 492 | 492 | $values = array_filter([ |
| 493 | 493 | 'appid' => $this->_appId, |
| 494 | 494 | 'mch_id' => $this->_mchId, |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | public function getQrcodeUrl() |
| 515 | 515 | { |
| 516 | - C::assertTrue(null !== ($productId = (string) I::get($this->_options, 'product_id')), '缺少 product_id 参数!'); |
|
| 516 | + C::assertTrue(null !== ($productId = (string)I::get($this->_options, 'product_id')), '缺少 product_id 参数!'); |
|
| 517 | 517 | $values = [ |
| 518 | 518 | 'appid' => $this->_appId, |
| 519 | 519 | 'mch_id' => $this->_mchId, |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | 'salt' => $salt, |
| 82 | 82 | 'sign' => md5($this->_appid . $text . $salt . $this->_secretKey), |
| 83 | 83 | ])); |
| 84 | - $this->_toArrayCall = function ($array) { |
|
| 84 | + $this->_toArrayCall = function($array) { |
|
| 85 | 85 | $trans = I::get($array, 'trans_result', []); |
| 86 | 86 | return Arrays::column($trans, 'dst'); |
| 87 | 87 | }; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | if (null === $this->_token) { |
| 146 | 146 | try { |
| 147 | - $this->_result = (array) Json::decode(Http::post('https://aip.baidubce.com/oauth/2.0/token', [], [ |
|
| 147 | + $this->_result = (array)Json::decode(Http::post('https://aip.baidubce.com/oauth/2.0/token', [], [ |
|
| 148 | 148 | 'grant_type' => 'client_credentials', |
| 149 | 149 | 'client_id' => $this->_apiKey, |
| 150 | 150 | 'client_secret' => $this->_secretKey, |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } catch (ClientException $e) { |
| 153 | 153 | throw new Exception("access_token 获取失败,接口返回为:" . $e->getResponse()->getBody()->getContents()); |
| 154 | 154 | } |
| 155 | - $this->_token = (string) $this->getResult(self::RESULT_TOKEN); |
|
| 155 | + $this->_token = (string)$this->getResult(self::RESULT_TOKEN); |
|
| 156 | 156 | } |
| 157 | 157 | return $this; |
| 158 | 158 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function getError() |
| 179 | 179 | { |
| 180 | - return (string) I::get($this->_errorMap, I::get($this->_result, 'error_code', 0), '未知错误'); |
|
| 180 | + return (string)I::get($this->_errorMap, I::get($this->_result, 'error_code', 0), '未知错误'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | 'resource_id' => '6006', |
| 32 | 32 | 'oe' => 'utf8', |
| 33 | 33 | ]), 'data.0.location', false); |
| 34 | - $this->_toArrayCall = function ($array) { |
|
| 34 | + $this->_toArrayCall = function($array) { |
|
| 35 | 35 | list($return['city'], $return['type']) = Arrays::lists(explode(' ', $array), 2); |
| 36 | 36 | return $return; |
| 37 | 37 | }; |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function fetchSearchFirst($firsts, $page = 0, $pageSize = 20) |
| 27 | 27 | { |
| 28 | - $this->_result = (array) Json::get(Http::get('http://api.jinsapi.com/yingshi/search', [ |
|
| 28 | + $this->_result = (array)Json::get(Http::get('http://api.jinsapi.com/yingshi/search', [ |
|
| 29 | 29 | 'keys' => Strings::toPinyinFirst($firsts), |
| 30 | 30 | 'page' => $page, |
| 31 | 31 | 'pageSize' => $pageSize, |
| 32 | 32 | ]), 'data', []); |
| 33 | - $this->_toArrayCall = function ($array) { |
|
| 33 | + $this->_toArrayCall = function($array) { |
|
| 34 | 34 | return Arrays::columns2($array, [ |
| 35 | 35 | 'id' => 'd_id', |
| 36 | 36 | 'name' => 'd_name', |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function fetchSearch($keywords, $page = 0, $pageSize = 20) |
| 55 | 55 | { |
| 56 | - $this->_result = (array) Json::get(Http::post('http://api.jinsapi.com/yingshi/searchForHanZi', [ |
|
| 56 | + $this->_result = (array)Json::get(Http::post('http://api.jinsapi.com/yingshi/searchForHanZi', [ |
|
| 57 | 57 | 'keys' => $keywords, |
| 58 | 58 | 'page' => $page, |
| 59 | 59 | 'pageSize' => $pageSize, |
| 60 | 60 | ]), 'data', []); |
| 61 | - $this->_toArrayCall = function ($array) { |
|
| 61 | + $this->_toArrayCall = function($array) { |
|
| 62 | 62 | return Arrays::columns2($array, [ |
| 63 | 63 | 'id' => 'd_id', |
| 64 | 64 | 'name' => 'd_name', |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function fetchById($id) |
| 81 | 81 | { |
| 82 | - $this->_result = (array) Json::get(Http::get('http://api.jinsapi.com/yingshi/getVodById', [ |
|
| 82 | + $this->_result = (array)Json::get(Http::get('http://api.jinsapi.com/yingshi/getVodById', [ |
|
| 83 | 83 | 'd_id' => $id, |
| 84 | 84 | ]), 'data', []); |
| 85 | - $this->_toArrayCall = function ($array) { |
|
| 85 | + $this->_toArrayCall = function($array) { |
|
| 86 | 86 | return Arrays::columns1($array, [ |
| 87 | 87 | 'id' => 'd_id', |
| 88 | 88 | 'name' => 'd_name', |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | 'lang' => 'd_lang', |
| 94 | 94 | 'year' => 'd_year', |
| 95 | 95 | 'description' => 'd_content', |
| 96 | - 'episodes' => function ($array) { |
|
| 97 | - $episodes = explode('#', (string) I::get($array, 'd_playurl')); |
|
| 96 | + 'episodes' => function($array) { |
|
| 97 | + $episodes = explode('#', (string)I::get($array, 'd_playurl')); |
|
| 98 | 98 | return Arrays::explode('$', $episodes); |
| 99 | 99 | }, |
| 100 | 100 | ]); |