@@ -50,7 +50,7 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public static function create($config = []) |
| 52 | 52 | { |
| 53 | - if (!static::$_instance instanceof static ) { |
|
| 53 | + if (!static::$_instance instanceof static) { |
|
| 54 | 54 | static::$_instance = new static(); |
| 55 | 55 | static::$_instance->__formName = I::get($config, 'formName', 'file'); |
| 56 | 56 | static::$_instance->__sizeLimit = static::$_instance->__getSizeLimit(I::get($config, 'sizeLimit', 0)); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public static function toBytes($size) |
| 81 | 81 | { |
| 82 | - $callback = function ($matches) { |
|
| 82 | + $callback = function($matches) { |
|
| 83 | 83 | $sizeMap = [ |
| 84 | 84 | '' => 0, |
| 85 | 85 | 'b' => 0, // 为了简化正则 |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | return $matches[1] * pow(1024, $sizeMap[strtolower($matches[2])]); |
| 94 | 94 | }; |
| 95 | 95 | |
| 96 | - return (int) preg_replace_callback('/(\d*)\s*([a-z]?)b?/i', $callback, $size, 1); |
|
| 96 | + return (int)preg_replace_callback('/(\d*)\s*([a-z]?)b?/i', $callback, $size, 1); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | if ($toBaseInput == '0123456789') { |
| 157 | 157 | $retval = 0; |
| 158 | 158 | for ($i = 1; $i <= $numberLen; $i++) { |
| 159 | - $retval = bcadd($retval, bcmul((string) array_search($number[$i - 1], $fromBase), bcpow($fromLen, $numberLen - $i))); |
|
| 159 | + $retval = bcadd($retval, bcmul((string)array_search($number[$i - 1], $fromBase), bcpow($fromLen, $numberLen - $i))); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return $retval; |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | $zoomWidth *= $this->_attributes['width']; |
| 153 | 153 | $zoomHeight *= $this->_attributes['height']; |
| 154 | 154 | } else { |
| 155 | - $zoom = (int) $zoom; |
|
| 155 | + $zoom = (int)$zoom; |
|
| 156 | 156 | $zoomWidth = $zoom * $this->_attributes['width']; |
| 157 | 157 | $zoomHeight = $zoom * $this->_attributes['height']; |
| 158 | 158 | } |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | throw new Exception('range error'); |
| 190 | 190 | } |
| 191 | 191 | $value = I::get($data, $field); |
| 192 | - $range = (array) I::get($rule, 'range', []); |
|
| 193 | - $isStrict = (bool) I::get($rule, 'isStrict', false); |
|
| 192 | + $range = (array)I::get($rule, 'range', []); |
|
| 193 | + $isStrict = (bool)I::get($rule, 'isStrict', false); |
|
| 194 | 194 | if (!in_array($value, $range, $isStrict)) { |
| 195 | 195 | $this->__messages[$field][] = I::get($rule, 'message', $field . ' 不在范围内'); |
| 196 | 196 | $this->__codes[$field][] = I::get($rule, 'code', self::CODE_VALIDATE_IN); |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | if (!array_key_exists('pattern', $rule)) { |
| 203 | 203 | throw new Exception('pattern error'); |
| 204 | 204 | } |
| 205 | - $value = (string) I::get($data, $field); |
|
| 206 | - $pattern = (string) I::get($rule, 'pattern', '//'); |
|
| 205 | + $value = (string)I::get($data, $field); |
|
| 206 | + $pattern = (string)I::get($rule, 'pattern', '//'); |
|
| 207 | 207 | if (!preg_match($pattern, $value)) { |
| 208 | 208 | $this->__messages[$field][] = I::get($rule, 'message', $field . ' 格式不正确'); |
| 209 | 209 | $this->__codes[$field][] = I::get($rule, 'code', self::CODE_VALIDATE_MATCH); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public static function ol($array) |
| 157 | 157 | { |
| 158 | - return implode(PHP_EOL, array_map(function ($row) { |
|
| 158 | + return implode(PHP_EOL, array_map(function($row) { |
|
| 159 | 159 | static $i = 1; |
| 160 | 160 | return ($i++) . '. ' . self::__text($row); |
| 161 | 161 | }, $array)); |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | $title = array_shift($array); |
| 211 | 211 | $rows = $array; |
| 212 | 212 | } |
| 213 | - $lineFunc = function ($arr) { |
|
| 214 | - return '|' . implode('|', array_map(function ($line) { |
|
| 213 | + $lineFunc = function($arr) { |
|
| 214 | + return '|' . implode('|', array_map(function($line) { |
|
| 215 | 215 | return ' ' . self::__text($line) . ' '; |
| 216 | 216 | }, $arr)) . '|'; |
| 217 | 217 | }; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function getHeader($name) |
| 103 | 103 | { |
| 104 | - return (string) Arrays::first((array) I::get($this->getHeaders(), $name, [])); |
|
| 104 | + return (string)Arrays::first((array)I::get($this->getHeaders(), $name, [])); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | if (isset($_POST[$this->__methodParam]) && !in_array($method = strtoupper($_POST[$this->__methodParam]), ['GET', 'HEAD', 'OPTIONS'])) { |
| 116 | 116 | return $method; |
| 117 | 117 | } |
| 118 | - if ($method = (string) I::get($this->getHeaders(), 'x-http-method-override')) { |
|
| 118 | + if ($method = (string)I::get($this->getHeaders(), 'x-http-method-override')) { |
|
| 119 | 119 | return strtoupper($method); |
| 120 | 120 | } |
| 121 | 121 | if (isset($_SERVER['REQUEST_METHOD'])) { |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $secure = $this->isSecureConnection(); |
| 418 | 418 | $http = $secure ? 'https' : 'http'; |
| 419 | 419 | if (I::get($this->getHeaders(), 'x-forwarded-host')) { |
| 420 | - $this->__hostInfo = $http . '://' . trim((string) Arrays::first(explode(',', $this->getHeader('x-forwarded-host')))); |
|
| 420 | + $this->__hostInfo = $http . '://' . trim((string)Arrays::first(explode(',', $this->getHeader('x-forwarded-host')))); |
|
| 421 | 421 | } elseif (I::get($this->getHeaders(), 'host')) { |
| 422 | 422 | $this->__hostInfo = $http . '://' . $this->getHeader('host'); |
| 423 | 423 | } elseif (isset($_SERVER['SERVER_NAME'])) { |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | */ |
| 618 | 618 | public function getQueryString() |
| 619 | 619 | { |
| 620 | - return (string) I::get($_SERVER, 'QUERY_STRING', ''); |
|
| 620 | + return (string)I::get($_SERVER, 'QUERY_STRING', ''); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | */ |
| 651 | 651 | public function getServerName() |
| 652 | 652 | { |
| 653 | - return (string) I::get($_SERVER, 'SERVER_NAME'); |
|
| 653 | + return (string)I::get($_SERVER, 'SERVER_NAME'); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | /** |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | */ |
| 661 | 661 | public function getServerPort() |
| 662 | 662 | { |
| 663 | - return (int) I::get($_SERVER, 'SERVER_PORT'); |
|
| 663 | + return (int)I::get($_SERVER, 'SERVER_PORT'); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | /** |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | */ |
| 716 | 716 | public function getRemoteIP() |
| 717 | 717 | { |
| 718 | - return (string) I::get($_SERVER, 'REMOTE_ADDR'); |
|
| 718 | + return (string)I::get($_SERVER, 'REMOTE_ADDR'); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | */ |
| 726 | 726 | public function getRemoteHost() |
| 727 | 727 | { |
| 728 | - return (string) I::get($_SERVER, 'REMOTE_HOST'); |
|
| 728 | + return (string)I::get($_SERVER, 'REMOTE_HOST'); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | $request = new Request(); |
| 76 | 76 | if (is_array($url)) { |
| 77 | 77 | $params = $url; |
| 78 | - $anchor = (string) I::get($url, '#', ''); |
|
| 78 | + $anchor = (string)I::get($url, '#', ''); |
|
| 79 | 79 | unset($params['#']); |
| 80 | 80 | $route = trim($params[0], '/'); |
| 81 | 81 | unset($params[0]); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $group = null; |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | - list($name, $value) = Arrays::lists(explode('=', $line), 2, function ($row) { |
|
| 112 | + list($name, $value) = Arrays::lists(explode('=', $line), 2, function($row) { |
|
| 113 | 113 | return trim($row); |
| 114 | 114 | }); |
| 115 | 115 | $array[$name] = $value; |
@@ -120,15 +120,15 @@ discard block |
||
| 120 | 120 | if (null === $group) { |
| 121 | 121 | $return = Arrays::merge($return, $array); |
| 122 | 122 | } else { |
| 123 | - $return[$group] = Arrays::merge((array) I::get($return, $group, []), $array); |
|
| 123 | + $return[$group] = Arrays::merge((array)I::get($return, $group, []), $array); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } elseif (self::TYPE_JSON === $this->_type) { |
| 127 | 127 | $content = $local->getFileContent($this->_file); |
| 128 | - $return = Json::decode((string) $content); |
|
| 128 | + $return = Json::decode((string)$content); |
|
| 129 | 129 | } elseif (self::TYPE_XML === $this->_type) { |
| 130 | 130 | $content = $local->getFileContent($this->_file); |
| 131 | - $return = Xml::toArray((string) $content); |
|
| 131 | + $return = Xml::toArray((string)$content); |
|
| 132 | 132 | } |
| 133 | 133 | return $return; |
| 134 | 134 | } |
@@ -203,7 +203,7 @@ |
||
| 203 | 203 | } elseif (false === $asFrame) { |
| 204 | 204 | self::send('X-Frame-Options: deny'); |
| 205 | 205 | } else { |
| 206 | - $asFrame = (string) $asFrame; |
|
| 206 | + $asFrame = (string)$asFrame; |
|
| 207 | 207 | self::send('X-Frame-Options: allow-from ' . $asFrame); |
| 208 | 208 | } |
| 209 | 209 | } |