Completed
Push — master ( 8b9ced...fd9088 )
by Lars
01:59
created
src/voku/db/Debug.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace voku\db;
6 6
 
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
     $this->logger(
140 140
         array(
141 141
             'error',
142
-            '<strong>' . \date(
142
+            '<strong>'.\date(
143 143
                 'd. m. Y G:i:s'
144
-            ) . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . ') (sql-error):</strong> ' . $error . '<br>',
144
+            ).' ('.$fileInfo['file'].' line: '.$fileInfo['line'].') (sql-error):</strong> '.$error.'<br>',
145 145
         )
146 146
     );
147 147
 
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
         $box_bg = $this->css_mysql_box_bg;
154 154
 
155 155
         echo '
156
-        <div class="OBJ-mysql-box" style="border:' . $box_border . '; background:' . $box_bg . '; padding:10px; margin:10px;">
156
+        <div class="OBJ-mysql-box" style="border:' . $box_border.'; background:'.$box_bg.'; padding:10px; margin:10px;">
157 157
           <b style="font-size:14px;">MYSQL Error:</b>
158 158
           <code style="display:block;">
159
-            file / line: ' . $fileInfo['file'] . ' / ' . $fileInfo['line'] . '
160
-            ' . $error . '
159
+            file / line: ' . $fileInfo['file'].' / '.$fileInfo['line'].'
160
+            ' . $error.'
161 161
           </code>
162 162
         </div>
163 163
         ';
@@ -295,21 +295,21 @@  discard block
 block discarded – undo
295 295
     // get extra info
296 296
     $infoExtra = \mysqli_info($this->_db->getLink());
297 297
     if ($infoExtra) {
298
-      $infoExtra = ' | info => ' . $infoExtra;
298
+      $infoExtra = ' | info => '.$infoExtra;
299 299
     }
300 300
 
301 301
     //
302 302
     // logging
303 303
     //
304 304
 
305
-    $info = 'time => ' . \round($duration, 5) . ' | results => ' . (int)$results . $infoExtra . ' | SQL => ' . UTF8::htmlentities($sql);
305
+    $info = 'time => '.\round($duration, 5).' | results => '.(int)$results.$infoExtra.' | SQL => '.UTF8::htmlentities($sql);
306 306
 
307 307
     $fileInfo = $this->getFileAndLineFromSql();
308 308
 
309 309
     return $this->logger(
310 310
         array(
311 311
             $logLevel,
312
-            '<strong>' . \date('d. m. Y G:i:s') . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . '):</strong> ' . $info . '<br>',
312
+            '<strong>'.\date('d. m. Y G:i:s').' ('.$fileInfo['file'].' line: '.$fileInfo['line'].'):</strong> '.$info.'<br>',
313 313
             'sql',
314 314
         )
315 315
     );
@@ -375,21 +375,21 @@  discard block
 block discarded – undo
375 375
         $this->logger(
376 376
             array(
377 377
                 'debug',
378
-                $subject . ' | ' . $htmlBody,
378
+                $subject.' | '.$htmlBody,
379 379
             )
380 380
         );
381 381
       } elseif ($priority > 3) {
382 382
         $this->logger(
383 383
             array(
384 384
                 'error',
385
-                $subject . ' | ' . $htmlBody,
385
+                $subject.' | '.$htmlBody,
386 386
             )
387 387
         );
388 388
       } elseif ($priority < 3) {
389 389
         $this->logger(
390 390
             array(
391 391
                 'info',
392
-                $subject . ' | ' . $htmlBody,
392
+                $subject.' | '.$htmlBody,
393 393
             )
394 394
         );
395 395
       }
Please login to merge, or discard this patch.
src/voku/db/DB.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace voku\db;
6 6
 
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
         }
437 437
 
438 438
         if ($_connector === 'NOT IN' || $_connector === 'IN') {
439
-          $_value = '(' . \implode(',', $_value) . ')';
439
+          $_value = '('.\implode(',', $_value).')';
440 440
         } elseif ($_connector === 'NOT BETWEEN' || $_connector === 'BETWEEN') {
441
-          $_value = '(' . \implode(' AND ', $_value) . ')';
441
+          $_value = '('.\implode(' AND ', $_value).')';
442 442
         }
443 443
 
444 444
       } else {
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
           $valueInner = "''";
488 488
         }
489 489
 
490
-        $sql .= ' ' . $_glueHelperInner . ' ' . $quoteString . ' ' . $_connector . ' ' . $valueInner . " \n";
490
+        $sql .= ' '.$_glueHelperInner.' '.$quoteString.' '.$_connector.' '.$valueInner." \n";
491 491
         $tmpCounter++;
492 492
       }
493 493
 
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
       );
691 691
 
692 692
     } catch (\Exception $e) {
693
-      $error = 'Error connecting to mysql server: ' . $e->getMessage();
693
+      $error = 'Error connecting to mysql server: '.$e->getMessage();
694 694
       $this->_debug->displayError($error, true);
695 695
       throw new DBConnectException($error, 100, $e);
696 696
     }
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
     $errno = mysqli_connect_errno();
700 700
     if (!$this->connected || $errno) {
701
-      $error = 'Error connecting to mysql server: ' . \mysqli_connect_error() . ' (' . $errno . ')';
701
+      $error = 'Error connecting to mysql server: '.\mysqli_connect_error().' ('.$errno.')';
702 702
       $this->_debug->displayError($error, true);
703 703
       throw new DBConnectException($error, 101);
704 704
     }
@@ -739,10 +739,10 @@  discard block
 block discarded – undo
739 739
     }
740 740
 
741 741
     if ($databaseName) {
742
-      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
742
+      $databaseName = $this->quote_string(\trim($databaseName)).'.';
743 743
     }
744 744
 
745
-    $sql = 'DELETE FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
745
+    $sql = 'DELETE FROM '.$databaseName.$this->quote_string($table)." WHERE ($WHERE);";
746 746
 
747 747
     return $this->query($sql);
748 748
   }
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
         $nameTmp = \substr($name, 1);
813 813
       }
814 814
 
815
-      $parseKeyInner = $nameTmp . '-' . $parseKey;
816
-      $sql = \str_replace(':' . $nameTmp, $parseKeyInner, $sql);
815
+      $parseKeyInner = $nameTmp.'-'.$parseKey;
816
+      $sql = \str_replace(':'.$nameTmp, $parseKeyInner, $sql);
817 817
     }
818 818
 
819 819
     foreach ($params as $name => $value) {
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
         $nameTmp = \substr($name, 1);
823 823
       }
824 824
 
825
-      $parseKeyInner = $nameTmp . '-' . $parseKey;
825
+      $parseKeyInner = $nameTmp.'-'.$parseKey;
826 826
       $sqlBefore = $sql;
827 827
       $secureParamValue = $this->secure($params[$name]);
828 828
 
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 
999 999
     if ($useCache === true) {
1000 1000
       $cache = new Cache(null, null, false, $useCache);
1001
-      $cacheKey = 'sql-' . \md5($query);
1001
+      $cacheKey = 'sql-'.\md5($query);
1002 1002
 
1003 1003
       if (
1004 1004
           $cache->getCacheIsReady() === true
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
     static $firstInstance = null;
1109 1109
 
1110 1110
     if (
1111
-        $hostname . $username . $password . $database . $port . $charset == '3306utf8'
1111
+        $hostname.$username.$password.$database.$port.$charset == '3306utf8'
1112 1112
         &&
1113 1113
         null !== $firstInstance
1114 1114
     ) {
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     $extra_config_string = '';
1119 1119
     if (\is_array($extra_config) === true) {
1120 1120
       foreach ($extra_config as $extra_config_key => $extra_config_value) {
1121
-        $extra_config_string .= $extra_config_key . (string)$extra_config_value;
1121
+        $extra_config_string .= $extra_config_key.(string)$extra_config_value;
1122 1122
       }
1123 1123
     } else {
1124 1124
       // only for backward compatibility
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
     }
1127 1127
 
1128 1128
     $connection = \md5(
1129
-        $hostname . $username . $password . $database . $port . $charset . (int)$exit_on_error . (int)$echo_on_error . $logger_class_name . $logger_level . $extra_config_string
1129
+        $hostname.$username.$password.$database.$port.$charset.(int)$exit_on_error.(int)$echo_on_error.$logger_class_name.$logger_level.$extra_config_string
1130 1130
     );
1131 1131
 
1132 1132
     if (!isset($instance[$connection])) {
@@ -1213,10 +1213,10 @@  discard block
 block discarded – undo
1213 1213
     $SET = $this->_parseArrayPair($data);
1214 1214
 
1215 1215
     if ($databaseName) {
1216
-      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1216
+      $databaseName = $this->quote_string(\trim($databaseName)).'.';
1217 1217
     }
1218 1218
 
1219
-    $sql = 'INSERT INTO ' . $databaseName . $this->quote_string($table) . " SET $SET;";
1219
+    $sql = 'INSERT INTO '.$databaseName.$this->quote_string($table)." SET $SET;";
1220 1220
 
1221 1221
     return $this->query($sql);
1222 1222
   }
@@ -1527,11 +1527,11 @@  discard block
 block discarded – undo
1527 1527
 
1528 1528
       // exit if we have more then 3 "DB server has gone away"-errors
1529 1529
       if ($RECONNECT_COUNTER > 3) {
1530
-        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql, 5);
1530
+        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql, 5);
1531 1531
         throw new DBGoneAwayException($errorMessage);
1532 1532
       }
1533 1533
 
1534
-      $this->_debug->mailToAdmin('DB-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
1534
+      $this->_debug->mailToAdmin('DB-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
1535 1535
 
1536 1536
       // reconnect
1537 1537
       $RECONNECT_COUNTER++;
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
       return false;
1546 1546
     }
1547 1547
 
1548
-    $this->_debug->mailToAdmin('SQL-Error', $errorMessage . '(' . $errorNumber . ') ' . ":\n<br />" . $sql);
1548
+    $this->_debug->mailToAdmin('SQL-Error', $errorMessage.'('.$errorNumber.') '.":\n<br />".$sql);
1549 1549
 
1550 1550
     $force_exception_after_error = null; // auto
1551 1551
     if ($this->_in_transaction === true) {
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
     }
1554 1554
     // this query returned an error, we must display it (only for dev) !!!
1555 1555
 
1556
-    $this->_debug->displayError($errorMessage . '(' . $errorNumber . ') ' . ' | ' . $sql, $force_exception_after_error);
1556
+    $this->_debug->displayError($errorMessage.'('.$errorNumber.') '.' | '.$sql, $force_exception_after_error);
1557 1557
 
1558 1558
     return false;
1559 1559
   }
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
         )
1577 1577
     );
1578 1578
 
1579
-    return '`' . $str . '`';
1579
+    return '`'.$str.'`';
1580 1580
   }
1581 1581
 
1582 1582
   /**
@@ -1647,10 +1647,10 @@  discard block
 block discarded – undo
1647 1647
     $values = \implode(',', $data);
1648 1648
 
1649 1649
     if ($databaseName) {
1650
-      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1650
+      $databaseName = $this->quote_string(\trim($databaseName)).'.';
1651 1651
     }
1652 1652
 
1653
-    $sql = 'REPLACE INTO ' . $databaseName . $this->quote_string($table) . " ($columns) VALUES ($values);";
1653
+    $sql = 'REPLACE INTO '.$databaseName.$this->quote_string($table)." ($columns) VALUES ($values);";
1654 1654
 
1655 1655
     return $this->query($sql);
1656 1656
   }
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
     $var = $this->escape($var, false, false, null);
1749 1749
 
1750 1750
     if (\is_string($var)) {
1751
-      $var = "'" . \trim($var, "'") . "'";
1751
+      $var = "'".\trim($var, "'")."'";
1752 1752
     }
1753 1753
 
1754 1754
     return $var;
@@ -1785,10 +1785,10 @@  discard block
 block discarded – undo
1785 1785
     }
1786 1786
 
1787 1787
     if ($databaseName) {
1788
-      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
1788
+      $databaseName = $this->quote_string(\trim($databaseName)).'.';
1789 1789
     }
1790 1790
 
1791
-    $sql = 'SELECT * FROM ' . $databaseName . $this->quote_string($table) . " WHERE ($WHERE);";
1791
+    $sql = 'SELECT * FROM '.$databaseName.$this->quote_string($table)." WHERE ($WHERE);";
1792 1792
 
1793 1793
     return $this->query($sql);
1794 1794
   }
@@ -1830,9 +1830,9 @@  discard block
 block discarded – undo
1830 1830
 
1831 1831
     $return = mysqli_set_charset($this->link, $charset);
1832 1832
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
1833
-    @\mysqli_query($this->link, 'SET CHARACTER SET ' . $charset);
1833
+    @\mysqli_query($this->link, 'SET CHARACTER SET '.$charset);
1834 1834
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
1835
-    @\mysqli_query($this->link, "SET NAMES '" . $charset . "'");
1835
+    @\mysqli_query($this->link, "SET NAMES '".$charset."'");
1836 1836
 
1837 1837
     return $return;
1838 1838
   }
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
       $result = $callback($this);
1967 1967
       if ($result === false) {
1968 1968
         /** @noinspection ThrowRawExceptionInspection */
1969
-        throw new \Exception('call_user_func [' . $callback . '] === false');
1969
+        throw new \Exception('call_user_func ['.$callback.'] === false');
1970 1970
       }
1971 1971
 
1972 1972
       return $this->commit();
@@ -2019,10 +2019,10 @@  discard block
 block discarded – undo
2019 2019
     }
2020 2020
 
2021 2021
     if ($databaseName) {
2022
-      $databaseName = $this->quote_string(\trim($databaseName)) . '.';
2022
+      $databaseName = $this->quote_string(\trim($databaseName)).'.';
2023 2023
     }
2024 2024
 
2025
-    $sql = 'UPDATE ' . $databaseName . $this->quote_string($table) . " SET $SET WHERE ($WHERE);";
2025
+    $sql = 'UPDATE '.$databaseName.$this->quote_string($table)." SET $SET WHERE ($WHERE);";
2026 2026
 
2027 2027
     return $this->query($sql);
2028 2028
   }
@@ -2036,7 +2036,7 @@  discard block
 block discarded – undo
2036 2036
    */
2037 2037
   public function table_exists(string $table): bool
2038 2038
   {
2039
-    $check = $this->query('SELECT 1 FROM ' . $this->quote_string($table));
2039
+    $check = $this->query('SELECT 1 FROM '.$this->quote_string($table));
2040 2040
 
2041 2041
     return $check !== false
2042 2042
            &&
Please login to merge, or discard this patch.
src/voku/db/ActiveRecord.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace voku\db;
6 6
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
     $value = $this->_filterParam($this->dirty);
584 584
     $this->insert = new ActiveRecordExpressions(
585 585
         array(
586
-            'operator' => 'INSERT INTO ' . $this->table,
586
+            'operator' => 'INSERT INTO '.$this->table,
587 587
             'target'   => new ActiveRecordExpressionsWrap(array('target' => \array_keys($this->dirty))),
588 588
         )
589 589
     );
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
    * @param int          $i <p>The index of $n in $sql array.</p>
787 787
    * @param ActiveRecord $o <p>The reference to $this.</p>
788 788
    */
789
-  private function _buildSqlCallback(string &$n, $i, self $o)
789
+  private function _buildSqlCallback(string & $n, $i, self $o)
790 790
   {
791 791
     if (
792 792
         'select' === $n
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
         null === $o->{$n}
795 795
     ) {
796 796
 
797
-      $n = \strtoupper($n) . ' ' . $o->table . '.*';
797
+      $n = \strtoupper($n).' '.$o->table.'.*';
798 798
 
799 799
     } elseif (
800 800
         (
@@ -806,15 +806,15 @@  discard block
 block discarded – undo
806 806
         null === $o->{$n}
807 807
     ) {
808 808
 
809
-      $n = \strtoupper($n) . ' ' . $o->table;
809
+      $n = \strtoupper($n).' '.$o->table;
810 810
 
811 811
     } elseif ('delete' === $n) {
812 812
 
813
-      $n = \strtoupper($n) . ' ';
813
+      $n = \strtoupper($n).' ';
814 814
 
815 815
     } else {
816 816
 
817
-      $n = (null !== $o->{$n}) ? $o->{$n} . ' ' : '';
817
+      $n = (null !== $o->{$n}) ? $o->{$n}.' ' : '';
818 818
 
819 819
     }
820 820
   }
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
   {
928 928
     if (\is_array($value)) {
929 929
       foreach ($value as $key => $val) {
930
-        $this->params[$value[$key] = self::PREFIX . ++self::$count] = $val;
930
+        $this->params[$value[$key] = self::PREFIX.++self::$count] = $val;
931 931
       }
932 932
     } elseif (\is_string($value)) {
933
-      $this->params[$ph = self::PREFIX . ++self::$count] = $value;
933
+      $this->params[$ph = self::PREFIX.++self::$count] = $value;
934 934
       $value = $ph;
935 935
     }
936 936
 
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
     $value = $this->_filterParam($value);
952 952
     $exp = new ActiveRecordExpressions(
953 953
         array(
954
-            'source'   => ('where' == $name ? $this->table . '.' : '') . $field,
954
+            'source'   => ('where' == $name ? $this->table.'.' : '').$field,
955 955
             'operator' => $operator,
956 956
             'target'   => \is_array($value)
957 957
                 ? new ActiveRecordExpressionsWrap(
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
     $this->join = new ActiveRecordExpressions(
985 985
         array(
986 986
             'source'   => $this->join ?: '',
987
-            'operator' => $type . ' JOIN',
987
+            'operator' => $type.' JOIN',
988 988
             'target'   => new ActiveRecordExpressions(
989 989
                 array('source' => $table, 'operator' => 'ON', 'target' => $on)
990 990
             ),
Please login to merge, or discard this patch.