Browse Source

[更新]基于标准优化代码

Anyon 7 years ago
parent
commit
ec30d927a7
2 changed files with 23 additions and 23 deletions
  1. 11 11
      application/common.php
  2. 12 12
      application/route.php

+ 11 - 11
application/common.php

@@ -24,7 +24,7 @@ use think\Db;
  * @param bool $replace
  * @param string|null $pathname
  */
-function p($data, $replace = false, $pathname = NULL)
+function p($data, $replace = false, $pathname = null)
 {
     is_null($pathname) && $pathname = RUNTIME_PATH . date('Ymd') . '.txt';
     $str = (is_string($data) ? $data : (is_array($data) || is_object($data)) ? print_r($data, true) : var_export($data, true)) . "\n";
@@ -38,19 +38,19 @@ function p($data, $replace = false, $pathname = NULL)
  */
 function & load_wechat($type = '')
 {
-    static $wechat = array();
+    static $wechat = [];
     $index = md5(strtolower($type));
     if (!isset($wechat[$index])) {
         $config = [
-            'token' => sysconf('wechat_token'),
-            'appid' => sysconf('wechat_appid'),
-            'appsecret' => sysconf('wechat_appsecret'),
+            'token'          => sysconf('wechat_token'),
+            'appid'          => sysconf('wechat_appid'),
+            'appsecret'      => sysconf('wechat_appsecret'),
             'encodingaeskey' => sysconf('wechat_encodingaeskey'),
-            'mch_id' => sysconf('wechat_mch_id'),
-            'partnerkey' => sysconf('wechat_partnerkey'),
-            'ssl_cer' => sysconf('wechat_cert_cert'),
-            'ssl_key' => sysconf('wechat_cert_key'),
-            'cachepath' => CACHE_PATH . 'wxpay' . DS,
+            'mch_id'         => sysconf('wechat_mch_id'),
+            'partnerkey'     => sysconf('wechat_partnerkey'),
+            'ssl_cer'        => sysconf('wechat_cert_cert'),
+            'ssl_key'        => sysconf('wechat_cert_key'),
+            'cachepath'      => CACHE_PATH . 'wxpay' . DS,
         ];
         $wechat[$index] = Loader::get($type, $config);
     }
@@ -122,7 +122,7 @@ function sysconf($name, $value = false)
  * array_column 函数兼容
  */
 if (!function_exists("array_column")) {
-
+    
     function array_column(array &$rows, $column_key, $index_key = null)
     {
         $data = [];

+ 12 - 12
application/route.php

@@ -14,38 +14,38 @@
 
 /*  测试环境禁止操作路由绑定 */
 think\Route::post([
-    'admin/config/index' => function() {
+    'admin/config/index'  => function () {
         return json(['code' => 0, 'msg' => '测试环境禁修改系统配置操作!']);
     },
-    'admin/config/file' => function() {
+    'admin/config/file'   => function () {
         return json(['code' => 0, 'msg' => '测试环境禁修改文件配置操作!']);
     },
-    'admin/menu/add' => function() {
+    'admin/menu/add'      => function () {
         return json(['code' => 0, 'msg' => '测试环境禁添加菜单操作!']);
     },
-    'admin/menu/edit' => function() {
+    'admin/menu/edit'     => function () {
         return json(['code' => 0, 'msg' => '测试环境禁编辑菜单操作!']);
     },
-    'admin/menu/forbid' => function() {
+    'admin/menu/forbid'   => function () {
         return json(['code' => 0, 'msg' => '测试环境禁止禁用菜单操作!']);
     },
-    'admin/menu/del' => function() {
+    'admin/menu/del'      => function () {
         return json(['code' => 0, 'msg' => '测试环境禁止删除菜单操作!']);
     },
-    'wechat/config/index' => function() {
+    'wechat/config/index' => function () {
         return json(['code' => 0, 'msg' => '测试环境禁止修改微信配置操作!']);
     },
-    'wechat/config/pay' => function() {
+    'wechat/config/pay'   => function () {
         return json(['code' => 0, 'msg' => '测试环境禁止修改微信支付操作!']);
     },
-    'wechat/menu/edit' => function() {
+    'wechat/menu/edit'    => function () {
         return json(['code' => 0, 'msg' => '测试环境禁止修改微信菜单操作!']);
-    }
+    },
 ]);
 think\Route::get([
-    'wechat/menu/cancel' => function() {
+    'wechat/menu/cancel' => function () {
         return json(['code' => 0, 'msg' => '测试环境禁止删除微信菜单操作!']);
-    }
+    },
 ]);
 
 return [];