Completed
Push — master ( 578b2d...d7dae2 )
by Lars
13:43 queued 10s
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   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
         }
320 320
 
321 321
         if ($port) {
322
-            $this->port = (int) $port;
322
+            $this->port = (int)$port;
323 323
         } else {
324 324
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
325
-            $this->port = (int) @\ini_get('mysqli.default_port');
325
+            $this->port = (int)@\ini_get('mysqli.default_port');
326 326
         }
327 327
 
328 328
         // fallback
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
         foreach ($arrayPair as $_key => $_value) {
376 376
             $_connector = '=';
377 377
             $_glueHelper = '';
378
-            $_key_upper = \strtoupper((string) $_key);
378
+            $_key_upper = \strtoupper((string)$_key);
379 379
 
380 380
             if (\strpos($_key_upper, ' NOT') !== false) {
381 381
                 $_connector = 'NOT';
@@ -457,18 +457,18 @@  discard block
 block discarded – undo
457 457
                 }
458 458
 
459 459
                 if ($_connector === 'NOT IN' || $_connector === 'IN') {
460
-                    $_value = '(' . \implode(',', $_value) . ')';
460
+                    $_value = '('.\implode(',', $_value).')';
461 461
                 } elseif ($_connector === 'NOT BETWEEN' || $_connector === 'BETWEEN') {
462
-                    $_value = '(' . \implode(' AND ', $_value) . ')';
462
+                    $_value = '('.\implode(' AND ', $_value).')';
463 463
                 } elseif ($firstKey && $firstValue) {
464
-                    if (\strpos((string) $firstKey, ' +') !== false) {
465
-                        $firstKey = \str_replace(' +', '', (string) $firstKey);
466
-                        $_value = $firstKey . ' + ' . $firstValue;
464
+                    if (\strpos((string)$firstKey, ' +') !== false) {
465
+                        $firstKey = \str_replace(' +', '', (string)$firstKey);
466
+                        $_value = $firstKey.' + '.$firstValue;
467 467
                     }
468 468
 
469
-                    if (\strpos((string) $firstKey, ' -') !== false) {
470
-                        $firstKey = \str_replace(' -', '', (string) $firstKey);
471
-                        $_value = $firstKey . ' - ' . $firstValue;
469
+                    if (\strpos((string)$firstKey, ' -') !== false) {
470
+                        $firstKey = \str_replace(' -', '', (string)$firstKey);
471
+                        $_value = $firstKey.' - '.$firstValue;
472 472
                     }
473 473
                 }
474 474
             } else {
@@ -477,18 +477,18 @@  discard block
 block discarded – undo
477 477
 
478 478
             $quoteString = $this->quote_string(
479 479
                 \trim(
480
-                    (string) \str_ireplace(
480
+                    (string)\str_ireplace(
481 481
                         [
482 482
                             $_connector,
483 483
                             $_glueHelper,
484 484
                         ],
485 485
                         '',
486
-                        (string) $_key
486
+                        (string)$_key
487 487
                     )
488 488
                 )
489 489
             );
490 490
 
491
-            $_value = (array) $_value;
491
+            $_value = (array)$_value;
492 492
 
493 493
             if (!$_glueHelper) {
494 494
                 $_glueHelper = $glue;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
                     $valueInner = "''";
513 513
                 }
514 514
 
515
-                $sql .= ' ' . $_glueHelperInner . ' ' . $quoteString . ' ' . $_connector . ' ' . $valueInner . " \n";
515
+                $sql .= ' '.$_glueHelperInner.' '.$quoteString.' '.$_connector.' '.$valueInner." \n";
516 516
                 $tmpCounter++;
517 517
             }
518 518
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
             unset($params[$key]);
565 565
 
566 566
             $sql = \substr_replace($sql, $replacement, $offset, 1);
567
-            $offset = \strpos($sql, '?', $offset + \strlen((string) $replacement));
567
+            $offset = \strpos($sql, '?', $offset + \strlen((string)$replacement));
568 568
         }
569 569
 
570 570
         return ['sql' => $sql, 'params' => $params];
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 
602 602
             // add ":" if needed
603 603
             if (\strpos($name, ':') !== 0) {
604
-                $nameTmp = ':' . $name;
604
+                $nameTmp = ':'.$name;
605 605
             } else {
606 606
                 $nameTmp = $name;
607 607
             }
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
             if ($offset === null) {
610 610
                 $offset = \strpos($sql, $nameTmp);
611 611
             } else {
612
-                $offset = \strpos($sql, $nameTmp, $offset + \strlen((string) $replacement));
612
+                $offset = \strpos($sql, $nameTmp, $offset + \strlen((string)$replacement));
613 613
             }
614 614
 
615 615
             if ($offset === false) {
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
             return \mysqli_affected_rows($this->mysqli_link);
642 642
         }
643 643
 
644
-        return (int) $this->affected_rows;
644
+        return (int)$this->affected_rows;
645 645
     }
646 646
 
647 647
     /**
@@ -853,10 +853,10 @@  discard block
 block discarded – undo
853 853
                 $this->database,
854 854
                 $this->port,
855 855
                 $this->socket,
856
-                (int) $flags
856
+                (int)$flags
857 857
             );
858 858
         } catch (\Exception $e) {
859
-            $error = 'Error connecting to mysql server: ' . $e->getMessage();
859
+            $error = 'Error connecting to mysql server: '.$e->getMessage();
860 860
             $this->debug->displayError($error, false);
861 861
 
862 862
             throw new DBConnectException($error, 100, $e);
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 
866 866
         $errno = \mysqli_connect_errno();
867 867
         if (!$this->connected || $errno) {
868
-            $error = 'Error connecting to mysql server: ' . \mysqli_connect_error() . ' (' . $errno . ')';
868
+            $error = 'Error connecting to mysql server: '.\mysqli_connect_error().' ('.$errno.')';
869 869
             $this->debug->displayError($error, false);
870 870
 
871 871
             throw new DBConnectException($error, 101);
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
         }
889 889
 
890 890
         if (!$this->connected) {
891
-            $error = 'Error connecting to mysql server: ' . \print_r($this->doctrine_connection ? $this->doctrine_connection->errorInfo() : [], false);
891
+            $error = 'Error connecting to mysql server: '.\print_r($this->doctrine_connection ? $this->doctrine_connection->errorInfo() : [], false);
892 892
             $this->debug->displayError($error, false);
893 893
 
894 894
             throw new DBConnectException($error, 101);
@@ -931,10 +931,10 @@  discard block
 block discarded – undo
931 931
         }
932 932
 
933 933
         if ($databaseName) {
934
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
934
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
935 935
         }
936 936
 
937
-        $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
937
+        $sql = 'DELETE FROM '.$databaseName.$this->quote_string($table)." WHERE (${WHERE})";
938 938
 
939 939
         $return = $this->query($sql);
940 940
 
@@ -1031,14 +1031,14 @@  discard block
 block discarded – undo
1031 1031
                 $var = $var->format('Y-m-d H:i:s');
1032 1032
                 $type = 'string';
1033 1033
             } elseif (\method_exists($var, '__toString')) {
1034
-                $var = (string) $var;
1034
+                $var = (string)$var;
1035 1035
                 $type = 'string';
1036 1036
             }
1037 1037
         }
1038 1038
 
1039 1039
         switch ($type) {
1040 1040
             case 'boolean':
1041
-                $var = (int) $var;
1041
+                $var = (int)$var;
1042 1042
 
1043 1043
                 break;
1044 1044
 
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
                     }
1083 1083
                 } else {
1084 1084
                     $varCleaned = [];
1085
-                    foreach ((array) $var as $key => $value) {
1085
+                    foreach ((array)$var as $key => $value) {
1086 1086
                         $key = $this->escape($key, $stripe_non_utf8, $html_entity_decode);
1087 1087
                         $value = $this->escape($value, $stripe_non_utf8, $html_entity_decode);
1088 1088
 
@@ -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()
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
         }
1323 1323
 
1324 1324
         if (
1325
-            '' . $hostname . $username . $password . $database . $port . $charset === '' . $port . $charset
1325
+            ''.$hostname.$username.$password.$database.$port.$charset === ''.$port.$charset
1326 1326
             &&
1327 1327
             $firstInstance instanceof self
1328 1328
         ) {
@@ -1338,13 +1338,13 @@  discard block
 block discarded – undo
1338 1338
             if (\is_object($extra_config_value)) {
1339 1339
                 $extra_config_value_tmp = \spl_object_hash($extra_config_value);
1340 1340
             } else {
1341
-                $extra_config_value_tmp = (string) $extra_config_value;
1341
+                $extra_config_value_tmp = (string)$extra_config_value;
1342 1342
             }
1343
-            $extra_config_string .= $extra_config_key . $extra_config_value_tmp;
1343
+            $extra_config_string .= $extra_config_key.$extra_config_value_tmp;
1344 1344
         }
1345 1345
 
1346 1346
         $connection = \md5(
1347
-            $hostname . $username . $password . $database . $port . $charset . (int) $exit_on_error . (int) $echo_on_error . $logger_class_name . $logger_level . $extra_config_string
1347
+            $hostname.$username.$password.$database.$port.$charset.(int)$exit_on_error.(int)$echo_on_error.$logger_class_name.$logger_level.$extra_config_string
1348 1348
         );
1349 1349
 
1350 1350
         if (!isset($instance[$connection])) {
@@ -1484,10 +1484,10 @@  discard block
 block discarded – undo
1484 1484
         $SET = $this->_parseArrayPair($data);
1485 1485
 
1486 1486
         if ($databaseName) {
1487
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1487
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
1488 1488
         }
1489 1489
 
1490
-        $sql = 'INSERT INTO ' . $databaseName . $this->quote_string($table) . " SET ${SET}";
1490
+        $sql = 'INSERT INTO '.$databaseName.$this->quote_string($table)." SET ${SET}";
1491 1491
 
1492 1492
         $return = $this->query($sql);
1493 1493
         if ($return === false) {
@@ -2016,12 +2016,12 @@  discard block
 block discarded – undo
2016 2016
 
2017 2017
             // exit if we have more then 3 "DB server has gone away"-errors
2018 2018
             if ($RECONNECT_COUNTER > 3) {
2019
-                $this->debug->mailToAdmin('DB-Fatal-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql, 5);
2019
+                $this->debug->mailToAdmin('DB-Fatal-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql, 5);
2020 2020
 
2021 2021
                 throw new DBGoneAwayException($errorMessage);
2022 2022
             }
2023 2023
 
2024
-            $this->debug->mailToAdmin('DB-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
2024
+            $this->debug->mailToAdmin('DB-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
2025 2025
 
2026 2026
             // reconnect
2027 2027
             $RECONNECT_COUNTER++;
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
             return false;
2036 2036
         }
2037 2037
 
2038
-        $this->debug->mailToAdmin('SQL-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
2038
+        $this->debug->mailToAdmin('SQL-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
2039 2039
 
2040 2040
         $force_exception_after_error = null; // auto
2041 2041
         if ($this->in_transaction) {
@@ -2043,7 +2043,7 @@  discard block
 block discarded – undo
2043 2043
         }
2044 2044
         // this query returned an error, we must display it (only for dev) !!!
2045 2045
 
2046
-        $this->debug->displayError($errorMessage . '(' . $errorNumber . ') ' . ' | ' . $sql, $force_exception_after_error);
2046
+        $this->debug->displayError($errorMessage.'('.$errorNumber.') '.' | '.$sql, $force_exception_after_error);
2047 2047
 
2048 2048
         return false;
2049 2049
     }
@@ -2061,12 +2061,12 @@  discard block
 block discarded – undo
2061 2061
             '`',
2062 2062
             '``',
2063 2063
             \trim(
2064
-                (string) $this->escape($str, false),
2064
+                (string)$this->escape($str, false),
2065 2065
                 '`'
2066 2066
             )
2067 2067
         );
2068 2068
 
2069
-        return '`' . $str . '`';
2069
+        return '`'.$str.'`';
2070 2070
     }
2071 2071
 
2072 2072
     /**
@@ -2135,10 +2135,10 @@  discard block
 block discarded – undo
2135 2135
         $values = \implode(',', $data);
2136 2136
 
2137 2137
         if ($databaseName) {
2138
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2138
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2139 2139
         }
2140 2140
 
2141
-        $sql = 'REPLACE INTO ' . $databaseName . $this->quote_string($table) . " (${columns}) VALUES (${values})";
2141
+        $sql = 'REPLACE INTO '.$databaseName.$this->quote_string($table)." (${columns}) VALUES (${values})";
2142 2142
 
2143 2143
         $return = $this->query($sql);
2144 2144
         \assert(\is_int($return) || $return === false);
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
                 }
2238 2238
             } else {
2239 2239
                 $varCleaned = [];
2240
-                foreach ((array) $var as $key => $value) {
2240
+                foreach ((array)$var as $key => $value) {
2241 2241
                     $key = $this->escape($key, false, false, $convert_array);
2242 2242
                     $value = $this->secure($value);
2243 2243
 
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
         $var = $this->escape($var, false, false, null);
2285 2285
 
2286 2286
         if (\is_string($var)) {
2287
-            $var = "'" . \trim($var, "'") . "'";
2287
+            $var = "'".\trim($var, "'")."'";
2288 2288
         }
2289 2289
 
2290 2290
         return $var;
@@ -2322,10 +2322,10 @@  discard block
 block discarded – undo
2322 2322
         }
2323 2323
 
2324 2324
         if ($databaseName) {
2325
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2325
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2326 2326
         }
2327 2327
 
2328
-        $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE (${WHERE})";
2328
+        $sql = 'SELECT * FROM '.$databaseName.$this->quote_string($table)." WHERE (${WHERE})";
2329 2329
 
2330 2330
         $return = $this->query($sql);
2331 2331
         \assert($return instanceof Result || $return === false);
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
     public function setConfigExtra(array $extra_config)
2377 2377
     {
2378 2378
         if (isset($extra_config['session_to_db'])) {
2379
-            $this->session_to_db = (bool) $extra_config['session_to_db'];
2379
+            $this->session_to_db = (bool)$extra_config['session_to_db'];
2380 2380
         }
2381 2381
 
2382 2382
         if (isset($extra_config['doctrine'])) {
@@ -2439,9 +2439,9 @@  discard block
 block discarded – undo
2439 2439
             $return = \mysqli_set_charset($this->mysqli_link, $charset);
2440 2440
 
2441 2441
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2442
-            @\mysqli_query($this->mysqli_link, 'SET CHARACTER SET ' . $charset);
2442
+            @\mysqli_query($this->mysqli_link, 'SET CHARACTER SET '.$charset);
2443 2443
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2444
-            @\mysqli_query($this->mysqli_link, "SET NAMES '" . $charset . "'");
2444
+            @\mysqli_query($this->mysqli_link, "SET NAMES '".$charset."'");
2445 2445
         } elseif ($this->doctrine_connection && $this->isDoctrinePDOConnection()) {
2446 2446
             $doctrineWrappedConnection = $this->getDoctrinePDOConnection();
2447 2447
             if (!$doctrineWrappedConnection instanceof Connection) {
@@ -2449,9 +2449,9 @@  discard block
 block discarded – undo
2449 2449
             }
2450 2450
 
2451 2451
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2452
-            @$doctrineWrappedConnection->exec('SET CHARACTER SET ' . $charset);
2452
+            @$doctrineWrappedConnection->exec('SET CHARACTER SET '.$charset);
2453 2453
             /** @noinspection PhpUsageOfSilenceOperatorInspection */
2454
-            @$doctrineWrappedConnection->exec("SET NAMES '" . $charset . "'");
2454
+            @$doctrineWrappedConnection->exec("SET NAMES '".$charset."'");
2455 2455
 
2456 2456
             $return = true;
2457 2457
         } else {
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
      */
2593 2593
     public function table_exists(string $table): bool
2594 2594
     {
2595
-        $check = $this->query('SELECT 1 FROM ' . $this->quote_string($table));
2595
+        $check = $this->query('SELECT 1 FROM '.$this->quote_string($table));
2596 2596
 
2597 2597
         return $check !== false
2598 2598
                &&
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
             $result = $callback($this);
2624 2624
             if ($result === false) {
2625 2625
                 /** @noinspection ThrowRawExceptionInspection */
2626
-                throw new \Exception('call_user_func [' . \print_r($callback, true) . '] === false');
2626
+                throw new \Exception('call_user_func ['.\print_r($callback, true).'] === false');
2627 2627
             }
2628 2628
 
2629 2629
             return $this->commit();
@@ -2681,10 +2681,10 @@  discard block
 block discarded – undo
2681 2681
         }
2682 2682
 
2683 2683
         if ($databaseName) {
2684
-            $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2684
+            $databaseName = $this->quote_string(\trim($databaseName)).'.';
2685 2685
         }
2686 2686
 
2687
-        $sql = 'UPDATE ' . $databaseName . $this->quote_string($table) . " SET ${SET} WHERE (${WHERE})";
2687
+        $sql = 'UPDATE '.$databaseName.$this->quote_string($table)." SET ${SET} WHERE (${WHERE})";
2688 2688
 
2689 2689
         $return = $this->query($sql);
2690 2690
         \assert(\is_int($return) || $return === false);
Please login to merge, or discard this patch.
src/voku/db/Result.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
     /**
928 928
      * Fetch as object.
929 929
      *
930
-     * @param object|string $class  <p>
930
+     * @param string $class  <p>
931 931
      *                              <strong>string</strong>: create a new object (with optional constructor
932 932
      *                              parameter)<br>
933 933
      *                              <strong>object</strong>: use a object and fill the the data into
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
     /**
1057 1057
      * Fetch as "\Generator" via yield.
1058 1058
      *
1059
-     * @param object|string $class  <p>
1059
+     * @param string $class  <p>
1060 1060
      *                              <strong>string</strong>: create a new object (with optional constructor
1061 1061
      *                              parameter)<br>
1062 1062
      *                              <strong>object</strong>: use a object and fill the the data into
Please login to merge, or discard this 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
     /**
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         }
520 520
 
521 521
         return Arrayy::createFromGeneratorFunction(
522
-            function () {
522
+            function() {
523 523
                 $this->reset();
524 524
 
525 525
                 /** @noinspection PhpAssignmentInConditionInspection */
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 
879 879
         if ($as_array) {
880 880
             return \array_map(
881
-                static function ($object) {
882
-                    return (array) $object;
881
+                static function($object) {
882
+                    return (array)$object;
883 883
                 },
884 884
                 $fields
885 885
             );
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
         }
1047 1047
 
1048 1048
         return \array_map(
1049
-            static function ($values) use ($keys) {
1049
+            static function($values) use ($keys) {
1050 1050
                 return \array_combine($keys, $values);
1051 1051
             },
1052 1052
             $rows
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
                     $fieldTmp->{$metadataTmpKey} = $metadataTmpValue;
1185 1185
                 }
1186 1186
 
1187
-                $typeNativeTmp = 'MYSQL_TYPE_' . $metadataTmp['native_type'];
1187
+                $typeNativeTmp = 'MYSQL_TYPE_'.$metadataTmp['native_type'];
1188 1188
                 $typeTmp = $THIS_CLASS_TMP->getConstant($typeNativeTmp);
1189 1189
                 if ($typeTmp) {
1190 1190
                     $fieldTmp->type = $typeTmp;
@@ -1531,11 +1531,11 @@  discard block
 block discarded – undo
1531 1531
             if (\abs($offset) > $this->num_rows) {
1532 1532
                 $offset = 0;
1533 1533
             } else {
1534
-                $offset = $this->num_rows - (int) \abs($offset);
1534
+                $offset = $this->num_rows - (int)\abs($offset);
1535 1535
             }
1536 1536
         }
1537 1537
 
1538
-        $length = $length !== null ? (int) $length : $this->num_rows;
1538
+        $length = $length !== null ? (int)$length : $this->num_rows;
1539 1539
         $n = 0;
1540 1540
         for ($i = $offset; $i < $this->num_rows && $n < $length; $i++) {
1541 1541
             if ($preserve_keys) {
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/Debug.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         } else {
115 115
 
116 116
             // for testing with dev-address
117
-            $noDev = isset($_GET['noDev']) ? (int) $_GET['noDev'] : 0;
117
+            $noDev = isset($_GET['noDev']) ? (int)$_GET['noDev'] : 0;
118 118
             $remoteIpAddress = $_SERVER['REMOTE_ADDR'] ?? false;
119 119
 
120 120
             if (
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $fileInfo = $this->getFileAndLineFromSql();
164 164
 
165
-        $log = '[' . \date('Y-m-d H:i:s') . ']: SQL-Error: ' . $error . ' | Trace: ' . $fileInfo['path'] . '<br>';
165
+        $log = '['.\date('Y-m-d H:i:s').']: SQL-Error: '.$error.' | Trace: '.$fileInfo['path'].'<br>';
166 166
 
167 167
         $this->logger(['error', $log]);
168 168
 
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 
179 179
             if (\PHP_SAPI === 'cli') {
180 180
                 echo "\n";
181
-                echo 'Error: ' . $error . "\n";
182
-                echo 'Trace: ' . $fileInfo['path'] . "\n";
181
+                echo 'Error: '.$error."\n";
182
+                echo 'Trace: '.$fileInfo['path']."\n";
183 183
                 echo "\n";
184 184
             } else {
185 185
                 echo '
186
-                <div class="OBJ-mysql-box" style="border: ' . $box_border . '; background: ' . $box_bg . '; padding: 10px; margin: 10px;">
186
+                <div class="OBJ-mysql-box" style="border: ' . $box_border.'; background: '.$box_bg.'; padding: 10px; margin: 10px;">
187 187
                   <b style="font-size: 14px;">MYSQL Error:</b>
188 188
                   <code style="display: block;">
189
-                    Error:' . $error . '
189
+                    Error:' . $error.'
190 190
                     <br><br>
191
-                    Trace: ' . $fileInfo['path'] . '
191
+                    Trace: ' . $fileInfo['path'].'
192 192
                   </code>
193 193
                 </div>
194 194
                 ';
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
                 continue;
244 244
             }
245 245
 
246
-            $path .= ($referrer[$key]['class'] ?? $referrer[$key]['file']) . '::' . ($referrer[$key]['function'] ?? '') . ':' . ($referrer[$key - 1]['line'] ?? '') . ' <- ';
246
+            $path .= ($referrer[$key]['class'] ?? $referrer[$key]['file']).'::'.($referrer[$key]['function'] ?? '').':'.($referrer[$key - 1]['line'] ?? '').' <- ';
247 247
         }
248 248
 
249 249
         $return['path'] = $path;
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
                 /** @noinspection PhpUsageOfSilenceOperatorInspection */
324 324
                 $traceStringExtra = @\mysqli_info($tmpLink);
325 325
                 if ($traceStringExtra) {
326
-                    $traceStringExtra = ' | info => ' . $traceStringExtra;
326
+                    $traceStringExtra = ' | info => '.$traceStringExtra;
327 327
                 }
328 328
             }
329 329
 
330
-            $traceStringExtra = ' | results => ' . \print_r($results, true) . $traceStringExtra;
330
+            $traceStringExtra = ' | results => '.\print_r($results, true).$traceStringExtra;
331 331
         }
332 332
 
333 333
         static $SLOW_QUERY_WARNING = null;
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
             $queryStatus = ' ERROR (REPEAT) ';
356 356
         }
357 357
 
358
-        $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";
358
+        $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 359
 
360
-        return $this->logger([$logLevel, $queryLog, 'sql',]);
360
+        return $this->logger([$logLevel, $queryLog, 'sql', ]);
361 361
     }
362 362
 
363 363
     /**
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
             mailToAdmin($subject, $htmlBody, $priority);
427 427
         } else {
428 428
             if ($priority === 3) {
429
-                $this->logger(['debug', $subject . ' | ' . $htmlBody]);
429
+                $this->logger(['debug', $subject.' | '.$htmlBody]);
430 430
             } elseif ($priority > 3) {
431
-                $this->logger(['error', $subject . ' | ' . $htmlBody]);
431
+                $this->logger(['error', $subject.' | '.$htmlBody]);
432 432
             } elseif ($priority < 3) {
433
-                $this->logger(['info', $subject . ' | ' . $htmlBody]);
433
+                $this->logger(['info', $subject.' | '.$htmlBody]);
434 434
             }
435 435
         }
436 436
     }
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      */
441 441
     public function setEchoOnError($echo_on_error)
442 442
     {
443
-        $this->echo_on_error = (bool) $echo_on_error;
443
+        $this->echo_on_error = (bool)$echo_on_error;
444 444
     }
445 445
 
446 446
     /**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function setExitOnError($exit_on_error)
450 450
     {
451
-        $this->exit_on_error = (bool) $exit_on_error;
451
+        $this->exit_on_error = (bool)$exit_on_error;
452 452
     }
453 453
 
454 454
     /**
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      */
457 457
     public function setLoggerClassName($logger_class_name)
458 458
     {
459
-        $this->logger_class_name = (string) $logger_class_name;
459
+        $this->logger_class_name = (string)$logger_class_name;
460 460
     }
461 461
 
462 462
     /**
@@ -464,6 +464,6 @@  discard block
 block discarded – undo
464 464
      */
465 465
     public function setLoggerLevel($logger_level)
466 466
     {
467
-        $this->logger_level = (string) $logger_level;
467
+        $this->logger_level = (string)$logger_level;
468 468
     }
469 469
 }
Please login to merge, or discard this patch.