Passed
Push — master ( ffd809...9155e7 )
by 世昌
07:36
created
suda/src/orm/statement/PrepareTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             $fields = $reads;
31 31
         } else {
32 32
             $field = [];
33
-            $prefix = strlen($table) ?"`{$table}`." :'';
33
+            $prefix = strlen($table) ? "`{$table}`." : '';
34 34
             foreach ($reads as $want) {
35 35
                 $field[] = $prefix."`$want`";
36 36
             }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         list($inSQL, $binders) = $this->prepareInParameter($values, $name);
104 104
         $sql = $name.' IN ('.$inSQL.')';
105
-        return [$sql,$binders];
105
+        return [$sql, $binders];
106 106
     }
107 107
 
108 108
     /**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     protected function prepareQueryMark(string $sql, array $parameter)
155 155
     {
156 156
         $binders = [];
157
-        $query = preg_replace_callback('/\?/', function ($match) use (&$binders, $parameter) {
157
+        $query = preg_replace_callback('/\?/', function($match) use (&$binders, $parameter) {
158 158
             $index = count($binders);
159 159
             if (array_key_exists($index, $parameter)) {
160 160
                 $name = Binder::index($index);
Please login to merge, or discard this patch.
suda/src/orm/DataSource.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
      * @return Connection
116 116
      * @throws SQLException
117 117
      */
118
-    public static function new(string $type, array $config, ?string $name = null): Connection
118
+    public static function new(string $type, array $config, ?string $name = null) : Connection
119 119
     {
120 120
         if (array_key_exists($type, static::$type)) {
121 121
             return new static::$type[$type]($config, $name);
Please login to merge, or discard this patch.
suda/src/orm/connection/SQLiteConnection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         try {
41 41
             $pdo = new PDO($this->getDsn());
42 42
             $this->id = static::$_id;
43
-            static::$_id ++;
43
+            static::$_id++;
44 44
             return $pdo;
45 45
         } catch (PDOException $e) {
46 46
             throw new SQLException($this->__toString().' connect database error:'.$e->getMessage(), $e->getCode(), E_ERROR, __FILE__, __LINE__, $e);
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function switchDatabase(string $database)
55 55
     {
56
-        return $this->query(new QueryStatement('USE `' . $database.'`'));
56
+        return $this->query(new QueryStatement('USE `'.$database.'`'));
57 57
     }
58 58
 
59 59
     /**
Please login to merge, or discard this patch.
suda/src/orm/Binder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      */
50 50
     public static function index(string $name): string
51 51
     {
52
-        return '_' . static::$index . $name;
52
+        return '_'.static::$index.$name;
53 53
     }
54 54
 
55 55
     /**
Please login to merge, or discard this patch.
suda/src/orm/connection/MySQLConnection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             $password = $this->config['password'] ?? '';
45 45
             $pdo = new PDO($this->getDsn(), $user, $password);
46 46
             $this->id = static::$_id;
47
-            static::$_id ++;
47
+            static::$_id++;
48 48
             return $pdo;
49 49
         } catch (PDOException $e) {
50 50
             throw new SQLException(sprintf(
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function switchDatabase(string $database)
64 64
     {
65
-        return $this->query(new QueryStatement('USE `' . $database.'`'));
65
+        return $this->query(new QueryStatement('USE `'.$database.'`'));
66 66
     }
67 67
 
68 68
     public function rawTableName(string $name)
Please login to merge, or discard this patch.
suda/src/orm/connection/creator/MySQLTableCreator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
         $table = $this->connection->rawTableName($this->name);
106 106
         $sql = "CREATE TABLE IF NOT EXISTS `{$table}` (\r\n\t";
107 107
         $sql .= implode(",\r\n\t", array_filter($content, 'strlen'));
108
-        $auto = null === $this->auto?'':'AUTO_INCREMENT='.$this->auto;
109
-        $collate = null === $this->collate?'':'COLLATE '.$this->collate;
108
+        $auto = null === $this->auto ? '' : 'AUTO_INCREMENT='.$this->auto;
109
+        $collate = null === $this->collate ? '' : 'COLLATE '.$this->collate;
110 110
         $sql .= "\r\n) ENGINE={$this->engine} {$collate} {$auto} DEFAULT CHARSET={$this->charset};";
111 111
         return $sql;
112 112
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             }
125 125
         }
126 126
         if (count($primary)) {
127
-            return 'PRIMARY KEY ('. implode(',', $primary).')';
127
+            return 'PRIMARY KEY ('.implode(',', $primary).')';
128 128
         }
129 129
         return  '';
130 130
     }
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
     protected function createField(Field $field)
218 218
     {
219 219
         $type = strtoupper($field->getValueType()).$this->parseLength($field->getLength());
220
-        $auto = $field->getAuto() ?'AUTO_INCREMENT':'';
221
-        $null = $field->isNullable() ?'NULL':'NOT NULL';
222
-        $attr = $field->getAttribute() ?strtoupper($field->getAttribute()):'';
223
-        $comment = $field->getComment() ?('COMMENT \''.addcslashes($field->getComment(), '\'').'\''):'';
220
+        $auto = $field->getAuto() ? 'AUTO_INCREMENT' : '';
221
+        $null = $field->isNullable() ? 'NULL' : 'NOT NULL';
222
+        $attr = $field->getAttribute() ?strtoupper($field->getAttribute()) : '';
223
+        $comment = $field->getComment() ? ('COMMENT \''.addcslashes($field->getComment(), '\'').'\'') : '';
224 224
         // default设置
225 225
         if ($field->hasDefault()) {
226 226
             if (null === $field->getDefault()) {
Please login to merge, or discard this patch.
suda/src/framework/loader/Loader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param string $className
42 42
      * @return string|null
43 43
      */
44
-    public function getClassPath(string $className):?string
44
+    public function getClassPath(string $className): ?string
45 45
     {
46 46
         // 搜索路径
47 47
         foreach ($this->includePath as $includeNamespace => $includePaths) {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @param string $filename
59 59
      * @return string|null
60 60
      */
61
-    public function import(string $filename):?string
61
+    public function import(string $filename): ?string
62 62
     {
63 63
         if ($filename = static::realPath($filename)) {
64 64
             @require_once $filename;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param string $className
102 102
      * @return string|null
103 103
      */
104
-    protected function getClassPathByAlias(string $includePath, string $className):?string
104
+    protected function getClassPathByAlias(string $includePath, string $className): ?string
105 105
     {
106 106
         $namepath = static::formatSeparator($className);
107 107
         $className = static::realName($className);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param string $className
127 127
      * @return string|null
128 128
      */
129
-    protected function getClassPathByName(string $includeNamespace, string $includePath, string $className):?string
129
+    protected function getClassPathByName(string $includeNamespace, string $includePath, string $className): ?string
130 130
     {
131 131
         if (is_numeric($includeNamespace)) {
132 132
             $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php';
Please login to merge, or discard this patch.
suda/src/framework/runnable/target/MethodTarget.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->method = $method;
61 61
         $static = $this->isStatic() ? '->' : '::';
62 62
         $name = is_object($object) ? get_class($object) : $object;
63
-        $this->name = $name . $static . $method;
63
+        $this->name = $name.$static.$method;
64 64
     }
65 65
 
66 66
     /**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         if (null === $this->requireFile) {
122 122
             $this->requireFile = $requireFile;
123
-            $this->name = $this->name . '@' . $requireFile;
123
+            $this->name = $this->name.'@'.$requireFile;
124 124
         }
125 125
         return $this;
126 126
     }
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('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.