Passed
Push — master ( 3086d8...2c5405 )
by 世昌
02:04
created
suda/src/application/ApplicationBase.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @param string $name
78 78
      * @return Module|null
79 79
      */
80
-    public function find(string $name):?Module
80
+    public function find(string $name): ?Module
81 81
     {
82 82
         return $this->module->get($name);
83 83
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                 $this->modulePaths[] = Resource::getPathByRelativePath($path, $this->path);
112 112
             }
113 113
         } else {
114
-            $this->modulePaths = [ Resource::getPathByRelativePath('modules', $this->path) ];
114
+            $this->modulePaths = [Resource::getPathByRelativePath('modules', $this->path)];
115 115
         }
116 116
     }
117 117
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     protected function className(string $name)
136 136
     {
137
-        return str_replace(['.','/'], '\\', $name);
137
+        return str_replace(['.', '/'], '\\', $name);
138 138
     }
139 139
 
140 140
     /**
Please login to merge, or discard this patch.
suda/src/framework/Config.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * @param array|Config $extra
112 112
      * @return array|null
113 113
      */
114
-    public static function loadConfig(string $path, $extra = []):?array
114
+    public static function loadConfig(string $path, $extra = []): ?array
115 115
     {
116 116
         if (!file_exists($path)) {
117 117
             $path = PathResolver::resolve($path);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         }
122 122
         if ($path) {
123 123
             $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
124
-            if (in_array($ext, ['yaml','yml','json','php','ini'])) {
124
+            if (in_array($ext, ['yaml', 'yml', 'json', 'php', 'ini'])) {
125 125
                 return ContentLoader::{'load'.ucfirst($ext)}($path, $extra);
126 126
             }
127 127
             return ContentLoader::loadJson($path, $extra);
Please login to merge, or discard this patch.
suda/src/framework/route/RouteMatcher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function __construct(array $methods, string $uri, array $attribute = [])
45 45
     {
46
-        array_walk($methods, function ($value) {
46
+        array_walk($methods, function($value) {
47 47
             return strtoupper($value);
48 48
         });
49 49
         $this->methods = $methods;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @param Request $request
160 160
      * @return array|null
161 161
      */
162
-    public function match(Request $request):?array
162
+    public function match(Request $request): ?array
163 163
     {
164 164
         if (count($this->methods) > 0 && !in_array($request->getMethod(), $this->methods)) {
165 165
             return null;
Please login to merge, or discard this patch.
suda/src/framework/route/uri/UriMatcher.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @param boolean $ignoreCase
47 47
      * @return array|null
48 48
      */
49
-    public function match(string $url, bool $ignoreCase = true):?array
49
+    public function match(string $url, bool $ignoreCase = true): ?array
50 50
     {
51
-        $match = '#^'. $this->match.'$#'. ($ignoreCase?'i':'');
51
+        $match = '#^'.$this->match.'$#'.($ignoreCase ? 'i' : '');
52 52
         $parameter = [];
53 53
         if (preg_match($match, $url, $parameter, PREG_UNMATCHED_AS_NULL) > 0) {
54 54
             return array_slice($parameter, 1);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         return $parameters;
80 80
     }
81 81
 
82
-    public function getParameter(string $name):?Parameter
82
+    public function getParameter(string $name): ?Parameter
83 83
     {
84 84
         foreach ($this->parameter as $parameter) {
85 85
             if ($parameter->getIndexName() === $name) {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      * @param integer $index
130 130
      * @return Parameter|null
131 131
      */
132
-    public function getParameterByIndex(int $index):?Parameter
132
+    public function getParameterByIndex(int $index): ?Parameter
133 133
     {
134 134
         foreach ($this->parameter as $parameter) {
135 135
             if ($parameter->getIndex() === $index) {
Please login to merge, or discard this patch.
suda/src/framework/debug/Caller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
     protected $ignorePath = [__FILE__];
12 12
     protected $backtrace;
13 13
 
14
-    public function __construct(array $backtrace, array $ignorePath =[])
14
+    public function __construct(array $backtrace, array $ignorePath = [])
15 15
     {
16 16
         $this->ignorePath = array_merge($this->ignorePath, $ignorePath);
17 17
         $this->backtrace = $backtrace;
18 18
     }
19 19
 
20
-    public function getCallerTrace():?array
20
+    public function getCallerTrace(): ?array
21 21
     {
22 22
         foreach ($this->backtrace as $trace) {
23 23
             if (array_key_exists('file', $trace)) {
Please login to merge, or discard this patch.
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.