Passed
Push — master ( c547da...5d2787 )
by 世昌
02:10 queued 15s
created
suda/src/component/debug/log/logger/FileLogger.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
      * @throws FileLoggerException
47 47
      * @param array $config
48 48
      */
49
-    public function __construct(array $config=[])
49
+    public function __construct(array $config = [])
50 50
     {
51 51
         $this->applyConfig($config);
52 52
         $temp = tmpfile();
53 53
         if ($temp === false) {
54
-            $this->tempname = $this->getConfig('save-path').'/log-'. microtime(true).'.tmp';
54
+            $this->tempname = $this->getConfig('save-path').'/log-'.microtime(true).'.tmp';
55 55
             $temp = fopen($this->tempname, 'w+');
56 56
         }
57 57
         if ($temp !== false) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file'));
61 61
         }
62 62
         $this->latest = $this->getConfig('save-path').'/'.$this->getConfig('file-name');
63
-        \register_shutdown_function([$this,'save']);
63
+        \register_shutdown_function([$this, 'save']);
64 64
     }
65 65
 
66 66
     public function getDefaultConfig():array
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     
79 79
     protected function packLogFile()
80 80
     {
81
-        $logFile= $this->latest;
82
-        $path=preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip');
81
+        $logFile = $this->latest;
82
+        $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip');
83 83
         $zip = new ZipArchive;
84 84
         $res = $zip->open($path, ZipArchive::CREATE);
85 85
         if ($res === true) {
86
-            if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) {
86
+            if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) {
87 87
                 array_push($this->removeFiles, $logFile);
88 88
             }
89 89
             if (\is_dir($this->getConfig('save-pack-path'))) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             $zip->close();
98 98
         } else {
99 99
             if (is_file($logFile) && file_exists($logFile)) {
100
-                rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log');
100
+                rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log');
101 101
             }
102 102
         }
103 103
     }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function checkSize():bool
111 111
     {
112
-        $logFile= $this->latest;
112
+        $logFile = $this->latest;
113 113
         if (file_exists($logFile)) {
114 114
             if (filesize($logFile) > $this->getConfig('max-file-size')) {
115 115
                 return true;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     public function log($level, string $message, array $context = [])
123 123
     {
124
-        if (LogLevel::compare($level, $this->getConfig('log-level')) >=0) {
124
+        if (LogLevel::compare($level, $this->getConfig('log-level')) >= 0) {
125 125
             $replace = [];
126 126
             $message = $this->interpolate($message, $context);
127 127
             $replace['%level%'] = $level;
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
     protected function rollLatest()
135 135
     {
136 136
         if (isset($this->latest)) {
137
-            $size=ftell($this->temp);
137
+            $size = ftell($this->temp);
138 138
             fseek($this->temp, 0);
139 139
             if ($size > 0) {
140
-                $body=fread($this->temp, $size);
140
+                $body = fread($this->temp, $size);
141 141
                 file_put_contents($this->latest, $body, FILE_APPEND);
142 142
             }
143 143
             fclose($this->temp);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             } elseif (is_null($val)) {
175 175
                 $val = 'null';
176 176
             }
177
-            $replace['{' . $key . '}'] = $val;
177
+            $replace['{'.$key.'}'] = $val;
178 178
         }
179 179
         return strtr($message, $replace);
180 180
     }
Please login to merge, or discard this patch.
suda/src/component/debug/log/logger/ConsoleLogger.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 {
11 11
     public function log($level, string $message, array $context = [])
12 12
     {
13
-        print date('Y-m-d H:i:s') .' ' . $this->interpolate($message, $context) . PHP_EOL;
13
+        print date('Y-m-d H:i:s').' '.$this->interpolate($message, $context).PHP_EOL;
14 14
     }
15 15
     public function interpolate(string $message, array $context)
16 16
     {
17 17
         $replace = [];
18 18
         foreach ($context as $key => $val) {
19
-            $replace['{' . $key . '}'] = $val;
19
+            $replace['{'.$key.'}'] = $val;
20 20
         }
21 21
         return strtr($message, $replace);
22 22
     }
Please login to merge, or discard this patch.
suda/src/component/debug/Caller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
     protected $ignorePath = [__FILE__];
10 10
     protected $backtrace;
11 11
 
12
-    public function __construct(array $backtrace, array $ignorePath =[])
12
+    public function __construct(array $backtrace, array $ignorePath = [])
13 13
     {
14 14
         $this->ignorePath = \array_merge($this->ignorePath, $ignorePath);
15 15
         $this->backtrace = $backtrace;
16 16
     }
17 17
 
18
-    public function getCallerTrace():?array
18
+    public function getCallerTrace(): ?array
19 19
     {
20 20
         foreach ($this->backtrace as $trace) {
21 21
             if (array_key_exists('file', $trace)) {
Please login to merge, or discard this patch.
suda/src/component/cacheable/CacheInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
      * @param int $expire 过期时间
16 16
      * @return bool
17 17
      */
18
-    public function set(string $name, $value, int $expire=null):bool;
18
+    public function set(string $name, $value, int $expire = null):bool;
19 19
 
20 20
     /**
21 21
      * 获取值
22 22
      * @param string $name 名
23 23
      * @return mixed|null
24 24
      */
25
-    public function get(string $name, $defalut=null);
25
+    public function get(string $name, $defalut = null);
26 26
 
27 27
     /**
28 28
      * 删除值
Please login to merge, or discard this patch.
suda/src/application/cache/FileCache.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
      * @param int $expire 过期时间
33 33
      * @return bool
34 34
      */
35
-    public function set(string $name, $value, int $expire=null):bool
35
+    public function set(string $name, $value, int $expire = null):bool
36 36
     {
37 37
         if ($this->disable()) {
38 38
             return false;
39 39
         }
40
-        $path=$this->getPath($name);
41
-        $this->value[$name]=$value;
40
+        $path = $this->getPath($name);
41
+        $this->value[$name] = $value;
42 42
         FileSystem::makes(dirname($path));
43
-        $value=serialize($value);
43
+        $value = serialize($value);
44 44
         if (is_null($expire)) {
45
-            $expire=time() + $this->defaultLiveTime;
45
+            $expire = time() + $this->defaultLiveTime;
46 46
         }
47
-        return file_put_contents($path, $expire.'|'.$value)!==false;
47
+        return file_put_contents($path, $expire.'|'.$value) !== false;
48 48
     }
49 49
 
50 50
     /**
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
      * @param string $name 名
53 53
      * @return mixed|null
54 54
      */
55
-    public function get(string $name, $defalut=null)
55
+    public function get(string $name, $defalut = null)
56 56
     {
57 57
         // 有值就获取值
58 58
         if (array_key_exists($name, $this->value)) {
59
-            $value=$this->value[$name];
59
+            $value = $this->value[$name];
60 60
             return $value;
61 61
         }
62 62
         // 没值就在cache文件中查找
63
-        $path=$this->getPath($name);
63
+        $path = $this->getPath($name);
64 64
         if (FileSystem::exist($path)) {
65
-            $value=FileSystem::get($path);
66
-            list($time, $value)=explode('|', $value, 2);
67
-            if (time()<intval($time)) {
65
+            $value = FileSystem::get($path);
66
+            list($time, $value) = explode('|', $value, 2);
67
+            if (time() < intval($time)) {
68 68
                 // 未过期则返回
69 69
                 return unserialize($value);
70 70
             } else {
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function has(string $name):bool
97 97
     {
98
-        return $this->get($name)!==null;
98
+        return $this->get($name) !== null;
99 99
     }
100 100
 
101 101
     /**
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function gc()
105 105
     {
106
-        $files=FileSystem::readFiles($this->path, true);
106
+        $files = FileSystem::readFiles($this->path, true);
107 107
         foreach ($files as $file) {
108
-            $value=FileSystem::get($file);
109
-            list($time, $value)=explode('|', $value, 2);
110
-            if (time()>intval($time)) {
108
+            $value = FileSystem::get($file);
109
+            list($time, $value) = explode('|', $value, 2);
110
+            if (time() > intval($time)) {
111 111
                 FileSystem::delete($file);
112 112
             }
113 113
         }
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
     private function getPath(string $name)
132 132
     {
133 133
         if (strpos($name, '.')) {
134
-            list($main, $sub)=explode('.', $name, 2);
134
+            list($main, $sub) = explode('.', $name, 2);
135 135
         } else {
136
-            $main=$name;
137
-            $sub=$name;
136
+            $main = $name;
137
+            $sub = $name;
138 138
         }
139
-        $fname= $this->path.'/'.$main.'/'.substr(md5($sub), 0, 4).'.cache';
139
+        $fname = $this->path.'/'.$main.'/'.substr(md5($sub), 0, 4).'.cache';
140 140
         return $fname;
141 141
     }
142 142
 }
Please login to merge, or discard this patch.
suda/src/application/Resource.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $path = $source;
30 30
         if (Path::isRelativePath($source)) {
31
-            $path =  $relative.'/'.$path;
31
+            $path = $relative.'/'.$path;
32 32
         }
33 33
         return Path::toAbsolutePath($path);
34 34
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param string $path
54 54
      * @return string|null
55 55
      */
56
-    public function getResourcePath(string $path):?string
56
+    public function getResourcePath(string $path): ?string
57 57
     {
58 58
         foreach ($this->resource as $root) {
59 59
             $target = $root.'/'.$path;
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
      * @param string $path
71 71
      * @return string|null
72 72
      */
73
-    public function getConfigResourcePath(string $path):?string
73
+    public function getConfigResourcePath(string $path): ?string
74 74
     {
75 75
         foreach ($this->resource as $root) {
76
-            if ( $target = Config::resolve($root.'/'.$path)) {
76
+            if ($target = Config::resolve($root.'/'.$path)) {
77 77
                 return $target;
78 78
             }
79 79
         }
Please login to merge, or discard this patch.
suda/src/application/Application.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -162,8 +162,8 @@
 block discarded – undo
162 162
      */
163 163
     protected function registerModuleManager()
164 164
     {
165
-       $this->manager = new Manager($this->getContext());
166
-       $this->manager->registerModule();
165
+        $this->manager = new Manager($this->getContext());
166
+        $this->manager->registerModule();
167 167
     }
168 168
 
169 169
     /**
Please login to merge, or discard this patch.
suda/src/application/response/Response.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function setStatus(int $code)
86 86
     {
87
-        $this->header->sendHeaderRaw('HTTP/1.1 '.$code.' '. Status::toText($code));
88
-        $this->header->sendHeader('Status', $code.' '. Status::toText($code));
87
+        $this->header->sendHeaderRaw('HTTP/1.1 '.$code.' '.Status::toText($code));
88
+        $this->header->sendHeader('Status', $code.' '.Status::toText($code));
89 89
     }
90 90
 
91 91
     /**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     public function render($value, string $echo = '', bool $allowEcho = true)
141 141
     {
142 142
         $this->header->send();
143
-        $wantEcho = strlen($echo) > 0 ;
143
+        $wantEcho = strlen($echo) > 0;
144 144
         $noReturn = $wantEcho && is_null($value);
145 145
         if ($noReturn && $wantEcho) {
146 146
             $this->send($echo);
Please login to merge, or discard this patch.
suda/src/application/response/provider/Status.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     public static $statusTexts = [
10 10
         100 => 'Continue',
11 11
         101 => 'Switching Protocols',
12
-        102 => 'Processing',            // RFC2518
12
+        102 => 'Processing', // RFC2518
13 13
         103 => 'Early Hints',
14 14
         200 => 'OK',
15 15
         201 => 'Created',
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
         204 => 'No Content',
19 19
         205 => 'Reset Content',
20 20
         206 => 'Partial Content',
21
-        207 => 'Multi-Status',          // RFC4918
22
-        208 => 'Already Reported',      // RFC5842
23
-        226 => 'IM Used',               // RFC3229
21
+        207 => 'Multi-Status', // RFC4918
22
+        208 => 'Already Reported', // RFC5842
23
+        226 => 'IM Used', // RFC3229
24 24
         300 => 'Multiple Choices',
25 25
         301 => 'Moved Permanently',
26 26
         302 => 'Found',
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         304 => 'Not Modified',
29 29
         305 => 'Use Proxy',
30 30
         307 => 'Temporary Redirect',
31
-        308 => 'Permanent Redirect',    // RFC7238
31
+        308 => 'Permanent Redirect', // RFC7238
32 32
         400 => 'Bad Request',
33 33
         401 => 'Unauthorized',
34 34
         402 => 'Payment Required',
@@ -47,34 +47,34 @@  discard block
 block discarded – undo
47 47
         415 => 'Unsupported Media Type',
48 48
         416 => 'Range Not Satisfiable',
49 49
         417 => 'Expectation Failed',
50
-        418 => 'I\'m a teapot',                                               // RFC2324
51
-        421 => 'Misdirected Request',                                         // RFC7540
52
-        422 => 'Unprocessable Entity',                                        // RFC4918
53
-        423 => 'Locked',                                                      // RFC4918
54
-        424 => 'Failed Dependency',                                           // RFC4918
55
-        425 => 'Too Early',                                                   // RFC-ietf-httpbis-replay-04
56
-        426 => 'Upgrade Required',                                            // RFC2817
57
-        428 => 'Precondition Required',                                       // RFC6585
58
-        429 => 'Too Many Requests',                                           // RFC6585
59
-        431 => 'Request Header Fields Too Large',                             // RFC6585
60
-        451 => 'Unavailable For Legal Reasons',                               // RFC7725
50
+        418 => 'I\'m a teapot', // RFC2324
51
+        421 => 'Misdirected Request', // RFC7540
52
+        422 => 'Unprocessable Entity', // RFC4918
53
+        423 => 'Locked', // RFC4918
54
+        424 => 'Failed Dependency', // RFC4918
55
+        425 => 'Too Early', // RFC-ietf-httpbis-replay-04
56
+        426 => 'Upgrade Required', // RFC2817
57
+        428 => 'Precondition Required', // RFC6585
58
+        429 => 'Too Many Requests', // RFC6585
59
+        431 => 'Request Header Fields Too Large', // RFC6585
60
+        451 => 'Unavailable For Legal Reasons', // RFC7725
61 61
         500 => 'Internal Server Error',
62 62
         501 => 'Not Implemented',
63 63
         502 => 'Bad Gateway',
64 64
         503 => 'Service Unavailable',
65 65
         504 => 'Gateway Timeout',
66 66
         505 => 'HTTP Version Not Supported',
67
-        506 => 'Variant Also Negotiates',                                     // RFC2295
68
-        507 => 'Insufficient Storage',                                        // RFC4918
69
-        508 => 'Loop Detected',                                               // RFC5842
70
-        510 => 'Not Extended',                                                // RFC2774
71
-        511 => 'Network Authentication Required',                             // RFC6585
67
+        506 => 'Variant Also Negotiates', // RFC2295
68
+        507 => 'Insufficient Storage', // RFC4918
69
+        508 => 'Loop Detected', // RFC5842
70
+        510 => 'Not Extended', // RFC2774
71
+        511 => 'Network Authentication Required', // RFC6585
72 72
     ];
73 73
 
74 74
     const HTTP_CONTINUE = 100;
75 75
     const HTTP_SWITCHING_PROTOCOLS = 101;
76
-    const HTTP_PROCESSING = 102;            // RFC2518
77
-    const HTTP_EARLY_HINTS = 103;           // RFC8297
76
+    const HTTP_PROCESSING = 102; // RFC2518
77
+    const HTTP_EARLY_HINTS = 103; // RFC8297
78 78
     const HTTP_OK = 200;
79 79
     const HTTP_CREATED = 201;
80 80
     const HTTP_ACCEPTED = 202;
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     const HTTP_NO_CONTENT = 204;
83 83
     const HTTP_RESET_CONTENT = 205;
84 84
     const HTTP_PARTIAL_CONTENT = 206;
85
-    const HTTP_MULTI_STATUS = 207;          // RFC4918
86
-    const HTTP_ALREADY_REPORTED = 208;      // RFC5842
87
-    const HTTP_IM_USED = 226;               // RFC3229
85
+    const HTTP_MULTI_STATUS = 207; // RFC4918
86
+    const HTTP_ALREADY_REPORTED = 208; // RFC5842
87
+    const HTTP_IM_USED = 226; // RFC3229
88 88
     const HTTP_MULTIPLE_CHOICES = 300;
89 89
     const HTTP_MOVED_PERMANENTLY = 301;
90 90
     const HTTP_FOUND = 302;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     const HTTP_USE_PROXY = 305;
94 94
     const HTTP_RESERVED = 306;
95 95
     const HTTP_TEMPORARY_REDIRECT = 307;
96
-    const HTTP_PERMANENTLY_REDIRECT = 308;  // RFC7238
96
+    const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238
97 97
     const HTTP_BAD_REQUEST = 400;
98 98
     const HTTP_UNAUTHORIZED = 401;
99 99
     const HTTP_PAYMENT_REQUIRED = 402;
@@ -112,21 +112,21 @@  discard block
 block discarded – undo
112 112
     const HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
113 113
     const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
114 114
     const HTTP_EXPECTATION_FAILED = 417;
115
-    const HTTP_I_AM_A_TEAPOT = 418;                                               // RFC2324
116
-    const HTTP_MISDIRECTED_REQUEST = 421;                                         // RFC7540
117
-    const HTTP_UNPROCESSABLE_ENTITY = 422;                                        // RFC4918
118
-    const HTTP_LOCKED = 423;                                                      // RFC4918
119
-    const HTTP_FAILED_DEPENDENCY = 424;                                           // RFC4918
115
+    const HTTP_I_AM_A_TEAPOT = 418; // RFC2324
116
+    const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540
117
+    const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
118
+    const HTTP_LOCKED = 423; // RFC4918
119
+    const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
120 120
 
121 121
     /**
122 122
      * @deprecated
123 123
      */
124
-    const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425;   // RFC2817
125
-    const HTTP_TOO_EARLY = 425;                                                   // RFC-ietf-httpbis-replay-04
126
-    const HTTP_UPGRADE_REQUIRED = 426;                                            // RFC2817
127
-    const HTTP_PRECONDITION_REQUIRED = 428;                                       // RFC6585
128
-    const HTTP_TOO_MANY_REQUESTS = 429;                                           // RFC6585
129
-    const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;                             // RFC6585
124
+    const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
125
+    const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04
126
+    const HTTP_UPGRADE_REQUIRED = 426; // RFC2817
127
+    const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585
128
+    const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585
129
+    const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585
130 130
     const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451;
131 131
     const HTTP_INTERNAL_SERVER_ERROR = 500;
132 132
     const HTTP_NOT_IMPLEMENTED = 501;
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
     const HTTP_SERVICE_UNAVAILABLE = 503;
135 135
     const HTTP_GATEWAY_TIMEOUT = 504;
136 136
     const HTTP_VERSION_NOT_SUPPORTED = 505;
137
-    const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506;                        // RFC2295
138
-    const HTTP_INSUFFICIENT_STORAGE = 507;                                        // RFC4918
139
-    const HTTP_LOOP_DETECTED = 508;                                               // RFC5842
140
-    const HTTP_NOT_EXTENDED = 510;                                                // RFC2774
137
+    const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295
138
+    const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918
139
+    const HTTP_LOOP_DETECTED = 508; // RFC5842
140
+    const HTTP_NOT_EXTENDED = 510; // RFC2774
141 141
     const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511;
142 142
 
143 143
     /**
Please login to merge, or discard this patch.