Passed
Branch main (941373)
by luo
02:37
created
Category
libs/MessageServices/ServerChan.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
      * @return bool
162 162
      * @throws \Exception
163 163
      */
164
-    public function send(string $content, string $subject = '', int $type = 1, array $data = [], ?string $recipient = null, ...$params)
164
+    public function send(string $content, string $subject = '', int $type = 1, array $data = [ ], ?string $recipient = null, ...$params)
165 165
     {
166 166
         $this->check($content, $data);
167 167
 
168 168
         if ($type === 1 || $type === 4) {
169 169
             // Do nothing
170 170
         } else if ($type === 2) {
171
-            $content = $this->genDomainRenewalResultsMarkDownText($data['username'], $data['renewalSuccessArr'], $data['renewalFailuresArr'], $data['domainStatusArr']);
171
+            $content = $this->genDomainRenewalResultsMarkDownText($data[ 'username' ], $data[ 'renewalSuccessArr' ], $data[ 'renewalFailuresArr' ], $data[ 'domainStatusArr' ]);
172 172
         } else if ($type === 3) {
173
-            $content = $this->genDomainStatusFullMarkDownText($data['username'], $data['domainStatusArr']);
173
+            $content = $this->genDomainStatusFullMarkDownText($data[ 'username' ], $data[ 'domainStatusArr' ]);
174 174
         } else {
175 175
             throw new \Exception(lang('error_msg.100003'));
176 176
         }
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
                 ]
189 189
             );
190 190
 
191
-            $resp = json_decode((string)$resp->getBody(), true);
191
+            $resp = json_decode((string) $resp->getBody(), true);
192 192
 
193
-            if (isset($resp['code']) && $resp['code'] === 0) {
193
+            if (isset($resp[ 'code' ]) && $resp[ 'code' ] === 0) {
194 194
                 return true;
195 195
             }
196 196
 
197
-            throw new \Exception($resp['message'] ?? '未知原因');
197
+            throw new \Exception($resp[ 'message' ] ?? '未知原因');
198 198
         } catch (\Exception $e) {
199 199
             system_log('Server酱 消息发送失败:<red>' . $e->getMessage() . '</red>');
200 200
 
Please login to merge, or discard this patch.
libs/Base.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @var array
14 14
      */
15
-    private static $instances = [];
15
+    private static $instances = [ ];
16 16
 
17 17
     /**
18 18
      * 添加单例
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public static function addInstance(string $className, bool $overwrite = false)
26 26
     {
27
-        if (isset(self::$instances[$className]) && !$overwrite) {
27
+        if (isset(self::$instances[ $className ]) && !$overwrite) {
28 28
             throw new \InvalidArgumentException(sprintf('类 %s 的实例已存在', $className));
29 29
         }
30 30
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
         $instance = new $className();
36 36
 
37
-        self::$instances[$className] = $instance;
37
+        self::$instances[ $className ] = $instance;
38 38
     }
39 39
 
40 40
     /**
@@ -47,19 +47,19 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public static function getInstance(...$params)
49 49
     {
50
-        $className = isset($params[1]) && $params[1] === 'IS_MESSAGE_SERVICE' ? $params[0] : static::class;
50
+        $className = isset($params[ 1 ]) && $params[ 1 ] === 'IS_MESSAGE_SERVICE' ? $params[ 0 ] : static::class;
51 51
 
52
-        if (!isset(self::$instances[$className])) {
52
+        if (!isset(self::$instances[ $className ])) {
53 53
             self::addInstance($className);
54 54
 
55 55
             // 由于自 php8 开始,is_callable 函数中如果使用类名,将不再适用于非静态方法,非静态方法必须使用对象实例,故只能将 init 从基类的
56 56
             // 普通构造函数迁移至此处,既可以实现单次调用非静态初始化方法,又不影响继承
57
-            if (is_callable([self::$instances[$className], 'init'])) {
58
-                self::$instances[$className]->init(...$params);
57
+            if (is_callable([ self::$instances[ $className ], 'init' ])) {
58
+                self::$instances[ $className ]->init(...$params);
59 59
             }
60 60
         }
61 61
 
62
-        return self::$instances[$className];
62
+        return self::$instances[ $className ];
63 63
     }
64 64
 
65 65
     private function __construct()
Please login to merge, or discard this patch.
libs/Connector/MessageServiceInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,5 +25,5 @@
 block discarded – undo
25 25
      *
26 26
      * @return bool
27 27
      */
28
-    public function send(string $content, string $subject = '', int $type = 1, array $data = [], ?string $recipient = null, ...$params);
28
+    public function send(string $content, string $subject = '', int $type = 1, array $data = [ ], ?string $recipient = null, ...$params);
29 29
 }
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
libs/Argv.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @var array 所有命令行参数
16 16
      */
17
-    public $allArgs = [];
17
+    public $allArgs = [ ];
18 18
 
19 19
     protected function init()
20 20
     {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function get(string $name, string $default = '')
50 50
     {
51
-        return $this->allArgs[$name] ?? $default;
51
+        return $this->allArgs[ $name ] ?? $default;
52 52
     }
53 53
 
54 54
     /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
         foreach ($argv as $a) { // Windows默认命令行无法正确传入使用引号括住的带空格参数,换个命令行终端就好,Linux不受影响
64 64
             if (preg_match('/^-{1,2}(?P<name>\w+)(?:=([\'"]|)(?P<val>[^\n\t\v\f\r\'"]+)\2)?$/i', $a, $m)) {
65
-                $this->allArgs[$m['name']] = $m['val'] ?? true;
65
+                $this->allArgs[ $m[ 'name' ] ] = $m[ 'val' ] ?? true;
66 66
             }
67 67
         }
68 68
 
Please login to merge, or discard this patch.
libs/Env.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * @var array 环境变量值
18 18
      */
19
-    protected $allValues = [];
19
+    protected $allValues = [ ];
20 20
 
21 21
     public function init($fileName = '.env', $overload = false)
22 22
     {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                 return null;
57 57
         }
58 58
 
59
-        if (($valueLength = strlen($value)) > 1 && $value[0] === '"' && $value[$valueLength - 1] === '"') { // 去除双引号
59
+        if (($valueLength = strlen($value)) > 1 && $value[ 0 ] === '"' && $value[ $valueLength - 1 ] === '"') { // 去除双引号
60 60
             return substr($value, 1, -1);
61 61
         }
62 62
 
Please login to merge, or discard this patch.
app/Console/FreeNom.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             throw new LlfException(34520004);
168 168
         }
169 169
 
170
-        return $matches['token'];
170
+        return $matches[ 'token' ];
171 171
     }
172 172
 
173 173
     /**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 'cookies' => $this->jar
187 187
             ]);
188 188
 
189
-            $page = (string)$resp->getBody();
189
+            $page = (string) $resp->getBody();
190 190
         } catch (\Exception $e) {
191 191
             throw new LlfException(34520013, $e->getMessage());
192 192
         }
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function renewAllDomains(array $allDomains, string $token)
210 210
     {
211
-        $renewalSuccessArr = [];
212
-        $renewalFailuresArr = [];
213
-        $domainStatusArr = [];
211
+        $renewalSuccessArr = [ ];
212
+        $renewalFailuresArr = [ ];
213
+        $domainStatusArr = [ ];
214 214
 
215 215
         foreach ($allDomains as $d) {
216
-            $domain = $d['domain'];
217
-            $days = (int)$d['days'];
218
-            $id = $d['id'];
216
+            $domain = $d[ 'domain' ];
217
+            $days = (int) $d[ 'days' ];
218
+            $id = $d[ 'id' ];
219 219
 
220 220
             // 免费域名只允许在到期前 14 天内续期
221 221
             if ($days <= 14) {
@@ -224,16 +224,16 @@  discard block
 block discarded – undo
224 224
                 sleep(1);
225 225
 
226 226
                 if ($renewalResult) {
227
-                    $renewalSuccessArr[] = $domain;
227
+                    $renewalSuccessArr[ ] = $domain;
228 228
 
229 229
                     continue; // 续期成功的域名无需记录过期天数
230 230
                 } else {
231
-                    $renewalFailuresArr[] = $domain;
231
+                    $renewalFailuresArr[ ] = $domain;
232 232
                 }
233 233
             }
234 234
 
235 235
             // 记录域名过期天数
236
-            $domainStatusArr[$domain] = $days;
236
+            $domainStatusArr[ $domain ] = $days;
237 237
         }
238 238
 
239 239
         // 存在续期操作
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 'cookies' => $this->jar
300 300
             ]);
301 301
 
302
-            $resp = (string)$resp->getBody();
302
+            $resp = (string) $resp->getBody();
303 303
 
304 304
             return stripos($resp, 'Order Confirmation') !== false;
305 305
         } catch (\Exception $e) {
@@ -319,27 +319,27 @@  discard block
 block discarded – undo
319 319
      *
320 320
      * @return bool
321 321
      */
322
-    public function arrayUnique(array &$array, array $keys = [])
322
+    public function arrayUnique(array &$array, array $keys = [ ])
323 323
     {
324
-        if (!isset($array[0]) || !is_array($array[0])) {
324
+        if (!isset($array[ 0 ]) || !is_array($array[ 0 ])) {
325 325
             return false;
326 326
         }
327 327
 
328 328
         if (empty($keys)) {
329
-            $keys = array_keys($array[0]);
329
+            $keys = array_keys($array[ 0 ]);
330 330
         }
331 331
 
332
-        $tmp = [];
332
+        $tmp = [ ];
333 333
         foreach ($array as $k => $items) {
334 334
             $combinedKey = '';
335 335
             foreach ($keys as $key) {
336
-                $combinedKey .= $items[$key];
336
+                $combinedKey .= $items[ $key ];
337 337
             }
338 338
 
339
-            if (isset($tmp[$combinedKey])) {
340
-                unset($array[$k]);
339
+            if (isset($tmp[ $combinedKey ])) {
340
+                unset($array[ $k ]);
341 341
             } else {
342
-                $tmp[$combinedKey] = $k;
342
+                $tmp[ $combinedKey ] = $k;
343 343
             }
344 344
         }
345 345
         unset($tmp);
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
      */
356 356
     protected function getAccounts()
357 357
     {
358
-        $accounts = [];
358
+        $accounts = [ ];
359 359
         $multipleAccounts = preg_replace('/\s/', '', env('MULTIPLE_ACCOUNTS'));
360 360
         if (preg_match_all('/<(?P<u>.*?)>@<(?P<p>.*?)>/i', $multipleAccounts, $matches, PREG_SET_ORDER)) {
361 361
             foreach ($matches as $m) {
362
-                $accounts[] = [
363
-                    'username' => $m['u'],
364
-                    'password' => $m['p']
362
+                $accounts[ ] = [
363
+                    'username' => $m[ 'u' ],
364
+                    'password' => $m[ 'p' ]
365 365
                 ];
366 366
             }
367 367
         }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         $username = env('FREENOM_USERNAME');
370 370
         $password = env('FREENOM_PASSWORD');
371 371
         if ($username && $password) {
372
-            $accounts[] = [
372
+            $accounts[ ] = [
373 373
                 'username' => $username,
374 374
                 'password' => $password
375 375
             ];
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 
414 414
         foreach ($accounts as $account) {
415 415
             try {
416
-                $this->username = $account['username'];
417
-                $this->password = $account['password'];
416
+                $this->username = $account[ 'username' ];
417
+                $this->password = $account[ 'password' ];
418 418
 
419 419
                 $this->jar = new CookieJar(); // 所有请求共用一个 CookieJar 实例
420 420
                 $this->login($this->username, $this->password);
Please login to merge, or discard this patch.
app/Console/MigrateEnvFile.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $allOldEnvValues = env();
62 62
 
63
-        unset($allOldEnvValues['ENV_FILE_VERSION']);
63
+        unset($allOldEnvValues[ 'ENV_FILE_VERSION' ]);
64 64
 
65
-        $allOldEnvValues = array_filter($allOldEnvValues, function ($val) {
65
+        $allOldEnvValues = array_filter($allOldEnvValues, function($val) {
66 66
             return $val !== '';
67 67
         });
68 68
 
69
-        $allOldEnvValues = array_map(function ($val) {
69
+        $allOldEnvValues = array_map(function($val) {
70 70
             $tmpVal = strtolower($val);
71 71
 
72 72
             if ($tmpVal === 'true' || $tmpVal === true) {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
             return null;
130 130
         }
131 131
 
132
-        return $this->getVerNum($m['env_file_version']);
132
+        return $this->getVerNum($m[ 'env_file_version' ]);
133 133
     }
134 134
 
135 135
     /**
Please login to merge, or discard this patch.
app/Console/Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     public function getVerNum($rawVer)
22 22
     {
23 23
         if (preg_match('/(?P<ver_num>\d+(?:\.\d+)*)/i', $rawVer, $m)) {
24
-            return $m['ver_num'];
24
+            return $m[ 'ver_num' ];
25 25
         }
26 26
 
27 27
         return null;
Please login to merge, or discard this patch.
app/Console/Upgrade.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     /**
26 26
      * @var array 与发布相关的信息
27 27
      */
28
-    public $releaseInfo = [];
28
+    public $releaseInfo = [ ];
29 29
 
30 30
     /**
31 31
      * @var string 最新版本号
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
             ]);
88 88
 
89 89
             $resp = $resp->getBody()->getContents();
90
-            $resp = (array)json_decode($resp, true);
90
+            $resp = (array) json_decode($resp, true);
91 91
 
92
-            if (!isset($resp['tag_name'])
93
-                || !isset($resp['body'])
94
-                || !isset($resp['name'])
95
-                || !isset($resp['published_at'])
96
-                || !isset($resp['html_url'])) {
92
+            if (!isset($resp[ 'tag_name' ])
93
+                || !isset($resp[ 'body' ])
94
+                || !isset($resp[ 'name' ])
95
+                || !isset($resp[ 'published_at' ])
96
+                || !isset($resp[ 'html_url' ])) {
97 97
                 throw new \Exception('Github 返回的数据与预期不一致:' . json_encode($resp, JSON_UNESCAPED_UNICODE));
98 98
             }
99 99
 
100 100
             $this->releaseInfo = $resp;
101 101
 
102
-            $this->latestVer = $this->getVerNum($resp['tag_name']);
102
+            $this->latestVer = $this->getVerNum($resp[ 'tag_name' ]);
103 103
             $this->currVer = $this->getVerNum(FreeNom::VERSION);
104 104
 
105 105
             return version_compare($this->latestVer, $this->currVer, '>');
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function rememberVer($ver)
139 139
     {
140
-        return (bool)file_put_contents($this->pushedVerFile, $ver . "\n", FILE_APPEND);
140
+        return (bool) file_put_contents($this->pushedVerFile, $ver . "\n", FILE_APPEND);
141 141
     }
142 142
 
143 143
     /**
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $content = sprintf(
151 151
             "见信好,我们在 %s 发布了新版 FreeNom 续期工具 v%s,而你当前正在使用的版本为 v%s,你可以根据自己的实际需要决定是否升级到新版本。今次新版有以下更新或改进:\n\n",
152
-            $this->friendlyDateFormat($this->releaseInfo['published_at'], 'UTC'),
152
+            $this->friendlyDateFormat($this->releaseInfo[ 'published_at' ], 'UTC'),
153 153
             $this->latestVer,
154 154
             $this->currVer
155 155
         );
156 156
 
157
-        $content .= $this->releaseInfo['body'];
157
+        $content .= $this->releaseInfo[ 'body' ];
158 158
 
159
-        $content .= "\n\n" . '欲知更多信息,请访问:' . $this->releaseInfo['html_url'];
159
+        $content .= "\n\n" . '欲知更多信息,请访问:' . $this->releaseInfo[ 'html_url' ];
160 160
 
161 161
         $content .= "\n\n" . '(本消息针对同一个新版只会推送一次,如果你不想收到新版本通知,将 .env 文件中的 NEW_VERSION_DETECTION 的值设为 0 即可)';
162 162
 
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
                     'FreeNom 续期工具有新的版本可用,你当前版本为 v%s,最新版本为 v%s。关于新版的详细信息,请访问:%s',
215 215
                     $this->currVer,
216 216
                     $this->latestVer,
217
-                    $this->releaseInfo['html_url']
217
+                    $this->releaseInfo[ 'html_url' ]
218 218
                 ));
219 219
             } else {
220 220
                 system_log(sprintf(
221 221
                     '<green>FreeNom 续期工具有新的版本可用,最新版本为 v%s(%s)</green>',
222 222
                     $this->latestVer,
223
-                    $this->releaseInfo['html_url']
223
+                    $this->releaseInfo[ 'html_url' ]
224 224
                 ));
225 225
 
226 226
                 $result = Message::send(
Please login to merge, or discard this patch.