Passed
Push — master ( 9d5835...e8364e )
by 世昌
02:16
created
suda/src/framework/debug/attach/DumpTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
     protected static function valueToString(string $key, $value, int $deep):string
68 68
     {
69 69
         if (is_string($value) && strlen($value) > static::$dumpStringLength) {
70
-            return  $key.'='.json_encode(substr($value, 0, static::$dumpStringLength), JSON_UNESCAPED_UNICODE) .'... ,';
70
+            return  $key.'='.json_encode(substr($value, 0, static::$dumpStringLength), JSON_UNESCAPED_UNICODE).'... ,';
71 71
         } elseif (is_bool($value)) {
72 72
             return $key.'='.($value ? 'true' : 'false').' ,';
73 73
         } else {
74
-            return $key.'='.self::parameterToString($value, $deep - 1) .' ,';
74
+            return $key.'='.self::parameterToString($value, $deep - 1).' ,';
75 75
         }
76 76
     }
77 77
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $argsDump = '';
120 120
         if (!empty($trace['args'])) {
121 121
             foreach ($trace['args'] as $arg) {
122
-                $argsDump .= self::parameterToString($arg) .',';
122
+                $argsDump .= self::parameterToString($arg).',';
123 123
             }
124 124
             $argsDump = rtrim($argsDump, ',');
125 125
         }
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 
130 130
     public static function dumpThrowable(Throwable $e)
131 131
     {
132
-        $dump = get_class($e).':'. $e->getMessage() .PHP_EOL;
133
-        $dump .= 'At: ' . $e->getFile().':'.$e->getLine().PHP_EOL;
132
+        $dump = get_class($e).':'.$e->getMessage().PHP_EOL;
133
+        $dump .= 'At: '.$e->getFile().':'.$e->getLine().PHP_EOL;
134 134
         $dump .= static::dumpTrace($e->getTrace());
135 135
         return $dump;
136 136
     }
Please login to merge, or discard this patch.
suda/src/framework/debug/attach/DumpInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  */
9 9
 interface DumpInterface 
10 10
 {
11
-    public static function parameterToString($object, int $deep=2);
11
+    public static function parameterToString($object, int $deep = 2);
12 12
     public static function dumpThrowable(Throwable $e);
13
-    public static function dumpTrace(array $backtrace, bool $str=true, string $perfix='');
13
+    public static function dumpTrace(array $backtrace, bool $str = true, string $perfix = '');
14 14
 }
Please login to merge, or discard this patch.
suda/src/framework/debug/attach/AttachTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
     protected function analyse(array $context)
24 24
     {
25 25
         $replace = [];
26
-        $attach = [] ;
26
+        $attach = [];
27 27
         foreach ($context as $key => $val) {
28 28
             if ($this->isReplacedObj($val)) {
29
-                $replace['{' . $key . '}'] = $val;
29
+                $replace['{'.$key.'}'] = $val;
30 30
             } else {
31 31
                 $attach[$key] = $val;
32 32
             }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
     protected function isReplacedObj($val) : bool
38 38
     {
39
-        return !is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && ! $val instanceof Throwable;
39
+        return !is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && !$val instanceof Throwable;
40 40
     }
41 41
 
42 42
     public function interpolate(string $message, array $context, array $attribute)
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         list($attach, $replace) = $this->analyse($context);
45 45
         $attribute = array_merge($this->attribute, $attribute);
46 46
         foreach ($attribute as $key => $val) {
47
-            $replace['%' . $key . '%'] = $val;
47
+            $replace['%'.$key.'%'] = $val;
48 48
         }
49 49
         $message = strtr($message, $replace);
50 50
         $attachInfo = '';
Please login to merge, or discard this patch.
suda/src/framework/debug/Debug.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 class Debug implements LoggerInterface, LoggerAwareInterface, DumpInterface, AttachInterface, ConfigInterface
20 20
 {
21
-    use LoggerTrait,LoggerAwareTrait,DumpTrait,AttachTrait,ConfigTrait;
21
+    use LoggerTrait, LoggerAwareTrait, DumpTrait, AttachTrait, ConfigTrait;
22 22
 
23 23
     /**
24 24
      * 忽略堆栈
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $replace = [];
71 71
         foreach ($context as $key => $val) {
72
-            $replace['{' . $key . '}'] = $val;
72
+            $replace['{'.$key.'}'] = $val;
73 73
         }
74 74
         return strtr($message, $replace);
75 75
     }
@@ -85,26 +85,26 @@  discard block
 block discarded – undo
85 85
         return $attribute;
86 86
     }
87 87
 
88
-    public static function formatBytes(int $bytes, int $precision=0)
88
+    public static function formatBytes(int $bytes, int $precision = 0)
89 89
     {
90
-        $human= ['B', 'KB', 'MB', 'GB', 'TB'];
90
+        $human = ['B', 'KB', 'MB', 'GB', 'TB'];
91 91
         $bytes = max($bytes, 0);
92
-        $pow = floor(($bytes?log($bytes):0)/log(1024));
93
-        $pos = min($pow, count($human)-1);
94
-        $bytes /= (1 << (10* $pos));
92
+        $pow = floor(($bytes ?log($bytes) : 0) / log(1024));
93
+        $pos = min($pow, count($human) - 1);
94
+        $bytes /= (1 << (10 * $pos));
95 95
         return round($bytes, $precision).' '.$human[$pos];
96 96
     }
97 97
 
98
-    public function time(string $name, string $type= LogLevel::INFO)
98
+    public function time(string $name, string $type = LogLevel::INFO)
99 99
     {
100
-        $this->timeRecord[$name]=['time'=>microtime(true),'level'=>$type];
100
+        $this->timeRecord[$name] = ['time'=>microtime(true), 'level'=>$type];
101 101
     }
102 102
 
103 103
     public function timeEnd(string $name)
104 104
     {
105 105
         if (array_key_exists($name, $this->timeRecord)) {
106
-            $pass=microtime(true)-$this->timeRecord[$name]['time'];
107
-            $this->log($this->timeRecord[$name]['level'], 'process '. $name.' cost '. number_format($pass, 5).'s');
106
+            $pass = microtime(true) - $this->timeRecord[$name]['time'];
107
+            $this->log($this->timeRecord[$name]['level'], 'process '.$name.' cost '.number_format($pass, 5).'s');
108 108
             return $pass;
109 109
         }
110 110
         return 0;
Please login to merge, or discard this patch.
suda/src/framework/debug/log/logger/FileLogger.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file'));
84 84
         }
85 85
         $this->latest = $this->getConfig('save-path').'/'.$this->getConfig('file-name');
86
-        register_shutdown_function([$this,'save']);
86
+        register_shutdown_function([$this, 'save']);
87 87
     }
88 88
 
89 89
     public function getDefaultConfig():array
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
     protected function packLogFile()
103 103
     {
104 104
         $logFile = $this->latest;
105
-        $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip');
105
+        $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip');
106 106
         $zip = $this->getZipArchive($path);
107 107
         if ($zip !== null) {
108
-            if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) {
108
+            if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) {
109 109
                 array_push($this->removeFiles, $logFile);
110 110
             }
111 111
             if (is_dir($this->getConfig('save-pack-path'))) {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             $zip->close();
120 120
         } else {
121 121
             if (is_file($logFile) && file_exists($logFile)) {
122
-                rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log');
122
+                rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log');
123 123
             }
124 124
         }
125 125
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             } elseif (null === $val) {
218 218
                 $val = 'null';
219 219
             }
220
-            $replace['{' . $key . '}'] = $val;
220
+            $replace['{'.$key.'}'] = $val;
221 221
         }
222 222
         return strtr($message, $replace);
223 223
     }
Please login to merge, or discard this patch.
suda/src/framework/config/PathResolver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@  discard block
 block discarded – undo
11 11
      * @param string $path
12 12
      * @return string|null
13 13
      */
14
-    public static function resolve(string $path):?string
14
+    public static function resolve(string $path): ?string
15 15
     {
16 16
         if (file_exists($path)) {
17 17
             return $path;
18 18
         }
19 19
         $basepath = dirname($path).'/'.pathinfo($path, PATHINFO_FILENAME);
20 20
         
21
-        return static::resolveYaml($basepath) ?? static::resolveExtensions($basepath, ['json','php','ini']);
21
+        return static::resolveYaml($basepath) ?? static::resolveExtensions($basepath, ['json', 'php', 'ini']);
22 22
     }
23 23
 
24 24
     /**
25 25
      * @param string $basepath
26 26
      * @return string|null
27 27
      */
28
-    protected static function resolveYaml(string $basepath):?string
28
+    protected static function resolveYaml(string $basepath): ?string
29 29
     {
30 30
         if (file_exists($conf = $basepath.'.yml') || file_exists($conf = $basepath.'.yaml')) {
31 31
             if (function_exists('yaml_parse') || class_exists('Spyc')) {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         return null;
36 36
     }
37 37
 
38
-    protected static function resolveExtensions(string $basepath, array $extensions):?string
38
+    protected static function resolveExtensions(string $basepath, array $extensions): ?string
39 39
     {
40 40
         foreach ($extensions as $ext) {
41 41
             if (file_exists($conf = $basepath.'.'.$ext)) {
Please login to merge, or discard this patch.
suda/src/framework/runnable/target/TargetBuilder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
         $dynmicsMethod;
68 68
         $parameter = self::buildParameter($parameter);
69 69
         if ($methodStart > 0) {
70
-            $splitLength = $splitLength > 0 ? 1:2;
70
+            $splitLength = $splitLength > 0 ? 1 : 2;
71 71
             $methodName = substr($command, $methodStart + $splitLength);
72 72
             $command = substr($command, 0, $methodStart);
73 73
             list($className, $constructParameter) = self::splitParameter($command);
74 74
             $constructParameter = self::buildParameter($constructParameter);
75
-            $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter);
75
+            $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter);
76 76
         } else {
77 77
             $target = new FunctionTarget(self::buildName($command), $parameter);
78 78
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) {
100 100
             throw new InvalidNameException(sprintf('invaild name: %s ', $name));
101 101
         }
102
-        return  str_replace(['.','/'], '\\', $name);
102
+        return  str_replace(['.', '/'], '\\', $name);
103 103
     }
104 104
 
105 105
     private static function splitParameter(string $command):array
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2);
111 111
             $command = substr($command, 0, $paramStart);
112 112
         }
113
-        return [$command,$parameter];
113
+        return [$command, $parameter];
114 114
     }
115 115
 
116 116
     private static function buildParameter(?string $parameter)
Please login to merge, or discard this patch.
suda/src/framework/runnable/target/MethodTarget.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function __construct($object, ?array $constructParameter = null, string $method, array $parameter = [])
55 55
     {
56
-        $this->object = is_object($object)? $object: $this->getPHPClassName($object);
56
+        $this->object = is_object($object) ? $object : $this->getPHPClassName($object);
57 57
         $this->constructParameter = $constructParameter;
58 58
         $this->method = $method;
59 59
         $this->parameter = $parameter;
60 60
         $static = $this->isStatic() ? '->' : '::';
61
-        $name = is_object($object)? get_class($object) : $object;
61
+        $name = is_object($object) ? get_class($object) : $object;
62 62
         $this->name = $name.$static.$method;
63 63
     }
64 64
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return object|null 动态类可获取
69 69
      */
70
-    public function getObjectInstance():?object
70
+    public function getObjectInstance(): ?object
71 71
     {
72 72
         if (is_object($this->object)) {
73 73
             return $this->object;
Please login to merge, or discard this patch.
suda/src/framework/request/UriParser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             parse_str($query, $this->query);
39 39
         }
40 40
         $url = parse_url($url, PHP_URL_PATH);
41
-        $this->uri = '/' . trim($url, '\/');
41
+        $this->uri = '/'.trim($url, '\/');
42 42
     }
43 43
 
44 44
     public function getQuery():array
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         }
59 59
         if (strpos($url, $indexFile) === 0) {
60 60
             // for /index.php/
61
-            $url = substr($url, strlen($indexFile));// for /index.php?/
61
+            $url = substr($url, strlen($indexFile)); // for /index.php?/
62 62
             if (strpos($url, '?/') === 0) {
63 63
                 $url = ltrim($url, '?');
64 64
             }
Please login to merge, or discard this patch.