Passed
Push — master ( 41a2b4...49df9d )
by 世昌
02:04
created
suda/src/orm/statement/ReadStatement.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     protected function whereStringArray(string $where, array $whereBinder)
145 145
     {
146 146
         list($where, $whereBinder) = $this->prepareWhereString($where, $whereBinder);
147
-        $this->where = 'WHERE '. $where;
147
+        $this->where = 'WHERE '.$where;
148 148
         $this->binder = $this->mergeBinder($this->binder, $whereBinder);
149 149
     }
150 150
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function groupBy(string $what)
158 158
     {
159
-        $this->groupBy = 'GROUP BY '. $what;
159
+        $this->groupBy = 'GROUP BY '.$what;
160 160
         return $this;
161 161
     }
162 162
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     {
201 201
 
202 202
         list($having, $havingBinder) = $this->prepareWhereString($having, $havingBinder);
203
-        $this->having = 'HAVING '. $having;
203
+        $this->having = 'HAVING '.$having;
204 204
         $this->binder = $this->mergeBinder($this->binder, $havingBinder);
205 205
     }
206 206
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function orderBy(string $what, string $order = 'ASC')
215 215
     {
216
-        $this->orderBy = 'ORDER BY '. $what.' '. $order;
216
+        $this->orderBy = 'ORDER BY '.$what.' '.$order;
217 217
         return $this;
218 218
     }
219 219
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     public function limit(int $start, int $length = null)
228 228
     {
229
-        $this->limit = 'LIMIT '. $start . ($length !== null ? ',' .$length :'');
229
+        $this->limit = 'LIMIT '.$start.($length !== null ? ','.$length : '');
230 230
         return $this;
231 231
     }
232 232
 
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
      */
254 254
     protected function prepareQuery():Query
255 255
     {
256
-        $where = [$this->where,$this->groupBy,$this->having,$this->orderBy,$this->limit];
256
+        $where = [$this->where, $this->groupBy, $this->having, $this->orderBy, $this->limit];
257 257
         $condition = implode(' ', array_filter(array_map('trim', $where), 'strlen'));
258
-        $select = [$this->distinct,$this->select];
258
+        $select = [$this->distinct, $this->select];
259 259
         $selection = implode(' ', array_filter(array_map('trim', $select), 'strlen'));
260 260
         $string = sprintf("SELECT %s FROM %s %s", $selection, $this->table, $condition);
261 261
         return new Query($string, $this->binder);
Please login to merge, or discard this patch.
suda/src/application/Application.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
         $this->debug->info('===============================');
41 41
         $this->debug->time('loading application');
42 42
         $appLoader->load();
43
-        $this->event->exec('application:load-config', [ $this->config ,$this]);
43
+        $this->event->exec('application:load-config', [$this->config, $this]);
44 44
         $this->debug->timeEnd('loading application');
45 45
         $this->debug->time('loading data-source');
46 46
         $appLoader->loadDataSource();
47 47
         $this->debug->timeEnd('loading data-source');
48 48
         Database::loadApplication($this);
49
-        $this->event->exec('application:load-environment', [ $this->config ,$this]);
49
+        $this->event->exec('application:load-environment', [$this->config, $this]);
50 50
         $this->debug->time('loading route');
51 51
         $appLoader->loadRoute();
52
-        $this->event->exec('application:load-route', [$this->route , $this]);
52
+        $this->event->exec('application:load-route', [$this->route, $this]);
53 53
         $this->debug->timeEnd('loading route');
54 54
         $this->debug->info('-------------------------------');
55 55
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             if (!$response->isSend()) {
107 107
                 $response->end();
108 108
             }
109
-            $this->debug->info('responded with code '. $response->getStatus());
109
+            $this->debug->info('responded with code '.$response->getStatus());
110 110
             $this->debug->timeEnd('sending response');
111 111
         } catch (Throwable $e) {
112 112
             $this->debug->uncaughtException($e);
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     protected function createResponse(?MatchResult $result, Request $request, Response $response)
174 174
     {
175 175
         if (SUDA_DEBUG) {
176
-            $response->setHeader('x-route', $result === null?'default':$result->getName());
176
+            $response->setHeader('x-route', $result === null ? 'default' : $result->getName());
177 177
         }
178 178
         if ($result === null) {
179 179
             $content = $this->defaultResponse($this, $request, $response);
Please login to merge, or discard this patch.
suda/src/framework/route/uri/MatcherHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         // 添加 * ? 匹配
37 37
         $url = str_replace(['\*', '\?'], ['[^/]*?', '[^/]'], $url);
38 38
         // 编译页面参数
39
-        $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function ($match) use (&$parameters) {
39
+        $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function($match) use (&$parameters) {
40 40
             $name = $match[1];
41 41
             $type = 'string';
42 42
             $extra = '';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $url = static::parseIgnorableParameter($url, $matcher, $parameter, $mapper);
71 71
         $url = static::replaceParameter($url, $matcher, $parameter, $mapper);
72 72
         if (count($query) && $allowQuery) {
73
-            return $url . '?' . http_build_query($query, 'v', '&', PHP_QUERY_RFC3986);
73
+            return $url.'?'.http_build_query($query, 'v', '&', PHP_QUERY_RFC3986);
74 74
         }
75 75
         return $url;
76 76
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         array $parameter,
89 89
         array $mapper
90 90
     ): string {
91
-        return preg_replace_callback('/\[(.+?)\]/', function ($match) use ($matcher, $parameter, $mapper) {
91
+        return preg_replace_callback('/\[(.+?)\]/', function($match) use ($matcher, $parameter, $mapper) {
92 92
             if (preg_match('/\{(\w+).+?\}/', $match[1])) {
93 93
                 $count = 0;
94 94
                 $subUrl = static::replaceParameter($match[1], $matcher, $parameter, $mapper, true, $count);
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         foreach ($parameter as $key => $value) {
108 108
             if (is_numeric($key)) {
109 109
                 $mp = $matcher->getParameterByIndex($key);
110
-                if ($mp  !== null) {
110
+                if ($mp !== null) {
111 111
                     unset($parameter[$key]);
112 112
                     $key = $mp->getIndexName();
113 113
                     $parameter[$key] = $value;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     ) {
144 144
         return preg_replace_callback(
145 145
             '/\{(\w+).+?\}/',
146
-            function ($match) use ($matcher, $parameter, $mapper, $ignore, &$count) {
146
+            function($match) use ($matcher, $parameter, $mapper, $ignore, &$count) {
147 147
                 if (array_key_exists($match[1], $mapper)) {
148 148
                     $count++;
149 149
                     return $mapper[$match[1]]->packValue($parameter[$match[1]]);
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
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
         $methodStart = $splitLength ?: strpos($command, '::') ?: $dynmicsMethod;
63 63
         $parameter = self::buildParameter($parameter);
64 64
         if ($methodStart > 0) {
65
-            $splitLength = $splitLength > 0 ? 1:2;
65
+            $splitLength = $splitLength > 0 ? 1 : 2;
66 66
             $methodName = substr($command, $methodStart + $splitLength);
67 67
             $command = substr($command, 0, $methodStart);
68 68
             list($className, $constructParameter) = self::splitParameter($command);
69 69
             $constructParameter = self::buildParameter($constructParameter);
70
-            $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter);
70
+            $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter);
71 71
         } else {
72 72
             $target = new FunctionTarget(self::buildName($command), $parameter);
73 73
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) {
100 100
             throw new InvalidNameException(sprintf('invalid 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/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) && is_file($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
             $conf = $basepath.'.'.$ext;
Please login to merge, or discard this patch.
suda/src/orm/statement/PrepareTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
             $fields = $reads;
26 26
         } else {
27 27
             $field = [];
28
-            $prefix = strlen($table) ?"`{$table}`." :'';
28
+            $prefix = strlen($table) ? "`{$table}`." : '';
29 29
             foreach ($reads as $want) {
30 30
                 $field[] = $prefix."`$want`";
31 31
             }
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
                 $newWhereBinder = array_merge($newWhereBinder, $binders);
82 82
                 $name = ltrim($name, ':');
83 83
                 $where = str_replace(':'.$name, $inSQL, $where);
84
-            } elseif($value instanceof  Binder) {
84
+            } elseif ($value instanceof  Binder) {
85 85
                 $newWhereBinder[] = $value;
86
-            }else{
86
+            } else {
87 87
                 $newWhereBinder[] = new Binder($name, $value);
88 88
             }
89 89
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         list($inSQL, $binders) = $this->prepareInParameter($values, $name);
105 105
         $sql = $name.' IN ('.$inSQL.')';
106
-        return [$sql,$binders];
106
+        return [$sql, $binders];
107 107
     }
108 108
 
109 109
     /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     protected function prepareQueryMark(string $sql, array $parameter)
156 156
     {
157 157
         $binders = [];
158
-        $query = preg_replace_callback('/\?/', function ($match) use (&$binders, $parameter) {
158
+        $query = preg_replace_callback('/\?/', function($match) use (&$binders, $parameter) {
159 159
             $index = count($binders);
160 160
             if (array_key_exists($index, $parameter)) {
161 161
                 $name = Binder::index($index);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
                 $where = str_replace(':'.$name, $inSQL, $where);
84 84
             } elseif($value instanceof  Binder) {
85 85
                 $newWhereBinder[] = $value;
86
-            }else{
86
+            } else{
87 87
                 $newWhereBinder[] = new Binder($name, $value);
88 88
             }
89 89
         }
Please login to merge, or discard this patch.