Completed
Push — master ( 195702...f3dab2 )
by Lars
02:13 queued 15s
created
src/voku/db/DB.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1079,7 +1079,7 @@
 block discarded – undo
1079 1079
      * @param string  $query    <p>sql-query</p>
1080 1080
      * @param bool    $useCache optional <p>use cache?</p>
1081 1081
      * @param int     $cacheTTL optional <p>cache-ttl in seconds</p>
1082
-     * @param DB|null $db       optional <p>the database connection</p>
1082
+     * @param null|\self $db       optional <p>the database connection</p>
1083 1083
      *
1084 1084
      * @throws QueryException
1085 1085
      *
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
         }
321 321
 
322 322
         if ($port) {
323
-            $this->port = (int) $port;
323
+            $this->port = (int)$port;
324 324
         } else {
325 325
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
326
-            $this->port = (int) @\ini_get('mysqli.default_port');
326
+            $this->port = (int)@\ini_get('mysqli.default_port');
327 327
         }
328 328
 
329 329
         // fallback
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         foreach ($arrayPair as $_key => $_value) {
377 377
             $_connector = '=';
378 378
             $_glueHelper = '';
379
-            $_key_upper = \strtoupper((string) $_key);
379
+            $_key_upper = \strtoupper((string)$_key);
380 380
 
381 381
             if (\strpos($_key_upper, ' NOT') !== false) {
382 382
                 $_connector = 'NOT';
@@ -458,30 +458,30 @@  discard block
 block discarded – undo
458 458
                 }
459 459
 
460 460
                 if ($_connector === 'NOT IN' || $_connector === 'IN') {
461
-                    $_value = '(' . \implode(',', $_value) . ')';
461
+                    $_value = '('.\implode(',', $_value).')';
462 462
                 } elseif ($_connector === 'NOT BETWEEN' || $_connector === 'BETWEEN') {
463
-                    $_value = '(' . \implode(' AND ', $_value) . ')';
463
+                    $_value = '('.\implode(' AND ', $_value).')';
464 464
                 } elseif ($firstKey && $firstValue) {
465
-                    if (\strpos((string) $firstKey, ' +') !== false) {
466
-                        $firstKey = \str_replace(' +', '', (string) $firstKey);
467
-                        $_value = $firstKey . ' + ' . $firstValue;
465
+                    if (\strpos((string)$firstKey, ' +') !== false) {
466
+                        $firstKey = \str_replace(' +', '', (string)$firstKey);
467
+                        $_value = $firstKey.' + '.$firstValue;
468 468
                     }
469 469
 
470
-                    if (\strpos((string) $firstKey, ' -') !== false) {
471
-                        $firstKey = \str_replace(' -', '', (string) $firstKey);
472
-                        $_value = $firstKey . ' - ' . $firstValue;
470
+                    if (\strpos((string)$firstKey, ' -') !== false) {
471
+                        $firstKey = \str_replace(' -', '', (string)$firstKey);
472
+                        $_value = $firstKey.' - '.$firstValue;
473 473
                     }
474 474
                 }
475 475
             } else {
476 476
                 $_value = $this->secure($_value);
477 477
             }
478 478
 
479
-            $_key = UTF8::str_replace_last($_glueHelper, '', (string) $_key);
479
+            $_key = UTF8::str_replace_last($_glueHelper, '', (string)$_key);
480 480
             $_key = UTF8::str_replace_last($_connector, '', $_key);
481 481
 
482 482
             $quoteString = $this->quote_string(\trim($_key));
483 483
 
484
-            $_value = (array) $_value;
484
+            $_value = (array)$_value;
485 485
 
486 486
             if (!$_glueHelper) {
487 487
                 $_glueHelper = $glue;
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
                     $valueInner = "''";
506 506
                 }
507 507
 
508
-                $sql .= ' ' . $_glueHelperInner . ' ' . $quoteString . ' ' . $_connector . ' ' . $valueInner . " \n";
508
+                $sql .= ' '.$_glueHelperInner.' '.$quoteString.' '.$_connector.' '.$valueInner." \n";
509 509
                 $tmpCounter++;
510 510
             }
511 511
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
             unset($params[$key]);
558 558
 
559 559
             $sql = \substr_replace($sql, $replacement, $offset, 1);
560
-            $offset = \strpos($sql, '?', $offset + \strlen((string) $replacement));
560
+            $offset = \strpos($sql, '?', $offset + \strlen((string)$replacement));
561 561
         }
562 562
 
563 563
         return ['sql' => $sql, 'params' => $params];
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
             // add ":" if needed
596 596
             if (\strpos($name, ':') !== 0) {
597
-                $nameTmp = ':' . $name;
597
+                $nameTmp = ':'.$name;
598 598
             } else {
599 599
                 $nameTmp = $name;
600 600
             }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
             if ($offset === null) {
603 603
                 $offset = \strpos($sql, $nameTmp);
604 604
             } else {
605
-                $offset = \strpos($sql, $nameTmp, $offset + \strlen((string) $replacement));
605
+                $offset = \strpos($sql, $nameTmp, $offset + \strlen((string)$replacement));
606 606
             }
607 607
 
608 608
             if ($offset === false) {
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
             return \mysqli_affected_rows($this->mysqli_link);
635 635
         }
636 636
 
637
-        return (int) $this->affected_rows;
637
+        return (int)$this->affected_rows;
638 638
     }
639 639
 
640 640
     /**
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
                 $this->database,
849 849
                 $this->port,
850 850
                 $this->socket,
851
-                (int) $flags
851
+                (int)$flags
852 852
             );
853 853
         } catch (\Exception $e) {
854
-            $error = 'Error connecting to mysql server: ' . $e->getMessage();
854
+            $error = 'Error connecting to mysql server: '.$e->getMessage();
855 855
             $this->debug->displayError($error, false);
856 856
 
857 857
             throw new DBConnectException($error, 100, $e);
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 
861 861
         $errno = \mysqli_connect_errno();
862 862
         if (!$this->connected || $errno) {
863
-            $error = 'Error connecting to mysql server: ' . \mysqli_connect_error() . ' (' . $errno . ')';
863
+            $error = 'Error connecting to mysql server: '.\mysqli_connect_error().' ('.$errno.')';
864 864
             $this->debug->displayError($error, false);
865 865
 
866 866
             throw new DBConnectException($error, 101);
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
         }
884 884
 
885 885
         if (!$this->connected) {
886
-            $error = 'Error connecting to mysql server: ' . \print_r($this->doctrine_connection ? $this->doctrine_connection->errorInfo() : [], false);
886
+            $error = 'Error connecting to mysql server: '.\print_r($this->doctrine_connection ? $this->doctrine_connection->errorInfo() : [], false);
887 887
             $this->debug->displayError($error, false);
888 888
 
889 889
             throw new DBConnectException($error, 101);
@@ -929,10 +929,10 @@  discard block
 block discarded – undo
929 929
         }
930 930
 
931 931
         if ($databaseName) {
932
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
932
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
933 933
         }
934 934
 
935
-        $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
935
+        $sql = 'DELETE FROM '.$databaseName.$this->quote_string($table)." WHERE (${WHERE})";
936 936
 
937 937
         $return = $this->query($sql);
938 938
 
@@ -1033,14 +1033,14 @@  discard block
 block discarded – undo
1033 1033
                 $var = $var->format('Y-m-d H:i:s');
1034 1034
                 $type = 'string';
1035 1035
             } elseif (\method_exists($var, '__toString')) {
1036
-                $var = (string) $var;
1036
+                $var = (string)$var;
1037 1037
                 $type = 'string';
1038 1038
             }
1039 1039
         }
1040 1040
 
1041 1041
         switch ($type) {
1042 1042
             case 'boolean':
1043
-                $var = (int) $var;
1043
+                $var = (int)$var;
1044 1044
 
1045 1045
                 break;
1046 1046
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
                     }
1085 1085
                 } else {
1086 1086
                     $varCleaned = [];
1087
-                    foreach ((array) $var as $key => $value) {
1087
+                    foreach ((array)$var as $key => $value) {
1088 1088
                         $key = $this->escape($key, $stripe_non_utf8, $html_entity_decode);
1089 1089
                         $value = $this->escape($value, $stripe_non_utf8, $html_entity_decode);
1090 1090
 
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 
1149 1149
         if ($useCache) {
1150 1150
             $cache = new Cache(null, null, false, $useCache);
1151
-            $cacheKey = 'sql-' . \md5($query);
1151
+            $cacheKey = 'sql-'.\md5($query);
1152 1152
 
1153 1153
             if (
1154 1154
                 $cache->getCacheIsReady()
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
         }
1325 1325
 
1326 1326
         if (
1327
-            '' . $hostname . $username . $password . $database . $port . $charset === '' . $port . $charset
1327
+            ''.$hostname.$username.$password.$database.$port.$charset === ''.$port.$charset
1328 1328
             &&
1329 1329
             $firstInstance instanceof self
1330 1330
         ) {
@@ -1340,13 +1340,13 @@  discard block
 block discarded – undo
1340 1340
             if (\is_object($extra_config_value)) {
1341 1341
                 $extra_config_value_tmp = \spl_object_hash($extra_config_value);
1342 1342
             } else {
1343
-                $extra_config_value_tmp = (string) $extra_config_value;
1343
+                $extra_config_value_tmp = (string)$extra_config_value;
1344 1344
             }
1345
-            $extra_config_string .= $extra_config_key . $extra_config_value_tmp;
1345
+            $extra_config_string .= $extra_config_key.$extra_config_value_tmp;
1346 1346
         }
1347 1347
 
1348 1348
         $connection = \md5(
1349
-            $hostname . $username . $password . $database . $port . $charset . (int) $exit_on_error . (int) $echo_on_error . $logger_class_name . $logger_level . $extra_config_string
1349
+            $hostname.$username.$password.$database.$port.$charset.(int)$exit_on_error.(int)$echo_on_error.$logger_class_name.$logger_level.$extra_config_string
1350 1350
         );
1351 1351
 
1352 1352
         if (!isset($instance[$connection])) {
@@ -1489,10 +1489,10 @@  discard block
 block discarded – undo
1489 1489
         $SET = $this->_parseArrayPair($data);
1490 1490
 
1491 1491
         if ($databaseName) {
1492
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1492
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
1493 1493
         }
1494 1494
 
1495
-        $sql = 'INSERT INTO ' . $databaseName . $this->quote_string($table) . " SET ${SET}";
1495
+        $sql = 'INSERT INTO '.$databaseName.$this->quote_string($table)." SET ${SET}";
1496 1496
 
1497 1497
         $return = $this->query($sql);
1498 1498
         if ($return === false) {
@@ -2023,12 +2023,12 @@  discard block
 block discarded – undo
2023 2023
 
2024 2024
             // exit if we have more then 3 "DB server has gone away"-errors
2025 2025
             if ($RECONNECT_COUNTER > 3) {
2026
-                $this->debug->mailToAdmin('DB-Fatal-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql, 5);
2026
+                $this->debug->mailToAdmin('DB-Fatal-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql, 5);
2027 2027
 
2028 2028
                 throw new DBGoneAwayException($errorMessage);
2029 2029
             }
2030 2030
 
2031
-            $this->debug->mailToAdmin('DB-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
2031
+            $this->debug->mailToAdmin('DB-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
2032 2032
 
2033 2033
             // reconnect
2034 2034
             $RECONNECT_COUNTER++;
@@ -2042,7 +2042,7 @@  discard block
 block discarded – undo
2042 2042
             return false;
2043 2043
         }
2044 2044
 
2045
-        $this->debug->mailToAdmin('SQL-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
2045
+        $this->debug->mailToAdmin('SQL-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
2046 2046
 
2047 2047
         $force_exception_after_error = null; // auto
2048 2048
         if ($this->in_transaction) {
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
         }
2051 2051
         // this query returned an error, we must display it (only for dev) !!!
2052 2052
 
2053
-        $this->debug->displayError($errorMessage . '(' . $errorNumber . ') ' . ' | ' . $sql, $force_exception_after_error);
2053
+        $this->debug->displayError($errorMessage.'('.$errorNumber.') '.' | '.$sql, $force_exception_after_error);
2054 2054
 
2055 2055
         return false;
2056 2056
     }
@@ -2068,12 +2068,12 @@  discard block
 block discarded – undo
2068 2068
             '`',
2069 2069
             '``',
2070 2070
             \trim(
2071
-                (string) $this->escape($str, false),
2071
+                (string)$this->escape($str, false),
2072 2072
                 '`'
2073 2073
             )
2074 2074
         );
2075 2075
 
2076
-        return '`' . $str . '`';
2076
+        return '`'.$str.'`';
2077 2077
     }
2078 2078
 
2079 2079
     /**
@@ -2142,10 +2142,10 @@  discard block
 block discarded – undo
2142 2142
         $values = \implode(',', $data);
2143 2143
 
2144 2144
         if ($databaseName) {
2145
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2145
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2146 2146
         }
2147 2147
 
2148
-        $sql = 'REPLACE INTO ' . $databaseName . $this->quote_string($table) . " (${columns}) VALUES (${values})";
2148
+        $sql = 'REPLACE INTO '.$databaseName.$this->quote_string($table)." (${columns}) VALUES (${values})";
2149 2149
 
2150 2150
         $return = $this->query($sql);
2151 2151
         \assert(\is_int($return) || $return === false);
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
                 }
2245 2245
             } else {
2246 2246
                 $varCleaned = [];
2247
-                foreach ((array) $var as $key => $value) {
2247
+                foreach ((array)$var as $key => $value) {
2248 2248
                     $key = $this->escape($key, false, false, $convert_array);
2249 2249
                     $value = $this->secure($value);
2250 2250
 
@@ -2291,7 +2291,7 @@  discard block
 block discarded – undo
2291 2291
         $var = $this->escape($var, false, false, null);
2292 2292
 
2293 2293
         if (\is_string($var)) {
2294
-            $var = "'" . \trim($var, "'") . "'";
2294
+            $var = "'".\trim($var, "'")."'";
2295 2295
         }
2296 2296
 
2297 2297
         return $var;
@@ -2332,10 +2332,10 @@  discard block
 block discarded – undo
2332 2332
         }
2333 2333
 
2334 2334
         if ($databaseName) {
2335
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2335
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2336 2336
         }
2337 2337
 
2338
-        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2338
+        $sql = 'SELECT * FROM '.$databaseName.$this->quote_string($table)." WHERE (${WHERE})";
2339 2339
 
2340 2340
         $return = $this->query($sql);
2341 2341
         \assert($return instanceof Result || $return === false);
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
     public function setConfigExtra(array $extra_config)
2389 2389
     {
2390 2390
         if (isset($extra_config['session_to_db'])) {
2391
-            $this->session_to_db = (bool) $extra_config['session_to_db'];
2391
+            $this->session_to_db = (bool)$extra_config['session_to_db'];
2392 2392
         }
2393 2393
 
2394 2394
         if (isset($extra_config['doctrine'])) {
@@ -2451,9 +2451,9 @@  discard block
 block discarded – undo
2451 2451
             $return = \mysqli_set_charset($this->mysqli_link, $charset);
2452 2452
 
2453 2453
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2454
-            @\mysqli_query($this->mysqli_link, 'SET CHARACTER SET ' . $charset);
2454
+            @\mysqli_query($this->mysqli_link, 'SET CHARACTER SET '.$charset);
2455 2455
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2456
-            @\mysqli_query($this->mysqli_link, "SET NAMES '" . $charset . "'");
2456
+            @\mysqli_query($this->mysqli_link, "SET NAMES '".$charset."'");
2457 2457
         } elseif ($this->doctrine_connection && $this->isDoctrinePDOConnection()) {
2458 2458
             $doctrineWrappedConnection = $this->getDoctrinePDOConnection();
2459 2459
             if (!$doctrineWrappedConnection instanceof Connection) {
@@ -2461,9 +2461,9 @@  discard block
 block discarded – undo
2461 2461
             }
2462 2462
 
2463 2463
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2464
-            @$doctrineWrappedConnection->exec('SET CHARACTER SET ' . $charset);
2464
+            @$doctrineWrappedConnection->exec('SET CHARACTER SET '.$charset);
2465 2465
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2466
-            @$doctrineWrappedConnection->exec("SET NAMES '" . $charset . "'");
2466
+            @$doctrineWrappedConnection->exec("SET NAMES '".$charset."'");
2467 2467
 
2468 2468
             $return = true;
2469 2469
         } else {
@@ -2604,7 +2604,7 @@  discard block
 block discarded – undo
2604 2604
      */
2605 2605
     public function table_exists(string $table): bool
2606 2606
     {
2607
-        $check = $this->query('SELECT 1 FROM ' . $this->quote_string($table));
2607
+        $check = $this->query('SELECT 1 FROM '.$this->quote_string($table));
2608 2608
 
2609 2609
         return $check !== false
2610 2610
                &&
@@ -2635,7 +2635,7 @@  discard block
 block discarded – undo
2635 2635
             $result = $callback($this);
2636 2636
             if ($result === false) {
2637 2637
                 /** @noinspection ThrowRawExceptionInspection */
2638
-                throw new \Exception('call_user_func [' . \print_r($callback, true) . '] === false');
2638
+                throw new \Exception('call_user_func ['.\print_r($callback, true).'] === false');
2639 2639
             }
2640 2640
 
2641 2641
             return $this->commit();
@@ -2697,10 +2697,10 @@  discard block
 block discarded – undo
2697 2697
         }
2698 2698
 
2699 2699
         if ($databaseName) {
2700
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2700
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2701 2701
         }
2702 2702
 
2703
-        $sql = 'UPDATE ' . $databaseName . $this->quote_string($table) . " SET ${SET} WHERE (${WHERE})";
2703
+        $sql = 'UPDATE '.$databaseName.$this->quote_string($table)." SET ${SET} WHERE (${WHERE})";
2704 2704
 
2705 2705
         $return = $this->query($sql);
2706 2706
         \assert(\is_int($return) || $return === false);
Please login to merge, or discard this patch.
src/voku/db/Helper.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $configOrig = $dbConnection->getConfig();
26 26
         \array_walk_recursive(
27 27
             $configOrig,
28
-            static function ($k, $v) use (&$configTmp) {
28
+            static function($k, $v) use (&$configTmp) {
29 29
                 $configTmp[] = $v;
30 30
                 $configTmp[] = $k;
31 31
             }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $optimized = 0;
52 52
         if (!empty($tables)) {
53 53
             foreach ($tables as $table) {
54
-                $optimize = 'OPTIMIZE TABLE ' . $dbConnection->quote_string($table);
54
+                $optimize = 'OPTIMIZE TABLE '.$dbConnection->quote_string($table);
55 55
                 $result = $dbConnection->query($optimize);
56 56
                 if ($result) {
57 57
                     $optimized++;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $optimized = 0;
80 80
         if (!empty($tables)) {
81 81
             foreach ($tables as $table) {
82
-                $optimize = 'REPAIR TABLE ' . $dbConnection->quote_string($table);
82
+                $optimize = 'REPAIR TABLE '.$dbConnection->quote_string($table);
83 83
                 $result = $dbConnection->query($optimize);
84 84
                 if ($result) {
85 85
                     $optimized++;
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
 
214 214
         $whereSQL = $dbConnection->_parseArrayPair($whereArray, 'AND');
215 215
         if ($whereSQL) {
216
-            $whereSQL = 'AND ' . $whereSQL;
216
+            $whereSQL = 'AND '.$whereSQL;
217 217
         }
218 218
 
219 219
         if ($databaseName) {
220
-            $databaseName = $dbConnection->quote_string(\trim($databaseName)) . '.';
220
+            $databaseName = $dbConnection->quote_string(\trim($databaseName)).'.';
221 221
         }
222 222
 
223 223
         // get the row
224
-        $query = 'SELECT ' . $dbConnection->quote_string($searchFieldName) . ', ' . $dbConnection->quote_string($idFieldName) . ' 
225
-          FROM ' . $databaseName . $dbConnection->quote_string($table) . '
224
+        $query = 'SELECT '.$dbConnection->quote_string($searchFieldName).', '.$dbConnection->quote_string($idFieldName).' 
225
+          FROM ' . $databaseName.$dbConnection->quote_string($table).'
226 226
           WHERE 1 = 1
227
-          ' . $whereSQL . '
227
+          ' . $whereSQL.'
228 228
         ';
229 229
 
230 230
         if ($useCache) {
231 231
             $cache = new Cache(null, null, false, $useCache);
232
-            $cacheKey = 'sql-phonetic-search-' . \md5($query);
232
+            $cacheKey = 'sql-phonetic-search-'.\md5($query);
233 233
 
234 234
             if (
235 235
                 $cache->getCacheIsReady()
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             return '';
314 314
         }
315 315
 
316
-        return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_client_version($mysqli_link);
316
+        return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = (string)\mysqli_get_client_version($mysqli_link);
317 317
     }
318 318
 
319 319
     /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         if ($doctrineConnection) {
342 342
             $doctrineWrappedConnection = $doctrineConnection->getWrappedConnection();
343 343
             if ($doctrineWrappedConnection instanceof \Doctrine\DBAL\Driver\PDOConnection) {
344
-                return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) $doctrineWrappedConnection->getServerVersion();
344
+                return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string)$doctrineWrappedConnection->getServerVersion();
345 345
             }
346 346
         }
347 347
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             return '';
351 351
         }
352 352
 
353
-        return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_server_version($mysqli_link);
353
+        return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string)\mysqli_get_server_version($mysqli_link);
354 354
     }
355 355
 
356 356
     /**
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
         }
392 392
 
393 393
         if ($databaseName) {
394
-            $databaseName = $dbConnection->quote_string(\trim($databaseName)) . '.';
394
+            $databaseName = $dbConnection->quote_string(\trim($databaseName)).'.';
395 395
         }
396 396
 
397
-        $sql = 'SHOW COLUMNS FROM ' . $databaseName . $dbConnection->escape($table);
397
+        $sql = 'SHOW COLUMNS FROM '.$databaseName.$dbConnection->escape($table);
398 398
         $result = $dbConnection->query($sql);
399 399
 
400 400
         if ($result instanceof Result && $result->num_rows > 0) {
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
 
447 447
         $whereSQL = $dbConnection->_parseArrayPair($whereArray, 'AND');
448 448
         if ($whereSQL) {
449
-            $whereSQL = 'AND ' . $whereSQL;
449
+            $whereSQL = 'AND '.$whereSQL;
450 450
         }
451 451
 
452 452
         if ($databaseName) {
453
-            $databaseName = $dbConnection->quote_string(\trim($databaseName)) . '.';
453
+            $databaseName = $dbConnection->quote_string(\trim($databaseName)).'.';
454 454
         }
455 455
 
456 456
         // get the row
457
-        $query = 'SELECT * FROM ' . $databaseName . $dbConnection->quote_string($table) . '
457
+        $query = 'SELECT * FROM '.$databaseName.$dbConnection->quote_string($table).'
458 458
           WHERE 1 = 1
459
-          ' . $whereSQL . '
459
+          ' . $whereSQL.'
460 460
         ';
461 461
         $result = $dbConnection->query($query);
462 462
 
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
                 foreach ($tmpArray as $fieldName => $value) {
476 476
                     if (!\in_array($fieldName, $ignoreArray, true)) {
477 477
                         if (\array_key_exists($fieldName, $updateArray)) {
478
-                            $insert_keys .= ',' . $fieldName;
478
+                            $insert_keys .= ','.$fieldName;
479 479
                             $insert_values .= ',?';
480 480
                             $bindings[] = $updateArray[$fieldName]; // INFO: do not escape non selected data
481 481
                         } else {
482
-                            $insert_keys .= ',' . $fieldName;
482
+                            $insert_keys .= ','.$fieldName;
483 483
                             $insert_values .= ',?';
484 484
                             $bindings[] = $value; // INFO: do not escape non selected data
485 485
                         }
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
                 $insert_values = \ltrim($insert_values, ',');
491 491
 
492 492
                 // insert the "copied" row
493
-                $new_query = 'INSERT INTO ' . $databaseName . $dbConnection->quote_string($table) . ' 
494
-                  (' . $insert_keys . ')
493
+                $new_query = 'INSERT INTO '.$databaseName.$dbConnection->quote_string($table).' 
494
+                  (' . $insert_keys.')
495 495
                   VALUES 
496
-                  (' . $insert_values . ')
496
+                  (' . $insert_values.')
497 497
                 ';
498 498
 
499 499
                 $return = $dbConnection->query($new_query, $bindings);
Please login to merge, or discard this patch.
src/voku/db/Prepare.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
         $value = $this->_db->escape($value);
102 102
 
103 103
         if ($type === 's') {
104
-            $valueForSqlWithBoundParameters = "'" . $value . "'";
104
+            $valueForSqlWithBoundParameters = "'".$value."'";
105 105
         } elseif ($type === 'i') {
106
-            $valueForSqlWithBoundParameters = (int) $value;
106
+            $valueForSqlWithBoundParameters = (int)$value;
107 107
         } elseif ($type === 'd') {
108
-            $valueForSqlWithBoundParameters = (float) $value;
108
+            $valueForSqlWithBoundParameters = (float)$value;
109 109
         } else {
110 110
             $valueForSqlWithBoundParameters = $value;
111 111
         }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
             // "INSERT" || "REPLACE"
206 206
             if (\preg_match('/^\s*"?(INSERT|REPLACE)\s+/i', $this->_sql)) {
207
-                $insert_id = (int) $this->insert_id;
207
+                $insert_id = (int)$this->insert_id;
208 208
                 $this->_debug->logQuery($this->_sql_with_bound_parameters, $query_duration, $insert_id);
209 209
 
210 210
                 return $insert_id;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
             // "UPDATE" || "DELETE"
214 214
             if (\preg_match('/^\s*"?(UPDATE|DELETE)\s+/i', $this->_sql)) {
215
-                $affected_rows = (int) $this->affected_rows;
215
+                $affected_rows = (int)$this->affected_rows;
216 216
                 $this->_debug->logQuery($this->_sql_with_bound_parameters, $query_duration, $affected_rows);
217 217
 
218 218
                 return $affected_rows;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                     return $this->queryErrorHandling($this->error, $this->_sql_with_bound_parameters);
230 230
                 }
231 231
 
232
-                $num_rows = (int) $select_result->num_rows;
232
+                $num_rows = (int)$select_result->num_rows;
233 233
                 $this->_debug->logQuery($this->_sql_with_bound_parameters, $query_duration, $num_rows);
234 234
 
235 235
                 return new Result($this->_sql_with_bound_parameters, $select_result);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     public function prepare($query): bool
289 289
     {
290 290
         if (!\is_string($query)) {
291
-            throw new \InvalidArgumentException('$query was no string: ' . \gettype($query));
291
+            throw new \InvalidArgumentException('$query was no string: '.\gettype($query));
292 292
         }
293 293
 
294 294
         $this->_sql = $query;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         $bool = parent::prepare($query);
308 308
 
309 309
         if ($bool === false) {
310
-            $this->_debug->displayError('Can not prepare query: ' . $query . ' | ' . $this->error, false);
310
+            $this->_debug->displayError('Can not prepare query: '.$query.' | '.$this->error, false);
311 311
         }
312 312
 
313 313
         return $bool;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 // we need to replace the question mark "?" here
369 369
                 $values[1] = \str_replace('?', '###simple_mysqli__prepare_question_mark###', $values[1]);
370 370
                 // build the query (only for debugging)
371
-                $testQuery = (string) \preg_replace("/\?/", $values[1], $testQuery, 1);
371
+                $testQuery = (string)\preg_replace("/\?/", $values[1], $testQuery, 1);
372 372
             }
373 373
             $testQuery = \str_replace('###simple_mysqli__prepare_question_mark###', '?', $testQuery);
374 374
         }
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
 
400 400
             // exit if we have more then 3 "DB server has gone away"-errors
401 401
             if ($RECONNECT_COUNTER > 3) {
402
-                $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
402
+                $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg.":\n<br />".$sql, 5);
403 403
 
404 404
                 throw new DBGoneAwayException($errorMsg);
405 405
             }
406 406
 
407
-            $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
407
+            $this->_debug->mailToAdmin('DB-Error', $errorMsg.":\n<br />".$sql);
408 408
 
409 409
             // reconnect
410 410
             $RECONNECT_COUNTER++;
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
             return $this->execute();
415 415
         }
416 416
 
417
-        $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
417
+        $this->_debug->mailToAdmin('SQL-Error', $errorMsg.":\n<br />".$sql);
418 418
 
419 419
         // this query returned an error, we must display it (only for dev) !!!
420
-        $this->_debug->displayError($errorMsg . ' | ' . $sql);
420
+        $this->_debug->displayError($errorMsg.' | '.$sql);
421 421
 
422 422
         return false;
423 423
     }
Please login to merge, or discard this patch.
src/voku/db/Result.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             &&
149 149
             !$result instanceof \Doctrine\DBAL\Statement
150 150
         ) {
151
-            throw new \InvalidArgumentException('$result must be ' . \mysqli_result::class . ' or ' . \Doctrine\DBAL\Statement::class . ' !');
151
+            throw new \InvalidArgumentException('$result must be '.\mysqli_result::class.' or '.\Doctrine\DBAL\Statement::class.' !');
152 152
         }
153 153
 
154 154
         $this->_result = $result;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
             $this->num_rows = $this->_result->rowCount();
172 172
         } else {
173
-            $this->num_rows = (int) $this->_result->num_rows;
173
+            $this->num_rows = (int)$this->_result->num_rows;
174 174
         }
175 175
 
176 176
         $this->current_row = 0;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function __toString()
213 213
     {
214
-        return (string) $this->num_rows;
214
+        return (string)$this->num_rows;
215 215
     }
216 216
 
217 217
     /**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         }
528 528
 
529 529
         return Arrayy::createFromGeneratorFunction(
530
-            function () {
530
+            function() {
531 531
                 $this->reset();
532 532
 
533 533
                 /** @noinspection PhpAssignmentInConditionInspection */
@@ -867,8 +867,8 @@  discard block
 block discarded – undo
867 867
 
868 868
         if ($as_array) {
869 869
             $fields = \array_map(
870
-                static function ($object) {
871
-                    return (array) $object;
870
+                static function($object) {
871
+                    return (array)$object;
872 872
                 },
873 873
                 $fields
874 874
             );
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
         }
1049 1049
 
1050 1050
         return \array_map(
1051
-            static function ($values) use ($keys) {
1051
+            static function($values) use ($keys) {
1052 1052
                 return \array_combine($keys, $values);
1053 1053
             },
1054 1054
             $rows
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
                     $fieldTmp->{$metadataTmpKey} = $metadataTmpValue;
1196 1196
                 }
1197 1197
 
1198
-                $typeNativeTmp = 'MYSQL_TYPE_' . $metadataTmp['native_type'];
1198
+                $typeNativeTmp = 'MYSQL_TYPE_'.$metadataTmp['native_type'];
1199 1199
                 $typeTmp = $THIS_CLASS_TMP->getConstant($typeNativeTmp);
1200 1200
                 if ($typeTmp) {
1201 1201
                     $fieldTmp->type = $typeTmp;
@@ -1549,11 +1549,11 @@  discard block
 block discarded – undo
1549 1549
             if (\abs($offset) > $this->num_rows) {
1550 1550
                 $offset = 0;
1551 1551
             } else {
1552
-                $offset = $this->num_rows - (int) \abs($offset);
1552
+                $offset = $this->num_rows - (int)\abs($offset);
1553 1553
             }
1554 1554
         }
1555 1555
 
1556
-        $length = $length !== null ? (int) $length : $this->num_rows;
1556
+        $length = $length !== null ? (int)$length : $this->num_rows;
1557 1557
         $n = 0;
1558 1558
         for ($i = $offset; $i < $this->num_rows && $n < $length; $i++) {
1559 1559
             if ($preserve_keys) {
Please login to merge, or discard this patch.
src/voku/db/Debug.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         } else {
114 114
 
115 115
             // for testing with dev-address
116
-            $noDev = isset($_GET['noDev']) ? (int) $_GET['noDev'] : 0;
116
+            $noDev = isset($_GET['noDev']) ? (int)$_GET['noDev'] : 0;
117 117
             $remoteIpAddress = $_SERVER['REMOTE_ADDR'] ?? false;
118 118
 
119 119
             if (
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     {
164 164
         $fileInfo = $this->getFileAndLineFromSql();
165 165
 
166
-        $log = '[' . \date('Y-m-d H:i:s') . ']: SQL-Error: ' . $error . ' | Trace: ' . $fileInfo['path'] . '<br>';
166
+        $log = '['.\date('Y-m-d H:i:s').']: SQL-Error: '.$error.' | Trace: '.$fileInfo['path'].'<br>';
167 167
 
168 168
         $this->logger(['error', $log]);
169 169
 
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 
180 180
             if (\PHP_SAPI === 'cli') {
181 181
                 echo "\n";
182
-                echo 'Error: ' . $error . "\n";
183
-                echo 'Trace: ' . $fileInfo['path'] . "\n";
182
+                echo 'Error: '.$error."\n";
183
+                echo 'Trace: '.$fileInfo['path']."\n";
184 184
                 echo "\n";
185 185
             } else {
186 186
                 echo '
187
-                <div class="OBJ-mysql-box" style="border: ' . $box_border . '; background: ' . $box_bg . '; padding: 10px; margin: 10px;">
187
+                <div class="OBJ-mysql-box" style="border: ' . $box_border.'; background: '.$box_bg.'; padding: 10px; margin: 10px;">
188 188
                   <b style="font-size: 14px;">MYSQL Error:</b>
189 189
                   <code style="display: block;">
190
-                    Error:' . $error . '
190
+                    Error:' . $error.'
191 191
                     <br><br>
192
-                    Trace: ' . $fileInfo['path'] . '
192
+                    Trace: ' . $fileInfo['path'].'
193 193
                   </code>
194 194
                 </div>
195 195
                 ';
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 continue;
245 245
             }
246 246
 
247
-            $path .= ($referrer[$key]['class'] ?? $referrer[$key]['file'] ?? '') . '::' . ($referrer[$key]['function'] ?? '') . ':' . ($referrer[$key - 1]['line'] ?? '') . ' <- ';
247
+            $path .= ($referrer[$key]['class'] ?? $referrer[$key]['file'] ?? '').'::'.($referrer[$key]['function'] ?? '').':'.($referrer[$key - 1]['line'] ?? '').' <- ';
248 248
         }
249 249
 
250 250
         $return['path'] = $path;
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
                 /** @noinspection PhpUsageOfSilenceOperatorInspection */
325 325
                 $traceStringExtra = @\mysqli_info($tmpLink);
326 326
                 if ($traceStringExtra) {
327
-                    $traceStringExtra = ' | info => ' . $traceStringExtra;
327
+                    $traceStringExtra = ' | info => '.$traceStringExtra;
328 328
                 }
329 329
             }
330 330
 
331
-            $traceStringExtra = ' | results => ' . \print_r($results, true) . $traceStringExtra;
331
+            $traceStringExtra = ' | results => '.\print_r($results, true).$traceStringExtra;
332 332
         }
333 333
 
334 334
         static $SLOW_QUERY_WARNING = null;
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
             $queryStatus = ' ERROR (REPEAT) ';
357 357
         }
358 358
 
359
-        $queryLog = '[' . \date('Y-m-d H:i:s') . ']: ' . $queryStatus . ' Duration: SQL::::DURATION-START' . \round($duration, 5) . 'SQL::::DURATION-END | Repeat: ' . $QUERY_LOG_FILE_INFO[$cacheKey] . ' | Host: ' . $this->_db->getConfig()['hostname'] . ' | Trace: ' . $fileInfo['path'] . ' | SQL: SQL::::QUERY-START ' . \str_replace("\n", '', $sql) . ' SQL::::QUERY-END' . $traceStringExtra . "\n";
359
+        $queryLog = '['.\date('Y-m-d H:i:s').']: '.$queryStatus.' Duration: SQL::::DURATION-START'.\round($duration, 5).'SQL::::DURATION-END | Repeat: '.$QUERY_LOG_FILE_INFO[$cacheKey].' | Host: '.$this->_db->getConfig()['hostname'].' | Trace: '.$fileInfo['path'].' | SQL: SQL::::QUERY-START '.\str_replace("\n", '', $sql).' SQL::::QUERY-END'.$traceStringExtra."\n";
360 360
 
361 361
         return $this->logger([$logLevel, $queryLog, 'sql']);
362 362
     }
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
             mailToAdmin($subject, $htmlBody, $priority);
430 430
         } else {
431 431
             if ($priority === 3) {
432
-                $this->logger(['debug', $subject . ' | ' . $htmlBody]);
432
+                $this->logger(['debug', $subject.' | '.$htmlBody]);
433 433
             } elseif ($priority > 3) {
434
-                $this->logger(['error', $subject . ' | ' . $htmlBody]);
434
+                $this->logger(['error', $subject.' | '.$htmlBody]);
435 435
             } else {
436
-                $this->logger(['info', $subject . ' | ' . $htmlBody]);
436
+                $this->logger(['info', $subject.' | '.$htmlBody]);
437 437
             }
438 438
         }
439 439
     }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      */
446 446
     public function setEchoOnError($echo_on_error)
447 447
     {
448
-        $this->echo_on_error = (bool) $echo_on_error;
448
+        $this->echo_on_error = (bool)$echo_on_error;
449 449
     }
450 450
 
451 451
     /**
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      */
456 456
     public function setExitOnError($exit_on_error)
457 457
     {
458
-        $this->exit_on_error = (bool) $exit_on_error;
458
+        $this->exit_on_error = (bool)$exit_on_error;
459 459
     }
460 460
 
461 461
     /**
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
      */
466 466
     public function setLoggerClassName($logger_class_name)
467 467
     {
468
-        $this->logger_class_name = (string) $logger_class_name;
468
+        $this->logger_class_name = (string)$logger_class_name;
469 469
     }
470 470
 
471 471
     /**
@@ -475,6 +475,6 @@  discard block
 block discarded – undo
475 475
      */
476 476
     public function setLoggerLevel($logger_level)
477 477
     {
478
-        $this->logger_level = (string) $logger_level;
478
+        $this->logger_level = (string)$logger_level;
479 479
     }
480 480
 }
Please login to merge, or discard this patch.