Completed
Push — master ( 4b3e9c...46623e )
by Lars
02:02
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
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
         }
318 318
 
319 319
         if ($port) {
320
-            $this->port = (int) $port;
320
+            $this->port = (int)$port;
321 321
         } else {
322 322
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
323
-            $this->port = (int) @\ini_get('mysqli.default_port');
323
+            $this->port = (int)@\ini_get('mysqli.default_port');
324 324
         }
325 325
 
326 326
         // fallback
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
         foreach ($arrayPair as $_key => $_value) {
374 374
             $_connector = '=';
375 375
             $_glueHelper = '';
376
-            $_key_upper = \strtoupper((string) $_key);
376
+            $_key_upper = \strtoupper((string)$_key);
377 377
 
378 378
             if (\strpos($_key_upper, ' NOT') !== false) {
379 379
                 $_connector = 'NOT';
@@ -455,30 +455,30 @@  discard block
 block discarded – undo
455 455
                 }
456 456
 
457 457
                 if ($_connector === 'NOT IN' || $_connector === 'IN') {
458
-                    $_value = '(' . \implode(',', $_value) . ')';
458
+                    $_value = '('.\implode(',', $_value).')';
459 459
                 } elseif ($_connector === 'NOT BETWEEN' || $_connector === 'BETWEEN') {
460
-                    $_value = '(' . \implode(' AND ', $_value) . ')';
460
+                    $_value = '('.\implode(' AND ', $_value).')';
461 461
                 } elseif ($firstKey && $firstValue) {
462
-                    if (\strpos((string) $firstKey, ' +') !== false) {
463
-                        $firstKey = \str_replace(' +', '', (string) $firstKey);
464
-                        $_value = $firstKey . ' + ' . $firstValue;
462
+                    if (\strpos((string)$firstKey, ' +') !== false) {
463
+                        $firstKey = \str_replace(' +', '', (string)$firstKey);
464
+                        $_value = $firstKey.' + '.$firstValue;
465 465
                     }
466 466
 
467
-                    if (\strpos((string) $firstKey, ' -') !== false) {
468
-                        $firstKey = \str_replace(' -', '', (string) $firstKey);
469
-                        $_value = $firstKey . ' - ' . $firstValue;
467
+                    if (\strpos((string)$firstKey, ' -') !== false) {
468
+                        $firstKey = \str_replace(' -', '', (string)$firstKey);
469
+                        $_value = $firstKey.' - '.$firstValue;
470 470
                     }
471 471
                 }
472 472
             } else {
473 473
                 $_value = $this->secure($_value);
474 474
             }
475 475
 
476
-            $_key = UTF8::str_replace_last($_glueHelper, '', (string) $_key);
476
+            $_key = UTF8::str_replace_last($_glueHelper, '', (string)$_key);
477 477
             $_key = UTF8::str_replace_last($_connector, '', $_key);
478 478
 
479 479
             $quoteString = $this->quote_string(\trim($_key));
480 480
 
481
-            $_value = (array) $_value;
481
+            $_value = (array)$_value;
482 482
 
483 483
             if (!$_glueHelper) {
484 484
                 $_glueHelper = $glue;
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
                     $valueInner = "''";
503 503
                 }
504 504
 
505
-                $sql .= ' ' . $_glueHelperInner . ' ' . $quoteString . ' ' . $_connector . ' ' . $valueInner . " \n";
505
+                $sql .= ' '.$_glueHelperInner.' '.$quoteString.' '.$_connector.' '.$valueInner." \n";
506 506
                 $tmpCounter++;
507 507
             }
508 508
 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
             unset($params[$key]);
555 555
 
556 556
             $sql = \substr_replace($sql, $replacement, $offset, 1);
557
-            $offset = \strpos($sql, '?', $offset + \strlen((string) $replacement));
557
+            $offset = \strpos($sql, '?', $offset + \strlen((string)$replacement));
558 558
         }
559 559
 
560 560
         return ['sql' => $sql, 'params' => $params];
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 
592 592
             // add ":" if needed
593 593
             if (\strpos($name, ':') !== 0) {
594
-                $nameTmp = ':' . $name;
594
+                $nameTmp = ':'.$name;
595 595
             } else {
596 596
                 $nameTmp = $name;
597 597
             }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
             if ($offset === null) {
600 600
                 $offset = \strpos($sql, $nameTmp);
601 601
             } else {
602
-                $offset = \strpos($sql, $nameTmp, $offset + \strlen((string) $replacement));
602
+                $offset = \strpos($sql, $nameTmp, $offset + \strlen((string)$replacement));
603 603
             }
604 604
 
605 605
             if ($offset === false) {
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             return \mysqli_affected_rows($this->mysqli_link);
632 632
         }
633 633
 
634
-        return (int) $this->affected_rows;
634
+        return (int)$this->affected_rows;
635 635
     }
636 636
 
637 637
     /**
@@ -845,10 +845,10 @@  discard block
 block discarded – undo
845 845
                 $this->database,
846 846
                 $this->port,
847 847
                 $this->socket,
848
-                (int) $flags
848
+                (int)$flags
849 849
             );
850 850
         } catch (\Exception $e) {
851
-            $error = 'Error connecting to mysql server: ' . $e->getMessage();
851
+            $error = 'Error connecting to mysql server: '.$e->getMessage();
852 852
             $this->debug->displayError($error, false);
853 853
 
854 854
             throw new DBConnectException($error, 100, $e);
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 
858 858
         $errno = \mysqli_connect_errno();
859 859
         if (!$this->connected || $errno) {
860
-            $error = 'Error connecting to mysql server: ' . \mysqli_connect_error() . ' (' . $errno . ')';
860
+            $error = 'Error connecting to mysql server: '.\mysqli_connect_error().' ('.$errno.')';
861 861
             $this->debug->displayError($error, false);
862 862
 
863 863
             throw new DBConnectException($error, 101);
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
         }
881 881
 
882 882
         if (!$this->connected) {
883
-            $error = 'Error connecting to mysql server: ' . \print_r($this->doctrine_connection ? $this->doctrine_connection->errorInfo() : [], false);
883
+            $error = 'Error connecting to mysql server: '.\print_r($this->doctrine_connection ? $this->doctrine_connection->errorInfo() : [], false);
884 884
             $this->debug->displayError($error, false);
885 885
 
886 886
             throw new DBConnectException($error, 101);
@@ -926,10 +926,10 @@  discard block
 block discarded – undo
926 926
         }
927 927
 
928 928
         if ($databaseName) {
929
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
929
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
930 930
         }
931 931
 
932
-        $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
932
+        $sql = 'DELETE FROM '.$databaseName.$this->quote_string($table)." WHERE (${WHERE})";
933 933
 
934 934
         $return = $this->query($sql);
935 935
 
@@ -1030,14 +1030,14 @@  discard block
 block discarded – undo
1030 1030
                 $var = $var->format('Y-m-d H:i:s');
1031 1031
                 $type = 'string';
1032 1032
             } elseif (\method_exists($var, '__toString')) {
1033
-                $var = (string) $var;
1033
+                $var = (string)$var;
1034 1034
                 $type = 'string';
1035 1035
             }
1036 1036
         }
1037 1037
 
1038 1038
         switch ($type) {
1039 1039
             case 'boolean':
1040
-                $var = (int) $var;
1040
+                $var = (int)$var;
1041 1041
 
1042 1042
                 break;
1043 1043
 
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
                     }
1082 1082
                 } else {
1083 1083
                     $varCleaned = [];
1084
-                    foreach ((array) $var as $key => $value) {
1084
+                    foreach ((array)$var as $key => $value) {
1085 1085
                         $key = $this->escape($key, $stripe_non_utf8, $html_entity_decode);
1086 1086
                         $value = $this->escape($value, $stripe_non_utf8, $html_entity_decode);
1087 1087
 
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 
1146 1146
         if ($useCache) {
1147 1147
             $cache = new \voku\cache\Cache(null, null, false, $useCache);
1148
-            $cacheKey = 'sql-' . \md5($query);
1148
+            $cacheKey = 'sql-'.\md5($query);
1149 1149
 
1150 1150
             if (
1151 1151
                 $cache->getCacheIsReady()
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
         }
1322 1322
 
1323 1323
         if (
1324
-            '' . $hostname . $username . $password . $database . $port . $charset === '' . $port . $charset
1324
+            ''.$hostname.$username.$password.$database.$port.$charset === ''.$port.$charset
1325 1325
             &&
1326 1326
             $firstInstance instanceof self
1327 1327
         ) {
@@ -1337,13 +1337,13 @@  discard block
 block discarded – undo
1337 1337
             if (\is_object($extra_config_value)) {
1338 1338
                 $extra_config_value_tmp = \spl_object_hash($extra_config_value);
1339 1339
             } else {
1340
-                $extra_config_value_tmp = (string) $extra_config_value;
1340
+                $extra_config_value_tmp = (string)$extra_config_value;
1341 1341
             }
1342
-            $extra_config_string .= $extra_config_key . $extra_config_value_tmp;
1342
+            $extra_config_string .= $extra_config_key.$extra_config_value_tmp;
1343 1343
         }
1344 1344
 
1345 1345
         $connection = \md5(
1346
-            $hostname . $username . $password . $database . $port . $charset . (int) $exit_on_error . (int) $echo_on_error . $logger_class_name . $logger_level . $extra_config_string
1346
+            $hostname.$username.$password.$database.$port.$charset.(int)$exit_on_error.(int)$echo_on_error.$logger_class_name.$logger_level.$extra_config_string
1347 1347
         );
1348 1348
 
1349 1349
         if (!isset($instance[$connection])) {
@@ -1486,10 +1486,10 @@  discard block
 block discarded – undo
1486 1486
         $SET = $this->_parseArrayPair($data);
1487 1487
 
1488 1488
         if ($databaseName) {
1489
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1489
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
1490 1490
         }
1491 1491
 
1492
-        $sql = 'INSERT INTO ' . $databaseName . $this->quote_string($table) . " SET ${SET}";
1492
+        $sql = 'INSERT INTO '.$databaseName.$this->quote_string($table)." SET ${SET}";
1493 1493
 
1494 1494
         $return = $this->query($sql);
1495 1495
         if ($return === false) {
@@ -2022,12 +2022,12 @@  discard block
 block discarded – undo
2022 2022
 
2023 2023
             // exit if we have more then 3 "DB server has gone away"-errors
2024 2024
             if ($RECONNECT_COUNTER > 3) {
2025
-                $this->debug->mailToAdmin('DB-Fatal-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql, 5);
2025
+                $this->debug->mailToAdmin('DB-Fatal-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql, 5);
2026 2026
 
2027 2027
                 throw new DBGoneAwayException($errorMessage);
2028 2028
             }
2029 2029
 
2030
-            $this->debug->mailToAdmin('DB-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
2030
+            $this->debug->mailToAdmin('DB-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
2031 2031
 
2032 2032
             // reconnect
2033 2033
             $RECONNECT_COUNTER++;
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
             return false;
2042 2042
         }
2043 2043
 
2044
-        $this->debug->mailToAdmin('SQL-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
2044
+        $this->debug->mailToAdmin('SQL-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
2045 2045
 
2046 2046
         $force_exception_after_error = null; // auto
2047 2047
         if ($this->in_transaction) {
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
         }
2050 2050
         // this query returned an error, we must display it (only for dev) !!!
2051 2051
 
2052
-        $this->debug->displayError($errorMessage . '(' . $errorNumber . ') ' . ' | ' . $sql, $force_exception_after_error);
2052
+        $this->debug->displayError($errorMessage.'('.$errorNumber.') '.' | '.$sql, $force_exception_after_error);
2053 2053
 
2054 2054
         return false;
2055 2055
     }
@@ -2067,12 +2067,12 @@  discard block
 block discarded – undo
2067 2067
             '`',
2068 2068
             '``',
2069 2069
             \trim(
2070
-                (string) $this->escape($str, false),
2070
+                (string)$this->escape($str, false),
2071 2071
                 '`'
2072 2072
             )
2073 2073
         );
2074 2074
 
2075
-        return '`' . $str . '`';
2075
+        return '`'.$str.'`';
2076 2076
     }
2077 2077
 
2078 2078
     /**
@@ -2141,10 +2141,10 @@  discard block
 block discarded – undo
2141 2141
         $values = \implode(',', $data);
2142 2142
 
2143 2143
         if ($databaseName) {
2144
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2144
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2145 2145
         }
2146 2146
 
2147
-        $sql = 'REPLACE INTO ' . $databaseName . $this->quote_string($table) . " (${columns}) VALUES (${values})";
2147
+        $sql = 'REPLACE INTO '.$databaseName.$this->quote_string($table)." (${columns}) VALUES (${values})";
2148 2148
 
2149 2149
         $return = $this->query($sql);
2150 2150
         \assert(\is_int($return) || $return === false);
@@ -2243,7 +2243,7 @@  discard block
 block discarded – undo
2243 2243
                 }
2244 2244
             } else {
2245 2245
                 $varCleaned = [];
2246
-                foreach ((array) $var as $key => $value) {
2246
+                foreach ((array)$var as $key => $value) {
2247 2247
                     $key = $this->escape($key, false, false, $convert_array);
2248 2248
                     $value = $this->secure($value);
2249 2249
 
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
         $var = $this->escape($var, false, false, null);
2291 2291
 
2292 2292
         if (\is_string($var)) {
2293
-            $var = "'" . \trim($var, "'") . "'";
2293
+            $var = "'".\trim($var, "'")."'";
2294 2294
         }
2295 2295
 
2296 2296
         return $var;
@@ -2331,10 +2331,10 @@  discard block
 block discarded – undo
2331 2331
         }
2332 2332
 
2333 2333
         if ($databaseName) {
2334
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2334
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2335 2335
         }
2336 2336
 
2337
-        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2337
+        $sql = 'SELECT * FROM '.$databaseName.$this->quote_string($table)." WHERE (${WHERE})";
2338 2338
 
2339 2339
         $return = $this->query($sql);
2340 2340
         \assert($return instanceof Result || $return === false);
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
     public function setConfigExtra(array $extra_config)
2388 2388
     {
2389 2389
         if (isset($extra_config['session_to_db'])) {
2390
-            $this->session_to_db = (bool) $extra_config['session_to_db'];
2390
+            $this->session_to_db = (bool)$extra_config['session_to_db'];
2391 2391
         }
2392 2392
 
2393 2393
         if (isset($extra_config['doctrine'])) {
@@ -2450,9 +2450,9 @@  discard block
 block discarded – undo
2450 2450
             $return = \mysqli_set_charset($this->mysqli_link, $charset);
2451 2451
 
2452 2452
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2453
-            @\mysqli_query($this->mysqli_link, 'SET CHARACTER SET ' . $charset);
2453
+            @\mysqli_query($this->mysqli_link, 'SET CHARACTER SET '.$charset);
2454 2454
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2455
-            @\mysqli_query($this->mysqli_link, "SET NAMES '" . $charset . "'");
2455
+            @\mysqli_query($this->mysqli_link, "SET NAMES '".$charset."'");
2456 2456
         } elseif ($this->doctrine_connection && $this->isDoctrinePDOConnection()) {
2457 2457
             $doctrineWrappedConnection = $this->getDoctrinePDOConnection();
2458 2458
             if (!$doctrineWrappedConnection instanceof \Doctrine\DBAL\Connection) {
@@ -2460,9 +2460,9 @@  discard block
 block discarded – undo
2460 2460
             }
2461 2461
 
2462 2462
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2463
-            @$doctrineWrappedConnection->exec('SET CHARACTER SET ' . $charset);
2463
+            @$doctrineWrappedConnection->exec('SET CHARACTER SET '.$charset);
2464 2464
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2465
-            @$doctrineWrappedConnection->exec("SET NAMES '" . $charset . "'");
2465
+            @$doctrineWrappedConnection->exec("SET NAMES '".$charset."'");
2466 2466
 
2467 2467
             $return = true;
2468 2468
         } else {
@@ -2603,7 +2603,7 @@  discard block
 block discarded – undo
2603 2603
      */
2604 2604
     public function table_exists(string $table): bool
2605 2605
     {
2606
-        $check = $this->query('SELECT 1 FROM ' . $this->quote_string($table));
2606
+        $check = $this->query('SELECT 1 FROM '.$this->quote_string($table));
2607 2607
 
2608 2608
         return $check !== false
2609 2609
                &&
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
             $result = $callback($this);
2635 2635
             if ($result === false) {
2636 2636
                 /** @noinspection ThrowRawExceptionInspection */
2637
-                throw new \Exception('call_user_func [' . \print_r($callback, true) . '] === false');
2637
+                throw new \Exception('call_user_func ['.\print_r($callback, true).'] === false');
2638 2638
             }
2639 2639
 
2640 2640
             return $this->commit();
@@ -2696,10 +2696,10 @@  discard block
 block discarded – undo
2696 2696
         }
2697 2697
 
2698 2698
         if ($databaseName) {
2699
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2699
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2700 2700
         }
2701 2701
 
2702
-        $sql = 'UPDATE ' . $databaseName . $this->quote_string($table) . " SET ${SET} WHERE (${WHERE})";
2702
+        $sql = 'UPDATE '.$databaseName.$this->quote_string($table)." SET ${SET} WHERE (${WHERE})";
2703 2703
 
2704 2704
         $return = $this->query($sql);
2705 2705
         \assert(\is_int($return) || $return === false);
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/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.
src/voku/db/Helper.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
         $configOrig = $dbConnection->getConfig();
23 23
         \array_walk_recursive(
24 24
             $configOrig,
25
-            static function ($k, $v) use (&$configTmp) {
25
+            static function($k, $v) use (&$configTmp) {
26 26
                 $configTmp[] = $v;
27 27
                 $configTmp[] = $k;
28 28
             }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $optimized = 0;
49 49
         if (!empty($tables)) {
50 50
             foreach ($tables as $table) {
51
-                $optimize = 'OPTIMIZE TABLE ' . $dbConnection->quote_string($table);
51
+                $optimize = 'OPTIMIZE TABLE '.$dbConnection->quote_string($table);
52 52
                 $result = $dbConnection->query($optimize);
53 53
                 if ($result) {
54 54
                     $optimized++;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $optimized = 0;
77 77
         if (!empty($tables)) {
78 78
             foreach ($tables as $table) {
79
-                $optimize = 'REPAIR TABLE ' . $dbConnection->quote_string($table);
79
+                $optimize = 'REPAIR TABLE '.$dbConnection->quote_string($table);
80 80
                 $result = $dbConnection->query($optimize);
81 81
                 if ($result) {
82 82
                     $optimized++;
@@ -210,23 +210,23 @@  discard block
 block discarded – undo
210 210
 
211 211
         $whereSQL = $dbConnection->_parseArrayPair($whereArray, 'AND');
212 212
         if ($whereSQL) {
213
-            $whereSQL = 'AND ' . $whereSQL;
213
+            $whereSQL = 'AND '.$whereSQL;
214 214
         }
215 215
 
216 216
         if ($databaseName) {
217
-            $databaseName = $dbConnection->quote_string(\trim($databaseName)) . '.';
217
+            $databaseName = $dbConnection->quote_string(\trim($databaseName)).'.';
218 218
         }
219 219
 
220 220
         // get the row
221
-        $query = 'SELECT ' . $dbConnection->quote_string($searchFieldName) . ', ' . $dbConnection->quote_string($idFieldName) . ' 
222
-          FROM ' . $databaseName . $dbConnection->quote_string($table) . '
221
+        $query = 'SELECT '.$dbConnection->quote_string($searchFieldName).', '.$dbConnection->quote_string($idFieldName).' 
222
+          FROM ' . $databaseName.$dbConnection->quote_string($table).'
223 223
           WHERE 1 = 1
224
-          ' . $whereSQL . '
224
+          ' . $whereSQL.'
225 225
         ';
226 226
 
227 227
         if ($useCache) {
228 228
             $cache = new \voku\cache\Cache(null, null, false, $useCache);
229
-            $cacheKey = 'sql-phonetic-search-' . \md5($query);
229
+            $cacheKey = 'sql-phonetic-search-'.\md5($query);
230 230
 
231 231
             if (
232 232
                 $cache->getCacheIsReady()
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             return '';
310 310
         }
311 311
 
312
-        return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_client_version($mysqli_link);
312
+        return $MYSQL_CLIENT_VERSION_CACHE[$cacheKey] = (string)\mysqli_get_client_version($mysqli_link);
313 313
     }
314 314
 
315 315
     /**
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         if ($doctrineConnection) {
338 338
             $doctrineWrappedConnection = $doctrineConnection->getWrappedConnection();
339 339
             if ($doctrineWrappedConnection instanceof \Doctrine\DBAL\Driver\PDOConnection) {
340
-                return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) $doctrineWrappedConnection->getServerVersion();
340
+                return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string)$doctrineWrappedConnection->getServerVersion();
341 341
             }
342 342
         }
343 343
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             return '';
347 347
         }
348 348
 
349
-        return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string) \mysqli_get_server_version($mysqli_link);
349
+        return $MYSQL_SERVER_VERSION_CACHE[$cacheKey] = (string)\mysqli_get_server_version($mysqli_link);
350 350
     }
351 351
 
352 352
     /**
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
         }
388 388
 
389 389
         if ($databaseName) {
390
-            $databaseName = $dbConnection->quote_string(\trim($databaseName)) . '.';
390
+            $databaseName = $dbConnection->quote_string(\trim($databaseName)).'.';
391 391
         }
392 392
 
393
-        $sql = 'SHOW COLUMNS FROM ' . $databaseName . $dbConnection->escape($table);
393
+        $sql = 'SHOW COLUMNS FROM '.$databaseName.$dbConnection->escape($table);
394 394
         $result = $dbConnection->query($sql);
395 395
 
396 396
         if ($result instanceof Result && $result->num_rows > 0) {
@@ -442,17 +442,17 @@  discard block
 block discarded – undo
442 442
 
443 443
         $whereSQL = $dbConnection->_parseArrayPair($whereArray, 'AND');
444 444
         if ($whereSQL) {
445
-            $whereSQL = 'AND ' . $whereSQL;
445
+            $whereSQL = 'AND '.$whereSQL;
446 446
         }
447 447
 
448 448
         if ($databaseName) {
449
-            $databaseName = $dbConnection->quote_string(\trim($databaseName)) . '.';
449
+            $databaseName = $dbConnection->quote_string(\trim($databaseName)).'.';
450 450
         }
451 451
 
452 452
         // get the row
453
-        $query = 'SELECT * FROM ' . $databaseName . $dbConnection->quote_string($table) . '
453
+        $query = 'SELECT * FROM '.$databaseName.$dbConnection->quote_string($table).'
454 454
           WHERE 1 = 1
455
-          ' . $whereSQL . '
455
+          ' . $whereSQL.'
456 456
         ';
457 457
         $result = $dbConnection->query($query);
458 458
 
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
                 foreach ($tmpArray as $fieldName => $value) {
472 472
                     if (!\in_array($fieldName, $ignoreArray, true)) {
473 473
                         if (\array_key_exists($fieldName, $updateArray)) {
474
-                            $insert_keys .= ',' . $fieldName;
474
+                            $insert_keys .= ','.$fieldName;
475 475
                             $insert_values .= ',?';
476 476
                             $bindings[] = $updateArray[$fieldName]; // INFO: do not escape non selected data
477 477
                         } else {
478
-                            $insert_keys .= ',' . $fieldName;
478
+                            $insert_keys .= ','.$fieldName;
479 479
                             $insert_values .= ',?';
480 480
                             $bindings[] = $value; // INFO: do not escape non selected data
481 481
                         }
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
                 $insert_values = \ltrim($insert_values, ',');
487 487
 
488 488
                 // insert the "copied" row
489
-                $new_query = 'INSERT INTO ' . $databaseName . $dbConnection->quote_string($table) . ' 
490
-                  (' . $insert_keys . ')
489
+                $new_query = 'INSERT INTO '.$databaseName.$dbConnection->quote_string($table).' 
490
+                  (' . $insert_keys.')
491 491
                   VALUES 
492
-                  (' . $insert_values . ')
492
+                  (' . $insert_values.')
493 493
                 ';
494 494
 
495 495
                 $return = $dbConnection->query($new_query, $bindings);
Please login to merge, or discard this patch.
src/voku/db/Result.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
             &&
145 145
             !$result instanceof \Doctrine\DBAL\Driver\Statement
146 146
         ) {
147
-            throw new \InvalidArgumentException('$result must be ' . \mysqli_result::class . ' or ' . \Doctrine\DBAL\Driver\Statement::class . ' !');
147
+            throw new \InvalidArgumentException('$result must be '.\mysqli_result::class.' or '.\Doctrine\DBAL\Driver\Statement::class.' !');
148 148
         }
149 149
 
150 150
         $this->_result = $result;
151 151
 
152 152
         if ($this->_result instanceof \Doctrine\DBAL\Driver\Statement) {
153 153
             if (\method_exists($this->_result, 'getWrappedStatement')) {
154
-                throw new \InvalidArgumentException('$result (' . \Doctrine\DBAL\Driver\Statement::class . ') must implement "getWrappedStatement()"!');
154
+                throw new \InvalidArgumentException('$result ('.\Doctrine\DBAL\Driver\Statement::class.') must implement "getWrappedStatement()"!');
155 155
             }
156 156
 
157 157
             $doctrineDriver = $this->_result->getWrappedStatement();
@@ -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\Arrayy::createFromGeneratorFunction(
530
-            function () {
530
+            function() {
531 531
                 $this->reset();
532 532
 
533 533
                 /** @noinspection PhpAssignmentInConditionInspection */
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 
878 878
         if ($as_array) {
879 879
             $fields = \array_map(
880
-                static function ($object) {
881
-                    return (array) $object;
880
+                static function($object) {
881
+                    return (array)$object;
882 882
                 },
883 883
                 $fields
884 884
             );
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
         }
1063 1063
 
1064 1064
         return \array_map(
1065
-            static function ($values) use ($keys) {
1065
+            static function($values) use ($keys) {
1066 1066
                 return \array_combine($keys, $values);
1067 1067
             },
1068 1068
             $rows
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
                     $fieldTmp->{$metadataTmpKey} = $metadataTmpValue;
1214 1214
                 }
1215 1215
 
1216
-                $typeNativeTmp = 'MYSQL_TYPE_' . $metadataTmp['native_type'];
1216
+                $typeNativeTmp = 'MYSQL_TYPE_'.$metadataTmp['native_type'];
1217 1217
                 $typeTmp = $THIS_CLASS_TMP->getConstant($typeNativeTmp);
1218 1218
                 if ($typeTmp) {
1219 1219
                     $fieldTmp->type = $typeTmp;
@@ -1575,11 +1575,11 @@  discard block
 block discarded – undo
1575 1575
             if (\abs($offset) > $this->num_rows) {
1576 1576
                 $offset = 0;
1577 1577
             } else {
1578
-                $offset = $this->num_rows - (int) \abs($offset);
1578
+                $offset = $this->num_rows - (int)\abs($offset);
1579 1579
             }
1580 1580
         }
1581 1581
 
1582
-        $length = $length !== null ? (int) $length : $this->num_rows;
1582
+        $length = $length !== null ? (int)$length : $this->num_rows;
1583 1583
         $n = 0;
1584 1584
         for ($i = $offset; $i < $this->num_rows && $n < $length; $i++) {
1585 1585
             if ($preserve_keys) {
Please login to merge, or discard this patch.