rabin 1 månad sedan
förälder
incheckning
8f54df9e41

+ 2 - 2
src/Dever/Config.php

@@ -1,14 +1,14 @@
 <?php namespace Dever;
 class Config
 {
-    protected static $data = array();
+    protected static $data = [];
     public static function get($key = 'setting', $data = false)
     {
         if (empty(self::$data[$key])) {
             $path = DEVER_PROJECT_PATH . 'config' . DIRECTORY_SEPARATOR;
             $env = self::env($path);
             $file = $path . $key . '.php';
-            self::$data[$key] = array();
+            self::$data[$key] = [];
             if (is_file($file)) {
                 self::$data[$key] = include($file);
             }

+ 6 - 6
src/Dever/Debug.php

@@ -12,8 +12,8 @@ class Debug
     {
         ini_set('display_errors', true);
         self::$start = microtime();
-        set_error_handler(array(__CLASS__, 'error_handler'), E_ERROR | E_NOTICE | E_STRICT);
-        set_exception_handler(array(__CLASS__, 'exception_handler'));
+        set_error_handler([__CLASS__, 'error_handler'], E_ERROR | E_NOTICE | E_STRICT);
+        set_exception_handler([__CLASS__, 'exception_handler']);
         self::$shell = Dever::shell(Config::get('setting')['shell']);
     }
     public static function error_handler($no, $str, $file, $line)
@@ -47,7 +47,7 @@ class Debug
         if (self::$shell) {
             $msg = $data;
             if ($type) {
-                $msg = is_array($msg) ? $msg : array('msg' => $msg);
+                $msg = is_array($msg) ? $msg : ['msg' => $msg];
                 $msg = array_merge($msg, self::env());
             }
             self::data($type, Output::format($msg));
@@ -112,7 +112,7 @@ class Debug
         if (self::$trace) {
             return array_reverse(array_values(self::$trace));
         }
-        return array();
+        return [];
     }
     private static function env()
     {
@@ -134,7 +134,7 @@ class Debug
     private static function check($value)
     {
         if (isset($value['file']) && strpos($value['file'], DEVER_APP_PATH) !== false) {
-            $config = array('lib', 'api', 'table');
+            $config = ['lib', 'api', 'table'];
             foreach ($config as $k => $v) {
                 if (strpos($value['file'], DEVER_APP_PATH . $v) !== false) {
                     return true;
@@ -179,7 +179,7 @@ class Debug
     private static function load()
     {
         $files = get_included_files();
-        $result = array();
+        $result = [];
         $path = DEVER_PATH;
         foreach ($files as $k => $v) {
             if (strpos($v, $path) === false) {

+ 2 - 2
src/Dever/Helper/Arr.php

@@ -3,7 +3,7 @@ class Arr
 {
     public static function replace($replace, $value, $key = 'col')
     {
-        $result = array();
+        $result = [];
         foreach ($replace as $k => $v) {
             if (isset($value[$k])) {
                 $v = $value[$k];
@@ -26,7 +26,7 @@ class Arr
                 $sort($arr);
             }
         }
-        $result = array();
+        $result = [];
         foreach ($arr as $k => $v) {
             if (null === $v) {
                 continue;

+ 2 - 2
src/Dever/Helper/Cmd.php

@@ -2,7 +2,7 @@
 use Dever;
 class Cmd
 {
-    public static function run($api, $param = array(), $app = false, $daemon = true)
+    public static function run($api, $param = [], $app = false, $daemon = true)
     {
         if (strpos($api, 'http') !== false) {
             return self::shell('curl "' . $api . '"');
@@ -45,7 +45,7 @@ class Cmd
         }
         //$shell = escapeshellcmd($shell);
         exec($shell, $output, $state);
-        return array($state == 0, $output);
+        return [$state == 0, $output];
     }
     public static function bash($cmd)
     {

+ 2 - 2
src/Dever/Helper/Code.php

@@ -14,8 +14,8 @@ class Code
         }
         $cal = array
             (
-            array('+', '+'),
-            array('-', '-'),
+            ['+', '+'],
+            ['-', '-'],
         );
         $index = array_rand($cal);
         $m1 = rand(1, 100);

+ 7 - 7
src/Dever/Helper/Curl.php

@@ -7,8 +7,8 @@ class Curl
     private $get_info = false;
     private $log = false;
     private $result_header = false;
-    private $param = array();
-    private $header = array();
+    private $param = [];
+    private $header = [];
     public function load($url, $param = false, $type = '', $json = false, $header = false, $agent = false, $proxy = false, $refer = false)
     {
         if ($type == 'get_info') {
@@ -68,7 +68,7 @@ class Curl
     {
         if ($param && is_array($param) && isset($param[0])) {
             $temp = $param;
-            $param = array();
+            $param = [];
             foreach ($temp as $k => $v) {
                 if (is_array($v)) {
                     $param = array_merge($param, $v);
@@ -184,15 +184,15 @@ class Curl
             }
             curl_setopt($this->handle, CURLOPT_HEADER, false);
             if ($this->result_header) {
-                $this->result_header = array();
-                curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, array($this, 'headerHandler'));
+                $this->result_header = [];
+                curl_setopt($this->handle, CURLOPT_HEADERFUNCTION, [$this, 'headerHandler']);
             }
             if (Dever::shell('debug')) {
                 curl_setopt($this->handle, CURLINFO_HEADER_OUT, true);
             }
             curl_setopt($this->handle, CURLOPT_ACCEPT_ENCODING, 'gzip,deflate');
             $result = curl_exec($this->handle);
-            $debug = array();
+            $debug = [];
             if (Dever::shell('debug')) {
                 $debug['request'] = curl_getinfo($this->handle, CURLINFO_HEADER_OUT);
             } elseif ($this->get_info) {
@@ -220,7 +220,7 @@ class Curl
             return 'error';
         }
     }
-    public function setting($setting = array())
+    public function setting($setting = [])
     {
         if ($setting) {
             $this->init();

+ 13 - 13
src/Dever/Helper/Date.php

@@ -12,7 +12,7 @@ class Date
         }
         $n = 0;
         if (strstr($v, 'T')) {
-            $v = str_replace(array('T', 'Z'), ' ', $v);
+            $v = str_replace(['T', 'Z'], ' ', $v);
             $n = 8*3600;
         }
         if (strstr($v, ' ')) {
@@ -20,7 +20,7 @@ class Date
             $v = $t[0];
             $s = explode(':', $t[1]);
         } else {
-            $s = array(0, 0, 0);
+            $s = [0, 0, 0];
         }
         if (!isset($s[1])) {
             $s[1] = 0;
@@ -37,7 +37,7 @@ class Date
             $t[2] = $u[1];
         }
         if (!isset($t)) {
-            $t = array(0, 0, 0);
+            $t = [0, 0, 0];
         }
         if (!isset($t[1])) {
             $t[1] = '-1';
@@ -61,13 +61,13 @@ class Date
             }
         }
         $config = array(
-            array(31536000, 'Y', '年'),
-            array(2592000, 'T', '个月'),
-            array(604800, 'W', '星期'),
-            array(86400, 'D', '天'),
-            array(3600, 'H', '小时'),
-            array(60, 'M', '分钟'),
-            array(1, 'S', '秒'),
+            [31536000, 'Y', '年'],
+            [2592000, 'T', '个月'],
+            [604800, 'W', '星期'],
+            [86400, 'D', '天'],
+            [3600, 'H', '小时'],
+            [60, 'M', '分钟'],
+            [1, 'S', '秒'],
         );
         if ($type == 2) {
             foreach ($config as $k => $v) {
@@ -104,7 +104,7 @@ class Date
         }
         $start = self::mktime(date('Y-m-d 00:00:00', strtotime('this week Monday', $time)));
         $end = self::mktime(date('Y-m-d 23:59:59', strtotime('this week Sunday', $time)));
-        return array($start, $end);
+        return [$start, $end];
     }
 
     # 获取月的开始时间和结束时间
@@ -120,7 +120,7 @@ class Date
         list($year, $month, $end) = explode('-', date('Y-m-t', $time));
         $start = self::mktime($year . '-' . $month . '-01 00:00:00');
         $end = self::mktime($year . '-' . $month . '-' . $end . ' 23:59:59');
-        return array($start, $end);
+        return [$start, $end];
     }
     # 获取天的开始时间和结束时间
     public static function day($time = false, $prefix = '-')
@@ -135,7 +135,7 @@ class Date
         list($year, $month, $day) = explode('-', date('Y-m-d', $time));
         $start = self::mktime($year . '-' . $month . '-' . $day . ' 00:00:00');
         $end = self::mktime($year . '-' . $month . '-' . $day . ' 23:59:59');
-        return array($start, $end);
+        return [$start, $end];
     }
     # 获取毫秒
     public static function mtime()

+ 2 - 2
src/Dever/Helper/Env.php

@@ -145,7 +145,7 @@ class Env
             $mobile_browser++;
         }
         $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
-        $mobile_agents = array(
+        $mobile_agents = [
             'w3c ', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac',
             'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno',
             'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-',
@@ -155,7 +155,7 @@ class Env
             'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-',
             'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp',
             'wapr', 'webc', 'winw', 'winw', 'xda', 'xda-',
-        );
+        ];
         if (in_array($mobile_ua, $mobile_agents)) {
             $mobile_browser++;
         }

+ 3 - 3
src/Dever/Helper/Lang.php

@@ -1,8 +1,8 @@
 <?php namespace Dever\Helper;
 class Lang
 {
-    private static $data = array();
-    public static function get($key = 'host', $param = array())
+    private static $data = [];
+    public static function get($key = 'host', $param = [])
     {
         $name = 'lang/' . Config::get('setting')['lang'];
         if (empty(self::$data[$name])) {
@@ -27,7 +27,7 @@ class Lang
     private static function param($param)
     {
         if (is_string($param)) {
-            $param = array($param);
+            $param = [$param];
         }
         return $param;
     }

+ 6 - 6
src/Dever/Helper/Math.php

@@ -5,12 +5,12 @@ class Math
     public static function cartesian($data)
     {
         $len = count($data);
-        $result = array();
+        $result = [];
         if ($len == 1) {
             foreach ($data[0] as $k => $v) {
                 if (is_array($v)) {
                     foreach ($v as $k1 => $v1) {
-                        $v[$k1] = array($v1);
+                        $v[$k1] = [$v1];
                     }
                 }
                 $result[] = $v;
@@ -24,10 +24,10 @@ class Math
                 foreach ($arr as $v) {
                     foreach($data[$i] as $v1) { 
                         if(!is_array($v)) {
-                            $v = array($v);
+                            $v = [$v];
                         }
                         if(!is_array($v1)){
-                            $v1 = array($v1);
+                            $v1 = [$v1];
                         }
                         $result[] = array_merge_recursive($v, $v1);
                     }
@@ -67,8 +67,8 @@ class Math
         if($amount < 0) {
             $result = '负';
         }
-        $digital = array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
-        $position = array('仟', '佰', '拾', '亿', '仟', '佰', '拾', '万', '仟', '佰', '拾', '元');
+        $digital = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
+        $position = ['仟', '佰', '拾', '亿', '仟', '佰', '拾', '万', '仟', '佰', '拾', '元'];
         $amountArr = explode('.', $amount);
         $integerArr = str_split($amountArr[0], 1);
         $integerArrLength = count($integerArr);

+ 10 - 10
src/Dever/Helper/Secure.php

@@ -15,7 +15,7 @@ class Secure
         $auth = Dever::json_decode(self::decode($signature));
         if (isset($auth[0]) && isset($auth[1]) && $auth[0]) {
             if (time() - $auth[1] < $time) {
-                return array('uid' => $auth[0], 'time' => $auth[1], 'extend' => $auth[2]);
+                return ['uid' => $auth[0], 'time' => $auth[1], 'extend' => $auth[2]];
             }
         }
         return false;
@@ -28,14 +28,14 @@ class Secure
         $time = $request['time'] ?? self::timestamp();
         $nonce = $request['nonce'] ?? self::nonce();
         $signature = self::signature($time, $nonce, $request);
-        $request += array (
+        $request += [
             'time' => $time,
             'nonce' => $nonce,
             'signature' => $signature,
-        );
+        ];
         return $request;
     }
-    public static function check($request = array(), $time = 300, $token = false)
+    public static function check($request = [], $time = 300, $token = false)
     {
         if ($token) {
             self::$token = $token;
@@ -65,7 +65,7 @@ class Secure
         }
         return $signature;
     }
-    public static function signature($time, $nonce, $request = array())
+    public static function signature($time, $nonce, $request = [])
     {
         if (isset($request['signature'])) {
             unset($request['signature']);
@@ -125,7 +125,7 @@ class Secure
         $string_length = strlen($string);
         $result = '';
         $box = range(0, 255);
-        $rndkey = array();
+        $rndkey = [];
         for ($i = 0; $i <= 255; $i++) {
             $rndkey[$i] = ord($cryptkey[$i % $key_length]); //生成一个255个元素的数组
         }
@@ -165,7 +165,7 @@ class Secure
         $string_length = strlen($string);
         $result = '';
         $box = range(0, 255);
-        $rndkey = array();
+        $rndkey = [];
         for ($i = 0; $i <= 255; $i++) {
             $rndkey[$i] = ord($cryptkey[$i % $key_length]);
         }
@@ -197,7 +197,7 @@ class Secure
             return false;
         }
         $encodestr = base64_encode($string);
-        $encodestr = str_replace(array('+', '/'), array('-', '_'), $encodestr);
+        $encodestr = str_replace(['+', '/'], ['-', '_'], $encodestr);
         return $encodestr;
     }
     public static function base64_decode($string)
@@ -205,7 +205,7 @@ class Secure
         if (!$string) {
             return false;
         }
-        $string = str_replace(array('-', '_'), array('+', '/'), $string);
+        $string = str_replace(['-', '_'], ['+', '/'], $string);
         $decodestr = base64_decode($string);
         return $decodestr;
     }
@@ -216,7 +216,7 @@ class Secure
         }
         $data = htmlspecialchars_decode($data);
         $data = str_replace('\/', '/', $data);
-        $data = str_replace(array('&amp;', '&lt;', '&gt;'), array('&amp;amp;', '&amp;lt;', '&amp;gt;'), $data);
+        $data = str_replace(['&amp;', '&lt;', '&gt;'], ['&amp;amp;', '&amp;lt;', '&amp;gt;'], $data);
         $data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
         $data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
         $data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');

+ 8 - 8
src/Dever/Helper/Str.php

@@ -28,13 +28,13 @@ class Str
     }
     public static function rand($len, $type = 4)
     {
-        $source = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
+        $source = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
         $config = array (
-            0 => array("min" => 0, "max" => 9), /// 全数字
-            1 => array("min" => 10, "max" => 35), /// 全小写
-            2 => array("min" => 36, "max" => 61), /// 全大写
-            3 => array("min" => 10, "max" => 61), /// 大小写
-            4 => array("min" => 0, "max" => 61), /// 数字+大小写
+            0 => ["min" => 0, "max" => 9], /// 全数字
+            1 => ["min" => 10, "max" => 35], /// 全小写
+            2 => ["min" => 36, "max" => 61], /// 全大写
+            3 => ["min" => 10, "max" => 61], /// 大小写
+            4 => ["min" => 0, "max" => 61], /// 数字+大小写
         );
         if (!isset($config[$type])) {
             $type = 4;
@@ -234,7 +234,7 @@ class Str
     public static function explode($value, $num = 2)
     {
         $len = mb_strlen($value);
-        $result = array();
+        $result = [];
         for ($i = 0; $i < $len; $i = $i + $num) {
             $result[$i / $num] = mb_substr($value, $i, $num);
         }
@@ -283,7 +283,7 @@ class Str
         }
         return false;
     }
-    public static function val($show, $data = array())
+    public static function val($show, $data = [])
     {
         if ($data && strpos($show, '{') !== false && strpos($show, '{"') === false) {
             $func = function ($r) use ($data) {

+ 2 - 2
src/Dever/Import.php

@@ -36,7 +36,7 @@ class Import
             if ($param && is_array($param) && !isset($param[0])) {
                 $reflectionMethod = new \ReflectionMethod($this->class, $method);
                 $data = $reflectionMethod->getParameters();
-                $result = array();
+                $result = [];
                 foreach ($data as $k => $v) {
                     $name = $v->name;
                     if (isset($param[$name])) {
@@ -46,7 +46,7 @@ class Import
                 $param = $result;
             } else {
                 if (!is_array($param)) {
-                    $param = array($param);
+                    $param = [$param];
                 }
             }
         }

+ 1 - 1
src/Dever/Log.php

@@ -109,7 +109,7 @@ class Log
         if ($content) {
             return explode("\n", $content); 
         }
-        return array();    
+        return [];    
     }
     public static function filter($string)
     {

+ 24 - 24
src/Dever/Model.php

@@ -5,7 +5,7 @@ class Model
     protected $method = '';
     protected $store;
     protected $partition = false;
-    public $config = array();
+    public $config = [];
     public function __construct($table, $app, $store, $partition, $path)
     {
         $project = Project::load($app);
@@ -125,11 +125,11 @@ class Model
     {
         return $this->store->optimize($this->config['table']);
     }
-    public function load($param, $set = array(), $lock = false)
+    public function load($param, $set = [], $lock = false)
     {
         return $this->store->load($this->config['table'], $param, $set, $this->config['struct'], $lock);
     }
-    public function select($param, $set = array(), $lock = false)
+    public function select($param, $set = [], $lock = false)
     {
         if (isset($this->partition['where']) && $this->partition['where']) {
             $param = array_merge($this->partition['where'], $param);
@@ -157,11 +157,11 @@ class Model
         }
         return $result;
     }
-    public function find($param, $set = array(), $lock = false)
+    public function find($param, $set = [], $lock = false)
     {
         if (isset($this->partition['where']) && $this->partition['where']) {
             if (is_numeric($param)) {
-                $param = array('id' => $param);
+                $param = ['id' => $param];
             }
             $param = array_merge($this->partition['where'], $param);
         }
@@ -173,12 +173,12 @@ class Model
     }
     public function column($param, $field = 'name', $default = '')
     {
-        $info = $this->find($param, array('col' => $field . ' as value'));
+        $info = $this->find($param, ['col' => $field . ' as value']);
         return $info ? $info['value'] : $default;
     }
     public function columns($param, $field = 'id')
     {
-        return $this->kv($param, array('col' => $field));
+        return $this->kv($param, ['col' => $field]);
     }
     public function count($param)
     {
@@ -191,13 +191,13 @@ class Model
         }
         return $this->store->count($this->config['table'], $param, $this->config['struct']);
     }
-    public function kv($param, $set = array())
+    public function kv($param, $set = [])
     {
-        $result = array();
+        $result = [];
         $data = $this->select($param, $set);
         if ($data) {
             if (empty($set['kv'])) {
-                $set['kv'] = array('id', 'name');
+                $set['kv'] = ['id', 'name'];
             }
             if (isset($set['kv'][1])) {
                 foreach ($data as $k => $v) {
@@ -213,7 +213,7 @@ class Model
     }
     public function up($param, $data, $lock = false)
     {
-        $info = $this->find($param, array(), $lock);
+        $info = $this->find($param, [], $lock);
         if ($info) {
             $state = $this->update($info['id'], $data);
             if ($state) {
@@ -237,10 +237,10 @@ class Model
     public function update($param, $data, $lock = false)
     {
         if ($lock && isset($this->config['struct']['lock'])) {
-            $info = $this->find($param, array('col' => 'id,lock'));
+            $info = $this->find($param, ['col' => 'id,lock']);
             if ($info) {
                 $param['lock'] = $info['lock'];
-                $data['lock'] = array('+', 1);
+                $data['lock'] = ['+', 1];
             } else {
                 return false;
             }
@@ -263,7 +263,7 @@ class Model
     {
         return $this->store->rollback();
     }
-    public function query($sql, $bind = array(), $page = array())
+    public function query($sql, $bind = [], $page = [])
     {
         if (strpos($sql, '{table}')) {
             $sql = str_replace('{table}', $this->config['table'], $sql);
@@ -307,7 +307,7 @@ class Model
             return $this->store->query($sql, $bind)->fetchColumn();
         }
     }
-    public function value($key, $value = false, $col = 'id,name', $data = array())
+    public function value($key, $value = false, $col = 'id,name', $data = [])
     {
         if (isset($this->config['option'][$key])) {
             $option = $this->config['option'][$key];
@@ -338,10 +338,10 @@ class Model
                 }
             } elseif (is_array($option) && !isset($option[0])) {
                 $temp = $option;
-                $option = array();
+                $option = [];
                 $col = explode(',', $col);
                 foreach ($temp as $k => $v) {
-                    $option[] = array($col[0] => $k, $col[1] => $v);
+                    $option[] = [$col[0] => $k, $col[1] => $v];
                 }
             }
             if ($value && $option) {
@@ -350,7 +350,7 @@ class Model
                 }
                 if (strpos($value, ',')) {
                     $temp = explode(',', $value);
-                    $result = array();
+                    $result = [];
                     foreach ($temp as $v) {
                         $state = Dever::in_array($option, $v);
                         if ($state) {
@@ -365,7 +365,7 @@ class Model
         }
         return false;
     }
-    public function tree($where, $config, $func = false, $set = array())
+    public function tree($where, $config, $func = false, $set = [])
     {
         $where[$config[0]] = $config[1];
         $data = $this->select($where, $set);
@@ -383,7 +383,7 @@ class Model
     }
     public function show($where, $field = 'name', $str = '、')
     {
-        $result = array();
+        $result = [];
         $data = $this->select($where);
         foreach ($data as $k => $v) {
             $result[] = $v[$field];
@@ -395,9 +395,9 @@ class Model
     {
         if (isset($this->config['request'][$method])) {
             $method = $this->config['request'][$method];
-            $param = array();
+            $param = [];
             if (isset($method['where'])) {
-                $temp = array();
+                $temp = [];
                 foreach ($method['where'] as $k => $v) {
                     if ($k == 'or' || $k == 'and') {
                         foreach ($v as $k1 => $v1) {
@@ -410,7 +410,7 @@ class Model
                 $param[] = $temp;
             }
             if (isset($method['data'])) {
-                $temp = array();
+                $temp = [];
                 foreach ($method['data'] as $k => $v) {
                     $this->callCreate($data, $temp, $k, $v);
                 }
@@ -434,7 +434,7 @@ class Model
                 $data[0][$k] = $v[2];
             }
             $i = $v[0];
-            $j = array($v[1], $data[0][$k]);
+            $j = [$v[1], $data[0][$k]];
         } else {
             if (empty($data[0][$k])) {
                 $data[0][$k] = $v;

+ 3 - 3
src/Dever/Output.php

@@ -5,7 +5,7 @@ class Output
     private static $format = 'json';
     public static function success($data, $uuid = false, $code = 200)
     {
-        $result = array();
+        $result = [];
         $result['status'] = 1;
         $result['msg'] = 'success';
         $result['data'] = $data;
@@ -22,7 +22,7 @@ class Output
     }
     public static function error($msg, $code = 500)
     {
-        $result = array();
+        $result = [];
         $result['status'] = 2;
         $result['code'] = $code;
         $result['msg'] = $msg;
@@ -47,7 +47,7 @@ class Output
     {
         $setting = Dever::config('setting');
         if (isset($setting['output_app']) && $setting['output_app'] && !in_array(DEVER_APP_NAME, $setting['output_app'])) {
-            $setting['output'] = array();
+            $setting['output'] = [];
         }
        
         if ($setting = Dever::issets($setting, 'output')) {

+ 2 - 2
src/Dever/Paginator.php

@@ -14,7 +14,7 @@ class Paginator
         self::$current = Route::input('pg', '', '', $page);
         $offset = self::$num * (self::$current-1);
         if ($offset >= 10000) {
-            return array($offset, self::$num);
+            return [$offset, self::$num];
         }
         return $offset . ',' . self::$num;
     }
@@ -82,7 +82,7 @@ class Paginator
     public static function link($page)
     {
         if (is_string(self::$link)) {
-            return Route::url(self::$link, array('pg' => $page));
+            return Route::url(self::$link, ['pg' => $page]);
         }
         return (self::$link)($page);
     }

+ 3 - 3
src/Dever/Project.php

@@ -1,7 +1,7 @@
 <?php namespace Dever;
 class Project
 {
-    protected static $content = array();
+    protected static $content = [];
     public static function init()
     {
         $file = File::get('app.php');
@@ -38,7 +38,7 @@ class Project
             if (isset(self::$content['manage'])) {
                 $manage = self::$content['manage'];
                 unset(self::$content['manage']);
-                self::$content = array_merge(array('manage' => $manage), self::$content);
+                self::$content = array_merge(['manage' => $manage], self::$content);
             }
             self::content($file);
             if (isset(self::$content['manage'])) {
@@ -64,7 +64,7 @@ class Project
                         $p = 'manage/api';
                     }
                     if (is_file($dir . $p . '/index.php')) {
-                        self::$content[$v] = array();
+                        self::$content[$v] = [];
                         if (strstr($name, 'package')) {
                             self::$content[$v]['path'] = DEVER_PATH . $k;
                             if ($v == 'manage') {

+ 3 - 3
src/Dever/Route.php

@@ -1,7 +1,7 @@
 <?php namespace Dever;
 class Route
 {
-    public static $data = array();
+    public static $data = [];
     protected static $type = '?l=';
     public static function input($key = false, $condition = '', $lang = '', $value = '')
     {
@@ -41,7 +41,7 @@ class Route
         }
         return $value;
     }
-    public static function url($uri = false, $param = array(), $auth = false, $rewrite = '')
+    public static function url($uri = false, $param = [], $auth = false, $rewrite = '')
     {
         if ($uri == false) {
             if (DEVER_APP_HOST) {
@@ -77,7 +77,7 @@ class Route
             }
             if ($param) {
                 $query = '';
-                $data = array();
+                $data = [];
                 $i = 1;
                 foreach ($param as $k => $v) {
                     $query .= $k . '=$' . $i . '&';

+ 6 - 6
src/Dever/Sql.php

@@ -66,7 +66,7 @@ class Sql
     }
     public static function alter($table, $struct, $data)
     {
-        $sql = array();
+        $sql = [];
         $alter = 'ALTER TABLE `' . $table . '` ';
         foreach ($data as $v) {
             $field = $v['Field'];
@@ -90,9 +90,9 @@ class Sql
         }
         return implode(';', $sql);
     }
-    public static function index($table, $index, $del = array())
+    public static function index($table, $index, $del = [])
     {
-        $sql = array();
+        $sql = [];
         $alter = 'ALTER TABLE `' . $table . '` ';
         foreach ($del as $v) {
             if ($v['Key_name'] != 'PRIMARY') {
@@ -150,7 +150,7 @@ class Sql
             return self::desc($table);
         }
     }
-    public static function select($table, $param, &$bind, $set = array(), $field = array(), $lock = false, $type = '')
+    public static function select($table, $param, &$bind, $set = [], $field = [], $lock = false, $type = '')
     {
         $col = '*';
         $rule = '';
@@ -191,7 +191,7 @@ class Sql
         }
         return 'SELECT ' . $col . ' FROM ' . $table . self::where($param, $bind, $field, $type) . $rule;
     }
-    public static function where($param, &$bind, $field = array(), $type = '')
+    public static function where($param, &$bind, $field = [], $type = '')
     {
         if ($param) {
             $first = $second = '';
@@ -238,7 +238,7 @@ class Sql
         $type = '';
         if (is_string($b)) {
             $type = $b;
-            $b = array();
+            $b = [];
         }
         $g = '';
         if (strstr($k, '.')) {

+ 1 - 1
src/Dever/Store/Base.php

@@ -7,7 +7,7 @@ class Base
     protected $read;
     protected $update;
     protected $type;
-    public static $instance = array();
+    public static $instance = [];
     public static function getInstance($key, $setting, $partition)
     {
         if ($key == false) {

+ 8 - 8
src/Dever/Store/Influxdb.php

@@ -11,7 +11,7 @@ class Influxdb extends Base
         $this->type = $setting['type'];
         $this->read = $setting;
     }
-    public function query($param = array(), $type = 1)
+    public function query($param = [], $type = 1)
     {
         $header['Authorization'] = 'Token ' . $this->read['token'];
         $header['Content-Type'] = 'text/plain; charset=utf-8';
@@ -19,7 +19,7 @@ class Influxdb extends Base
         if ($type == 1) {
             $type = 'get';
             $host = $this->read['host'] . '/query?db='.$this->read['name'];
-            $param = array('q' => $param);
+            $param = ['q' => $param];
             $json = false;
         } else {
             $type = 'post';
@@ -34,7 +34,7 @@ class Influxdb extends Base
         */
         $result = Dever::curl($host, $param, $type, $json, $header)->result();
         if (Debug::$shell) {
-            $this->log(array('param' => $param, 'result' => $result));
+            $this->log(['param' => $param, 'result' => $result]);
         }
         return $result;
     }
@@ -46,14 +46,14 @@ class Influxdb extends Base
     }
     public function load($table, $param, $set, $field, $lock)
     {
-        $bind = array();
+        $bind = [];
         $sql = Sql::select($table, $param, $bind, $set, $field, $lock, $this->type);
         $data = $this->query($sql);
         $data = Dever::json_decode($data);
         if (isset($data['results'][0]['series'][0]['values'])) {
             return $data['results'][0]['series'][0];
         } else {
-            return array();
+            return [];
         }
     }
     public function select($table, $param, $set, $field, $lock)
@@ -62,7 +62,7 @@ class Influxdb extends Base
         if ($data) {
             $columns = $data['columns'];
             $values = $data['values'];
-            $result = array();
+            $result = [];
             foreach ($values as $k => $v) {
                 foreach ($columns as $k1 => $v1) {
                     $result[$k][$v1] = $this->set($v[$k1], $v1);
@@ -78,7 +78,7 @@ class Influxdb extends Base
         if ($data) {
             $columns = $data['columns'];
             $values = $data['values'];
-            $result = array();
+            $result = [];
             foreach ($columns as $k => $v) {
                 $result[$v] = $this->set($values[0][$k], $v);
             }
@@ -98,7 +98,7 @@ class Influxdb extends Base
     {
         $param = $table;
         $time = $data['cdate'];
-        $tags = $fields = array();
+        $tags = $fields = [];
         if (isset($data['id'])) {
             if (!$data['id']) {
                 $data['id'] = 1;

+ 37 - 38
src/Dever/Store/Mongo.php

@@ -20,7 +20,7 @@ class Mongo extends Base
             if (empty($setting['timeout'])) {
                 $setting['timeout'] = 1000;
             }
-            $handle = new Manager('mongodb://' . $setting['host'] . ':' . $setting['port'], array('username' => $setting['user'], 'password' => $setting['pwd'], 'connectTimeoutMS' => $setting['timeout']));
+            $handle = new Manager('mongodb://' . $setting['host'] . ':' . $setting['port'], ['username' => $setting['user'], 'password' => $setting['pwd'], 'connectTimeoutMS' => $setting['timeout']]);
             Debug::add('mongodb ' . $setting['host'] . ' connected', $setting['type']);
             return $handle;
         } catch (\PDOException $e) {
@@ -30,15 +30,15 @@ class Mongo extends Base
     public function index($config, $state = 0)
     {
         return;
-        $command = array('listIndexes' => $config['table']);
+        $command = ['listIndexes' => $config['table']];
         $result = $this->read->executeCommand($this->db, new Command($command));
         foreach ($result as $k => $v) {
             if ($v->name != '_id_') {
-                $command = array('dropIndexes' => $config['table'], 'index' => $v->name);
+                $command = ['dropIndexes' => $config['table'], 'index' => $v->name];
                 $this->read->executeCommand($this->db, new Command($command));
             }
         }
-        $index = array();
+        $index = [];
         foreach ($config['index'] as $k => $v) {
             $t = false;
             if (strpos($v, '.')) {
@@ -48,29 +48,28 @@ class Mongo extends Base
                 }
             }
             $v = explode(',', $v);
-            $key = array();
+            $key = [];
             foreach ($v as $v1) {
                 $key[$v1] = 1;
             }
-            $index[] = array
-            (
+            $index[] = [
                 'name' => $k,
                 'key' => $key,
                 'background' => false,
                 'unique' => $t
-            );
+            ];
         }
-        $command = array('createIndexes' => $config['table'],'indexes' => $index);
+        $command = ['createIndexes' => $config['table'],'indexes' => $index];
         $this->read->executeCommand($this->db, new Command($command));
     }
     public function load($table, $param, $set, $field, $lock)
     {
         $param = $this->param($param);
-        $options = array();
+        $options = [];
         if (isset($set['order'])) {
             if (is_string($set['order'])) {
                 $temp = explode(',', $set['order']);
-                $set['order'] = array();
+                $set['order'] = [];
                 foreach ($temp as $k => $v) {
                     $t = explode(' ', $v);
                     if ($t[0] == 'id') {
@@ -96,7 +95,7 @@ class Mongo extends Base
         }
         if (isset($set['col']) && $set['col'] && $set['col'] != '*') {
             $temp = explode(',', $set['col']);
-            $total = array();
+            $total = [];
             foreach ($temp as $k => $v) {
                 if (strstr($v, 'sum(')) {
                     if (strstr($v, ' as')) {
@@ -107,24 +106,24 @@ class Mongo extends Base
                         $k = $v;
                     }
                     $v = str_replace(array('sum(', ')'), '', $v);
-                    $total[$k] = array('$sum' => '$' . $v);
+                    $total[$k] = ['$sum' => '$' . $v];
                 } else {
                     $options['projection'][$v] = true;
                 }
             }
             if ($total && empty($set['group'])) {
-                $set['group'] = array();
+                $set['group'] = [];
                 foreach ($param as $k => $v) {
                     $set['group'][] = $k;
                 }
             }
         }
         if (isset($set['group'])) {
-            $pipeline = array();
+            $pipeline = [];
             if ($param) {
-                $pipeline[] = array('$match' => $param);
+                $pipeline[] = ['$match' => $param];
             }
-            $group = array();
+            $group = [];
             if ($set['group'] == 'null') {
                 $group = null;
             } else {
@@ -135,26 +134,26 @@ class Mongo extends Base
                     $group[$v] = '$' . $v;
                 }
             }
-            $group = array('_id' => $group);
+            $group = ['_id' => $group];
             if (isset($total) && $total) {
                 $group = array_merge($group, $total);
             } else {
-                $group['count'] = array('$sum' => 1);
+                $group['count'] = ['$sum' => 1];
             }
             if (isset($options['projection'])) {
                 foreach ($options['projection'] as $k => $v) {
-                    $group[$k] = array('$push' => '$' . $k);
+                    $group[$k] = ['$push' => '$' . $k];
                 }
             }
-            $pipeline[] = array('$group' => $group);
+            $pipeline[] = ['$group' => $group];
             if (isset($options['sort'])) {
-                $pipeline[] = array('$sort' => $options['sort']);
+                $pipeline[] = ['$sort' => $options['sort']];
             }
             if (isset($options['skip'])) {
-                $pipeline[] = array('$skip' => $options['skip']);
+                $pipeline[] = ['$skip' => $options['skip']];
             }
             if (isset($options['limit'])) {
-                $pipeline[] = array('$limit' => $options['limit']);
+                $pipeline[] = ['$limit' => $options['limit']];
             }
             $options = array('aggregate' => $table,'pipeline' => $pipeline,'cursor' => new \stdClass());
             $command = new Command($options);
@@ -164,13 +163,13 @@ class Mongo extends Base
             $result = $this->read->executeQuery($this->db . '.' . $table, $query);
         }
         if (Debug::$shell) {
-            $this->log(array('table' => $this->db . '.' . $table, 'param' => $param, 'option' => $options, 'result' => $result));
+            $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'option' => $options, 'result' => $result]);
         }
         return $result;
     }
     public function select($table, $param, $set, $field, $lock)
     {
-        $result = array();
+        $result = [];
         $data = $this->load($table, $param, $set, $field, $lock);
         foreach ($data as $k => $v) {
             $result[] = $this->handle($v);
@@ -179,7 +178,7 @@ class Mongo extends Base
     }
     public function find($table, $param, $set, $field, $lock)
     {
-        $result = array();
+        $result = [];
         $data = $this->load($table, $param, $set, $field, $lock);
         foreach ($data as $k => $v) {
             $result = $this->handle($v);
@@ -196,13 +195,13 @@ class Mongo extends Base
             $result = $data[0]->count;
         }
         if (Debug::$shell) {
-            $this->log(array('table' => $this->db . '.' . $table, 'param' => $param, 'result' => $result));
+            $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'result' => $result]);
         }
         return $result;
     }
     public function insert($table, $data, $field)
     {
-        $insert = array();
+        $insert = [];
         foreach ($data as $k => $v) {
             if ($field && empty($field[$k]) && strpos('id,cdate', $k) === false) {
                 continue;
@@ -230,7 +229,7 @@ class Mongo extends Base
         $id = $id['oid'];
         $result = $this->update->executeBulkWrite($this->db . '.' . $table, $bulk);
         if (Debug::$shell) {
-            $this->log(array('table' => $this->db . '.' . $table, 'insert' => $insert, 'result' => $id));
+            $this->log(['table' => $this->db . '.' . $table, 'insert' => $insert, 'result' => $id]);
         }
         if ($result->getInsertedCount() >= 1) {
             return $id;
@@ -239,7 +238,7 @@ class Mongo extends Base
     }
     public function update($table, $param, $data, $field)
     {
-        $update = array();
+        $update = [];
         foreach ($data as $k => $v) {
             if ($field && empty($field[$k]) && strpos('id,cdate', $k) === false) {
                 continue;
@@ -253,14 +252,14 @@ class Mongo extends Base
             }*/
             $update[$k] = $v;
         }
-        $update = array('$set' => $update);
+        $update = ['$set' => $update];
         $param = $this->param($param);
         $bulk = new BulkWrite;
-        $bulk->update($param, $update, array('multi' => true, 'upsert' => false));
+        $bulk->update($param, $update, ['multi' => true, 'upsert' => false]);
         $result = $this->update->executeBulkWrite($this->db . '.' . $table, $bulk);
         $result = $result->getModifiedCount();
         if (Debug::$shell) {
-            $this->log(array('table' => $this->db . '.' . $table, 'param' => $param, 'update' => $update, 'result' => $result));
+            $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'update' => $update, 'result' => $result]);
         }
         return $result;
     }
@@ -272,13 +271,13 @@ class Mongo extends Base
         $result = $this->update->executeBulkWrite($this->db . '.' . $table, $bulk);
         $result = $result->getDeletedCount();
         if (Debug::$shell) {
-            $this->log(array('table' => $this->db . '.' . $table, 'param' => $param, 'result' => $result));
+            $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'result' => $result]);
         }
         return $result;
     }
     private function param($param)
     {
-        $result = array();
+        $result = [];
         if ($param) {
             if (is_array($param)) {
                 foreach ($param as $k => $v) {
@@ -289,7 +288,7 @@ class Mongo extends Base
                         $k = '_id';
                     }
                     if ($k == 'or' || $k == 'and') {
-                        $where = array();
+                        $where = [];
                         foreach ($v as $k1 => $v1) {
                             if (strpos($k1, '#')) {
                                 $k1 = trim($k1, '#');
@@ -342,7 +341,7 @@ class Mongo extends Base
                 foreach ($value as $k => $v) {
                     $value[$k] = $this->value($key, $v);
                 }
-                $value = array('$' . $method => $value);
+                $value = ['$' . $method => $value];
                 break;
             case '>':
                 $value = array('$gt' => $this->value($key, $value));

+ 9 - 9
src/Dever/Store/Pdo.php

@@ -25,7 +25,7 @@ class Pdo extends Base
             if (empty($setting['persistent'])) {
                 $persistent = false;
             }
-            $handle = new \PDO($dsn, $setting['user'], $setting['pwd'], array(\PDO::ATTR_PERSISTENT => $persistent));
+            $handle = new \PDO($dsn, $setting['user'], $setting['pwd'], [\PDO::ATTR_PERSISTENT => $persistent]);
             $handle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             $handle->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL);
             $handle->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
@@ -75,7 +75,7 @@ class Pdo extends Base
             $this->query(Sql::create($config));
         }
         if (isset($config['default']) && $config['default']) {
-            $count = $this->count($config['table'], array(), $config['struct']);
+            $count = $this->count($config['table'], [], $config['struct']);
             if (!$count) {
                 $this->query(Sql::inserts($config['table'], $config['default']));
             }
@@ -89,7 +89,7 @@ class Pdo extends Base
     {
         $this->query(Sql::partition($config['table'], $partition, $this->query(Sql::showIndex($config['table']))));
     }
-    public function query($sql, $bind = array(), $method = 'read')
+    public function query($sql, $bind = [], $method = 'read')
     {
         try {
             if ($bind) {
@@ -113,7 +113,7 @@ class Pdo extends Base
     }
     public function load($table, $param, $set, $field, $lock)
     {
-        $bind = array();
+        $bind = [];
         $sql = Sql::select($table, $param, $bind, $set, $field, $lock);
         return $this->query($sql, $bind);
     }
@@ -131,33 +131,33 @@ class Pdo extends Base
     }
     public function explain($table, $param, $field)
     {
-        $bind = array();
+        $bind = [];
         $sql = sql::explain(Sql::select($table, $param, $bind, array('col'=>'count(*)'), $field, false));
         return $this->query($sql, $bind)->fetch();
     }
     public function insert($table, $data, $field)
     {
-        $bind = array();
+        $bind = [];
         $sql = Sql::insert($table, $data, $bind, $field);
         $this->query($sql, $bind, 'update');
         return $this->update->lastInsertId();
     }
     public function update($table, $param, $data, $field)
     {
-        $bind = array();
+        $bind = [];
         $sql = Sql::update($table, $param, $data, $bind, $field);
         return $this->query($sql, $bind, 'update')->rowCount();
     }
     public function delete($table, $param, $field)
     {
-        $bind = array();
+        $bind = [];
         $sql = Sql::delete($table, $param, $bind, $field);
         return $this->query($sql, $bind, 'update')->rowCount();
     }
     public function optimize($table)
     {
         $sql = Sql::optimize($table) . ';' . Sql::analyze($table);
-        return $this->query($sql, array(), 'update');
+        return $this->query($sql, [], 'update');
     }
     public function begin()
     {