Passed
Push — master ( a365bf...864cd3 )
by Darío
01:42
created
src/Db/TableGateway/TableGateway.php 1 patch
Braces   +50 added lines, -49 removed lines patch added patch discarded remove patch
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
             {
74 74
                 $k++;
75 75
 
76
-                if (is_null($value))
77
-                    $parsed_where[] = "$key IS NULL";
78
-                elseif ($value instanceof SQLFunction)
79
-                    $parsed_where[] = "$key = " . $value->getStatement();
80
-                elseif (is_array($value))
76
+                if (is_null($value)) {
77
+                                    $parsed_where[] = "$key IS NULL";
78
+                } elseif ($value instanceof SQLFunction) {
79
+                                    $parsed_where[] = "$key = " . $value->getStatement();
80
+                } elseif (is_array($value))
81 81
                 {
82 82
                     $parsed_in = [];
83 83
 
@@ -100,8 +100,7 @@  discard block
 block discarded – undo
100 100
                     }
101 101
 
102 102
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
103
-                }
104
-                else
103
+                } else
105 104
                 {
106 105
                     switch ($driver)
107 106
                     {
@@ -119,18 +118,19 @@  discard block
 block discarded – undo
119 118
             }
120 119
 
121 120
             $where = "WHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
121
+        } else {
122
+                    $where = "";
122 123
         }
123
-        else
124
-            $where = "";
125 124
 
126 125
         $table = $this->entity->getTableName();
127 126
 
128 127
         $sql = "SELECT * \r\nFROM {$table}\r\n$where";
129 128
 
130
-        if (count($bind_values))
131
-            $this->getDriver()->getDb()->execute($sql, $bind_values);
132
-        else
133
-            $this->getDriver()->getDb()->execute($sql);
129
+        if (count($bind_values)) {
130
+                    $this->getDriver()->getDb()->execute($sql, $bind_values);
131
+        } else {
132
+                    $this->getDriver()->getDb()->execute($sql);
133
+        }
134 134
 
135 135
         return $this->getDriver()->getDb()->getArrayResult();
136 136
     }
@@ -147,8 +147,9 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function insert(Array $data)
149 149
     {
150
-        if (!count($data))
151
-            throw new \LogicException("Missing values for INSERT statement!");
150
+        if (!count($data)) {
151
+                    throw new \LogicException("Missing values for INSERT statement!");
152
+        }
152 153
 
153 154
         $bind_values = [];
154 155
 
@@ -171,11 +172,11 @@  discard block
 block discarded – undo
171 172
                 continue;
172 173
             }
173 174
 
174
-            if (is_null($value))
175
-                $value = "NULL";
176
-            elseif ($value instanceof SQLFunction)
177
-                $value = $value->getStatement();
178
-            else {
175
+            if (is_null($value)) {
176
+                            $value = "NULL";
177
+            } elseif ($value instanceof SQLFunction) {
178
+                            $value = $value->getStatement();
179
+            } else {
179 180
 
180 181
                 switch ($driver)
181 182
                 {
@@ -225,11 +226,13 @@  discard block
 block discarded – undo
225 226
     {
226 227
         $parsed_set = [];
227 228
 
228
-        if (!count($set))
229
-            throw new \LogicException("You cannot update rows without SET clause");
229
+        if (!count($set)) {
230
+                    throw new \LogicException("You cannot update rows without SET clause");
231
+        }
230 232
 
231
-        if (!count($where))
232
-            throw new SecurityException("You cannot update rows without WHERE clause!");
233
+        if (!count($where)) {
234
+                    throw new SecurityException("You cannot update rows without WHERE clause!");
235
+        }
233 236
 
234 237
         $bind_values = [];
235 238
 
@@ -241,11 +244,11 @@  discard block
 block discarded – undo
241 244
         {
242 245
             $k++;
243 246
 
244
-            if (is_null($value))
245
-                $parsed_set[] = "$key = NULL";
246
-            elseif ($value instanceof SQLFunction)
247
-                $parsed_set[] = "$key = " . $value->getStatement();
248
-            elseif (is_array($value))
247
+            if (is_null($value)) {
248
+                            $parsed_set[] = "$key = NULL";
249
+            } elseif ($value instanceof SQLFunction) {
250
+                            $parsed_set[] = "$key = " . $value->getStatement();
251
+            } elseif (is_array($value))
249 252
             {
250 253
                 $parsed_in = [];
251 254
 
@@ -256,8 +259,9 @@  discard block
 block discarded – undo
256 259
                         case 'Oci8':
257 260
 
258 261
                             # [POSSIBLE BUG] - To Future revision (What about non-string values ?)
259
-                            if (is_string($in_value))
260
-                                $parsed_in[] = ":$k";
262
+                            if (is_string($in_value)) {
263
+                                                            $parsed_in[] = ":$k";
264
+                            }
261 265
 
262 266
                             $bind_values[":$k"] = $in_value;
263 267
                             break;
@@ -272,8 +276,7 @@  discard block
 block discarded – undo
272 276
                 }
273 277
 
274 278
                 $parsed_set[] = "$key IN (" . implode(", ", $parsed_in) . ")";
275
-            }
276
-            else
279
+            } else
277 280
             {
278 281
                 switch ($driver)
279 282
                 {
@@ -298,11 +301,11 @@  discard block
 block discarded – undo
298 301
         {
299 302
             $k++;
300 303
 
301
-            if (is_null($value))
302
-                $parsed_where[] = "$key IS NULL";
303
-            elseif ($value instanceof SQLFunction)
304
-                $parsed_where[] = "$key = " . $value->getStatement();
305
-            elseif (is_array($value))
304
+            if (is_null($value)) {
305
+                            $parsed_where[] = "$key IS NULL";
306
+            } elseif ($value instanceof SQLFunction) {
307
+                            $parsed_where[] = "$key = " . $value->getStatement();
308
+            } elseif (is_array($value))
306 309
             {
307 310
                 $parsed_in = [];
308 311
 
@@ -325,8 +328,7 @@  discard block
 block discarded – undo
325 328
                 }
326 329
 
327 330
                 $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
328
-            }
329
-            else
331
+            } else
330 332
             {
331 333
                 switch ($driver)
332 334
                 {
@@ -378,11 +380,11 @@  discard block
 block discarded – undo
378 380
             {
379 381
                 $k++;
380 382
 
381
-                if (is_null($value))
382
-                    $parsed_where[] = "$key IS NULL";
383
-                elseif ($value instanceof SQLFunction)
384
-                    $parsed_where[] = "$key = " . $value->getStatement();
385
-                elseif (is_array($value))
383
+                if (is_null($value)) {
384
+                                    $parsed_where[] = "$key IS NULL";
385
+                } elseif ($value instanceof SQLFunction) {
386
+                                    $parsed_where[] = "$key = " . $value->getStatement();
387
+                } elseif (is_array($value))
386 388
                 {
387 389
                     $parsed_in = [];
388 390
 
@@ -405,8 +407,7 @@  discard block
 block discarded – undo
405 407
                     }
406 408
 
407 409
                     $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")";
408
-                }
409
-                else
410
+                } else
410 411
                 {
411 412
                     switch ($driver)
412 413
                     {
@@ -424,9 +425,9 @@  discard block
 block discarded – undo
424 425
             }
425 426
 
426 427
             $where = "\r\nWHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where);
428
+        } else {
429
+                    throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
427 430
         }
428
-        else
429
-            throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead.");
430 431
 
431 432
         $table = $this->entity->getTableName();
432 433
 
Please login to merge, or discard this patch.
src/Db/Driver/SQLServer.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         else
133 133
         {
134 134
             if ($isSelectStm)
135
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
135
+                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET));
136 136
             else
137 137
                 $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
138 138
         }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $this->rowsAffected = sqlsrv_rows_affected($this->result);
159 159
 
160 160
         if ($this->transac_mode)
161
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
161
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
162 162
 
163 163
         return $this->result;
164 164
     }
Please login to merge, or discard this patch.
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,15 +31,17 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct($options)
33 33
     {
34
-        if (!array_key_exists("dbchar", $options))
35
-            $options["dbchar"] = "UTF-8";
34
+        if (!array_key_exists("dbchar", $options)) {
35
+                    $options["dbchar"] = "UTF-8";
36
+        }
36 37
 
37 38
         parent::__construct($options);
38 39
 
39 40
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
40 41
 
41
-        if ($auto_connect)
42
-            $this->connect();
42
+        if ($auto_connect) {
43
+                    $this->connect();
44
+        }
43 45
     }
44 46
 
45 47
     /**
@@ -52,11 +54,13 @@  discard block
 block discarded – undo
52 54
      */
53 55
     public function connect()
54 56
     {
55
-        if (!extension_loaded('sqlsrv'))
56
-            throw new \RuntimeException("The Sqlsrv extension is not loaded");
57
+        if (!extension_loaded('sqlsrv')) {
58
+                    throw new \RuntimeException("The Sqlsrv extension is not loaded");
59
+        }
57 60
 
58
-        if (!is_null($this->dbport) && !empty($this->dbport))
59
-            $this->dbhost .= ', ' . $this->dbport;
61
+        if (!is_null($this->dbport) && !empty($this->dbport)) {
62
+                    $this->dbhost .= ', ' . $this->dbport;
63
+        }
60 64
 
61 65
         $db_info = array("Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpass, "CharacterSet" => $this->dbchar);
62 66
         $conn = sqlsrv_connect($this->dbhost, $db_info);
@@ -137,13 +141,13 @@  discard block
 block discarded – undo
137 141
             }
138 142
 
139 143
             $exec = sqlsrv_execute($stmt);
140
-        }
141
-        else
144
+        } else
142 145
         {
143
-            if ($isSelectStm)
144
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
145
-            else
146
-                $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
146
+            if ($isSelectStm) {
147
+                            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
148
+            } else {
149
+                            $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params);
150
+            }
147 151
         }
148 152
 
149 153
         if ($exec === false)
@@ -163,11 +167,13 @@  discard block
 block discarded – undo
163 167
         $this->numRows = sqlsrv_has_rows($this->result) ? sqlsrv_num_rows($this->result) : $this->numRows;
164 168
         $this->numFields = sqlsrv_num_fields($this->result);
165 169
 
166
-        if ($isInsertStm || $isUpdateStm || $isDeleteStm)
167
-            $this->rowsAffected = sqlsrv_rows_affected($this->result);
170
+        if ($isInsertStm || $isUpdateStm || $isDeleteStm) {
171
+                    $this->rowsAffected = sqlsrv_rows_affected($this->result);
172
+        }
168 173
 
169
-        if ($this->transac_mode)
170
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
174
+        if ($this->transac_mode) {
175
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
176
+        }
171 177
 
172 178
         return $this->result;
173 179
     }
@@ -234,9 +240,8 @@  discard block
 block discarded – undo
234 240
             {
235 241
                 $data[] = $row;
236 242
             }
237
-        }
238
-        else
239
-            /*
243
+        } else {
244
+                    /*
240 245
              * "This kind of exception should lead directly to a fix in your code"
241 246
              * So much production tests tell us this error is throwed because developers
242 247
              * execute toArray() before execute().
@@ -244,6 +249,7 @@  discard block
 block discarded – undo
244 249
              * Ref: http://php.net/manual/en/class.logicexception.php
245 250
              */
246 251
             throw new \LogicException('There are not data in the buffer!');
252
+        }
247 253
 
248 254
         $this->arrayResult = $data;
249 255
 
@@ -257,7 +263,8 @@  discard block
 block discarded – undo
257 263
      */
258 264
     public function __destruct()
259 265
     {
260
-        if ($this->dbconn)
261
-            sqlsrv_close($this->dbconn);
266
+        if ($this->dbconn) {
267
+                    sqlsrv_close($this->dbconn);
268
+        }
262 269
     }
263 270
 }
264 271
\ No newline at end of file
Please login to merge, or discard this patch.
src/Db/Driver/MySQL.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             {
119 119
                 if (is_string($param_values[$i]))
120 120
                     $bind_types .= 's';
121
-                else if(is_float($param_values[$i]))
121
+                else if (is_float($param_values[$i]))
122 122
                     $bind_types .= 'd';
123 123
                 # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?)
124 124
                 else
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             $this->numFields = $this->dbconn->field_count;
179 179
 
180 180
         if ($this->transac_mode)
181
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
181
+            $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result;
182 182
 
183 183
         /*
184 184
          * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries, * and TRUE for other successful queries, it should be handled to return only objects or resources.
Please login to merge, or discard this patch.
Braces   +45 added lines, -36 removed lines patch added patch discarded remove patch
@@ -31,15 +31,17 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function __construct($options)
33 33
     {
34
-        if (!array_key_exists("dbchar", $options))
35
-            $options["dbchar"] = "utf8";
34
+        if (!array_key_exists("dbchar", $options)) {
35
+                    $options["dbchar"] = "utf8";
36
+        }
36 37
 
37 38
         parent::__construct($options);
38 39
 
39 40
         $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true;
40 41
 
41
-        if ($auto_connect)
42
-            $this->connect();
42
+        if ($auto_connect) {
43
+                    $this->connect();
44
+        }
43 45
     }
44 46
 
45 47
     /**
@@ -52,13 +54,15 @@  discard block
 block discarded – undo
52 54
      */
53 55
     public function connect()
54 56
     {
55
-        if (!extension_loaded('mysqli'))
56
-            throw new \RuntimeException("The Mysqli extension is not loaded");
57
+        if (!extension_loaded('mysqli')) {
58
+                    throw new \RuntimeException("The Mysqli extension is not loaded");
59
+        }
57 60
 
58
-        if (!is_null($this->dbport) && !empty($this->dbport))
59
-            $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport);
60
-        else
61
-            $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
61
+        if (!is_null($this->dbport) && !empty($this->dbport)) {
62
+                    $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname, $this->dbport);
63
+        } else {
64
+                    $conn = @new \mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
65
+        }
62 66
 
63 67
         if ($conn->connect_errno)
64 68
         {
@@ -68,8 +72,7 @@  discard block
 block discarded – undo
68 72
              * the warning message "Property access is not allowed yet".
69 73
              */
70 74
             throw new Exception\ConnectionException(mysqli_connect_error(), mysqli_connect_errno());
71
-        }
72
-        else
75
+        } else
73 76
         {
74 77
             $this->dbconn = $conn;
75 78
             $this->dbconn->set_charset($this->dbchar);
@@ -116,13 +119,15 @@  discard block
 block discarded – undo
116 119
 
117 120
             for ($i = 0; $i < $n_params; $i++)
118 121
             {
119
-                if (is_string($param_values[$i]))
120
-                    $bind_types .= 's';
121
-                else if(is_float($param_values[$i]))
122
-                    $bind_types .= 'd';
122
+                if (is_string($param_values[$i])) {
123
+                                    $bind_types .= 's';
124
+                } else if(is_float($param_values[$i])) {
125
+                                    $bind_types .= 'd';
126
+                }
123 127
                 # [POSSIBLE BUG] - To Future revision (What about non-string and non-decimal types ?)
124
-                else
125
-                    $bind_types .= 's';
128
+                else {
129
+                                    $bind_types .= 's';
130
+                }
126 131
 
127 132
                 $bind_values[] = '$param_values[' . $i . ']';
128 133
             }
@@ -143,12 +148,12 @@  discard block
 block discarded – undo
143 148
                      * It is useful to prevent rollback transactions on insert statements because
144 149
                      * insert statement do not free results.
145 150
                      */
146
-                    if ($res)
147
-                        $this->result = $res;
151
+                    if ($res) {
152
+                                            $this->result = $res;
153
+                    }
148 154
                 }
149 155
             }
150
-        }
151
-        else
156
+        } else
152 157
         {
153 158
             $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL);
154 159
 
@@ -165,20 +170,23 @@  discard block
 block discarded – undo
165 170
         }
166 171
 
167 172
         # identify SELECT, SHOW, DESCRIBE or EXPLAIN queries
168
-        if (is_object($this->result) && property_exists($this->result, 'num_rows'))
169
-            $this->numRows = $this->result->num_rows;
170
-        else
173
+        if (is_object($this->result) && property_exists($this->result, 'num_rows')) {
174
+                    $this->numRows = $this->result->num_rows;
175
+        } else
171 176
         {
172 177
             # affected_rows return the same of num_rows on select statements!
173
-            if (property_exists($this->dbconn, 'affected_rows'))
174
-                $this->rowsAffected = $this->dbconn->affected_rows;
178
+            if (property_exists($this->dbconn, 'affected_rows')) {
179
+                            $this->rowsAffected = $this->dbconn->affected_rows;
180
+            }
175 181
         }
176 182
 
177
-        if (property_exists($this->dbconn, 'field_count'))
178
-            $this->numFields = $this->dbconn->field_count;
183
+        if (property_exists($this->dbconn, 'field_count')) {
184
+                    $this->numFields = $this->dbconn->field_count;
185
+        }
179 186
 
180
-        if ($this->transac_mode)
181
-            $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
187
+        if ($this->transac_mode) {
188
+                    $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result;
189
+        }
182 190
 
183 191
         /*
184 192
          * Because mysqli_query() returns FALSE on failure, a mysqli_result object for SELECT, SHOW, DESCRIBE or EXPLAIN queries, * and TRUE for other successful queries, it should be handled to return only objects or resources.
@@ -255,9 +263,8 @@  discard block
 block discarded – undo
255 263
             {
256 264
                 $data[] = $row;
257 265
             }
258
-        }
259
-        else
260
-            /*
266
+        } else {
267
+                    /*
261 268
              * "This kind of exception should lead directly to a fix in your code"
262 269
              * So much production tests tell us this error is throwed because developers
263 270
              * execute toArray() before execute().
@@ -265,6 +272,7 @@  discard block
 block discarded – undo
265 272
              * Ref: http://php.net/manual/en/class.logicexception.php
266 273
              */
267 274
             throw new \LogicException('There are not data in the buffer!');
275
+        }
268 276
 
269 277
         $this->arrayResult = $data;
270 278
 
@@ -279,7 +287,8 @@  discard block
 block discarded – undo
279 287
     public function __destruct()
280 288
     {
281 289
         # prevent "Property access is not allowed yet" with @ on failure connections
282
-        if ($this->dbconn !== false && !is_null($this->dbconn))
283
-            @$this->dbconn->close();
290
+        if ($this->dbconn !== false && !is_null($this->dbconn)) {
291
+                    @$this->dbconn->close();
292
+        }
284 293
     }
285 294
 }
286 295
\ No newline at end of file
Please login to merge, or discard this patch.
test/Db/Driver/MySQLTest.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         try
241 241
         {
242 242
             $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')";
243
-	        $result = $conn->execute($sql);
243
+            $result = $conn->execute($sql);
244 244
         }
245 245
         catch (\Exception $e)
246 246
         {
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 
512 512
         try
513 513
         {
514
-	        $sql = "INSERT INTO MYTABLE (DESCRIPTION) VALUES ('TRANS_SHORTCUT_1')";
515
-	        $result = $conn->execute($sql);
514
+            $sql = "INSERT INTO MYTABLE (DESCRIPTION) VALUES ('TRANS_SHORTCUT_1')";
515
+            $result = $conn->execute($sql);
516 516
 
517
-	        $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')";
518
-	        $result = $conn->execute($sql);
517
+            $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')";
518
+            $result = $conn->execute($sql);
519 519
         }
520 520
         catch (InvalidQueryException $e)
521 521
         {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public function testCannotStablishConnection()
146 146
     {
147 147
         $options = $this->options;
148
-        $options["dbhost"] = 'myserver';   // this server does not exists
148
+        $options["dbhost"] = 'myserver'; // this server does not exists
149 149
 
150 150
         $conn = new MySQL($options);
151 151
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         $this->assertEquals(2, $conn->getNumFields());
273 273
         $this->assertEquals(0, $conn->getRowsAffected());
274 274
 
275
-        $rowset = $conn->getArrayResult();    # array with results
275
+        $rowset = $conn->getArrayResult(); # array with results
276 276
         $row = array_shift($rowset);
277 277
 
278 278
         $this->assertArrayHasKey("ID", $row);
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
         $result = $conn->execute($sql);
300 300
         $rowcount = count($conn->getArrayResult());
301 301
 
302
-        $this->assertTrue(($rowcount === 1));    # the row is available for now
302
+        $this->assertTrue(($rowcount === 1)); # the row is available for now
303 303
 
304 304
         # properties modified by execute() method
305 305
         $this->assertEquals(1, $conn->getNumRows());
306 306
         $this->assertEquals(2, $conn->getNumFields());
307
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
307
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
308 308
 
309 309
         $this->assertTrue($conn->commit());
310 310
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $result = $conn->execute($sql);
314 314
         $rowcount = count($conn->getArrayResult());
315 315
 
316
-        $this->assertTrue(($rowcount === 1));    # the row is available
316
+        $this->assertTrue(($rowcount === 1)); # the row is available
317 317
     }
318 318
 
319 319
     /**
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
         $result = $conn->execute($sql);
337 337
         $rowcount = count($conn->getArrayResult());
338 338
 
339
-        $this->assertTrue(($rowcount === 1));    # the row is available for now
339
+        $this->assertTrue(($rowcount === 1)); # the row is available for now
340 340
 
341 341
         # properties modified by execute() method
342 342
         $this->assertEquals(1, $conn->getNumRows());
343 343
         $this->assertEquals(2, $conn->getNumFields());
344
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
344
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
345 345
 
346 346
         $this->assertTrue($conn->rollback());
347 347
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         $result = $conn->execute($sql);
351 351
         $rowcount = count($conn->getArrayResult());
352 352
 
353
-        $this->assertNotTrue(($rowcount === 1));    # the row is not available
353
+        $this->assertNotTrue(($rowcount === 1)); # the row is not available
354 354
     }
355 355
 
356 356
     /**
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
         $result = $conn->execute($sql);
383 383
         $rowcount = count($conn->getArrayResult());
384 384
 
385
-        $this->assertTrue(($rowcount === 4));    # the rows are available for now
385
+        $this->assertTrue(($rowcount === 4)); # the rows are available for now
386 386
 
387 387
         # properties modified by execute() method
388 388
         $this->assertEquals(4, $conn->getNumRows());
389 389
         $this->assertEquals(2, $conn->getNumFields());
390
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
390
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
391 391
 
392 392
         $this->assertTrue($conn->commit());
393 393
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
         $result = $conn->execute($sql);
397 397
         $rowcount = count($conn->getArrayResult());
398 398
 
399
-        $this->assertTrue(($rowcount === 4));    # the row is available
399
+        $this->assertTrue(($rowcount === 4)); # the row is available
400 400
     }
401 401
 
402 402
     /**
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
         $result = $conn->execute($sql);
429 429
         $rowcount = count($conn->getArrayResult());
430 430
 
431
-        $this->assertTrue(($rowcount === 4));    # the rows are available for now
431
+        $this->assertTrue(($rowcount === 4)); # the rows are available for now
432 432
 
433 433
         # properties modified by execute() method
434 434
         $this->assertEquals(4, $conn->getNumRows());
435 435
         $this->assertEquals(2, $conn->getNumFields());
436
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
436
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
437 437
 
438 438
         $this->assertTrue($conn->rollback());
439 439
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $result = $conn->execute($sql);
443 443
         $rowcount = count($conn->getArrayResult());
444 444
 
445
-        $this->assertNotTrue(($rowcount === 4));    # the row is available
445
+        $this->assertNotTrue(($rowcount === 4)); # the row is available
446 446
     }
447 447
 
448 448
     /**
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
         $result = $conn->execute($sql);
474 474
         $rowcount = count($conn->getArrayResult());
475 475
 
476
-        $this->assertTrue(($rowcount === 2));    # the rows are available for now
476
+        $this->assertTrue(($rowcount === 2)); # the rows are available for now
477 477
 
478 478
         # properties modified by execute() method
479 479
         $this->assertEquals(2, $conn->getNumRows());
480 480
         $this->assertEquals(2, $conn->getNumFields());
481
-        $this->assertEquals(0, $conn->getRowsAffected());    # nothing affected (autocommit = false)
481
+        $this->assertEquals(0, $conn->getRowsAffected()); # nothing affected (autocommit = false)
482 482
 
483 483
         # ends the transaction
484 484
         $conn->endTransaction();
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         $result = $conn->execute($sql);
489 489
         $rowcount = count($conn->getArrayResult());
490 490
 
491
-        $this->assertTrue(($rowcount === 2));    # the row is available
491
+        $this->assertTrue(($rowcount === 2)); # the row is available
492 492
     }
493 493
 
494 494
     /**
@@ -532,6 +532,6 @@  discard block
 block discarded – undo
532 532
         $result = $conn->execute($sql);
533 533
         $rowcount = count($conn->getArrayResult());
534 534
 
535
-        $this->assertNotTrue(($rowcount === 0));    # the rows are not available
535
+        $this->assertNotTrue(($rowcount === 0)); # the rows are not available
536 536
     }
537 537
 }
538 538
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -84,12 +84,10 @@  discard block
 block discarded – undo
84 84
 
85 85
         try {
86 86
             $conn->disconnect();
87
-        }
88
-        catch (\Exception $e)
87
+        } catch (\Exception $e)
89 88
         {
90 89
             $errorObject = ($e instanceof \LogicException);
91
-        }
92
-        finally
90
+        } finally
93 91
         {
94 92
             $this->assertNotTrue($conn->isConnected());
95 93
             $this->assertTrue($errorObject, $e->getMessage());
@@ -125,12 +123,10 @@  discard block
 block discarded – undo
125 123
 
126 124
         try {
127 125
             $conn->reconnect();
128
-        }
129
-        catch (\Exception $e)
126
+        } catch (\Exception $e)
130 127
         {
131 128
             $errorObject = ($e instanceof \LogicException);
132
-        }
133
-        finally
129
+        } finally
134 130
         {
135 131
             $this->assertTrue($errorObject, $e->getMessage());
136 132
             $this->assertNotTrue($conn->isConnected());
@@ -155,13 +151,11 @@  discard block
 block discarded – undo
155 151
 
156 152
         try {
157 153
             $mysqliObject = $conn->connect();
158
-        }
159
-        catch (\Exception $e)
154
+        } catch (\Exception $e)
160 155
         {
161 156
             $errorObject = ($e instanceof ConnectionException);
162 157
             $message = $e->getMessage();
163
-        }
164
-        finally
158
+        } finally
165 159
         {
166 160
             $this->assertTrue($errorObject, $message);
167 161
             $this->assertNotTrue($conn->isConnected());
@@ -241,13 +235,11 @@  discard block
 block discarded – undo
241 235
         {
242 236
             $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('Hello world!')";
243 237
 	        $result = $conn->execute($sql);
244
-        }
245
-        catch (\Exception $e)
238
+        } catch (\Exception $e)
246 239
         {
247 240
             $errorObject = ($e instanceof InvalidQueryException);
248 241
             $message = $e->getMessage();
249
-        }
250
-        finally
242
+        } finally
251 243
         {
252 244
             $this->assertTrue($errorObject, $message);
253 245
         }
@@ -516,8 +508,7 @@  discard block
 block discarded – undo
516 508
 
517 509
 	        $sql = "INSERT INTO MYTABLE (DESCRIPTION, WRONG) VALUES ('TRANS_SHORTCUT_2')";
518 510
 	        $result = $conn->execute($sql);
519
-        }
520
-        catch (InvalidQueryException $e)
511
+        } catch (InvalidQueryException $e)
521 512
         {
522 513
             $message = $e->getMessage();
523 514
             #·not necessary!
Please login to merge, or discard this patch.