Test Failed
Branch trunk (412648)
by SuperNova.WS
03:40
created
classes/BBCodeParser.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -14,6 +14,9 @@
 block discarded – undo
14 14
     $this->design = $gc->design;
15 15
   }
16 16
 
17
+  /**
18
+   * @param integer $authorAccessLevel
19
+   */
17 20
   protected function applyElements($elements, $text, $authorAccessLevel = AUTH_LEVEL_REGISTERED) {
18 21
     foreach ($elements as $auth_level => $element) {
19 22
       if ($auth_level > $authorAccessLevel) {
Please login to merge, or discard this patch.
classes/classSupernova.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
    *   <p>null - транзакция НЕ должна быть запущена</p>
310 310
    *   <p>true - транзакция должна быть запущена - для совместимости с $for_update</p>
311 311
    *   <p>false - всё равно - для совместимости с $for_update</p>
312
-   * @return bool Текущий статус транзакции
312
+   * @return null|boolean Текущий статус транзакции
313 313
    */
314 314
   public static function db_transaction_check($status = null) {
315 315
     $error_msg = false;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
   /**
377 377
    * Блокирует указанные таблицу/список таблиц
378 378
    *
379
-   * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
379
+   * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
380 380
    * <p>string - название таблицы для блокировки</p>
381 381
    * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p>
382 382
    */
Please login to merge, or discard this patch.
Braces   +78 added lines, -50 removed lines patch added patch discarded remove patch
@@ -188,14 +188,18 @@  discard block
 block discarded – undo
188 188
   // Перепаковывает массив на заданную глубину, убирая поля с null
189 189
   public static function array_repack(&$array, $level = 0) {
190 190
     // TODO $lock_table не нужна тут
191
-    if(!is_array($array)) return;
191
+    if(!is_array($array)) {
192
+      return;
193
+    }
192 194
 
193 195
     foreach($array as $key => &$value) {
194 196
       if($value === null) {
195 197
         unset($array[$key]);
196 198
       } elseif($level > 0 && is_array($value)) {
197 199
         static::array_repack($value, $level - 1);
198
-        if(empty($value)) unset($array[$key]);
200
+        if(empty($value)) {
201
+          unset($array[$key]);
202
+        }
199 203
       }
200 204
     }
201 205
   }
@@ -204,7 +208,9 @@  discard block
 block discarded – undo
204 208
   // TODO Вынести в отдельный объект
205 209
   public static function cache_repack($location_type, $record_id = 0) {
206 210
     // Если есть $user_id - проверяем, а надо ли перепаковывать?
207
-    if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return;
211
+    if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) {
212
+      return;
213
+    }
208 214
 
209 215
     static::array_repack(static::$data[$location_type]);
210 216
     static::array_repack(static::$locator[$location_type], 3); // TODO У каждого типа локации - своя глубина!!!! Но можно и глубже ???
@@ -249,7 +255,9 @@  discard block
 block discarded – undo
249 255
   */
250 256
   public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) {
251 257
     // нет идентификатора - выход
252
-    if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) return;
258
+    if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) {
259
+      return;
260
+    }
253 261
 
254 262
     $in_transaction = static::db_transaction_check(false);
255 263
     if(
@@ -283,8 +291,9 @@  discard block
 block discarded – undo
283 291
     return static::$locks[$location_type][$record_id] = true; // Не всегда - от результата
284 292
   }
285 293
   public static function cache_lock_unset($location_type, $record_id) {
286
-    if(isset(static::$locks[$location_type][$record_id]))
287
-      unset(static::$locks[$location_type][$record_id]);
294
+    if(isset(static::$locks[$location_type][$record_id])) {
295
+          unset(static::$locks[$location_type][$record_id]);
296
+    }
288 297
     return true; // Не всегда - от результата
289 298
   }
290 299
   public static function cache_lock_unset_all() {
@@ -454,8 +463,9 @@  discard block
 block discarded – undo
454 463
 
455 464
           while($row = db_fetch($query)) {
456 465
             // Исключаем из списка родительских ИД уже заблокированные записи
457
-            if(!static::cache_lock_get($owner_location_type, $row['parent_id']))
458
-              $parent_id_list[$row['parent_id']] = $row['parent_id'];
466
+            if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) {
467
+                          $parent_id_list[$row['parent_id']] = $row['parent_id'];
468
+            }
459 469
           }
460 470
 
461 471
           // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы
@@ -483,7 +493,9 @@  discard block
 block discarded – undo
483 493
       if(is_array($query_cache)) {
484 494
         foreach($query_cache as $key => $value) {
485 495
           $result[$key] = $value;
486
-          if($fetch) break;
496
+          if($fetch) {
497
+            break;
498
+          }
487 499
         }
488 500
       }
489 501
       return $fetch ? (is_array($result) ? reset($result) : false) : $result;
@@ -491,12 +503,15 @@  discard block
 block discarded – undo
491 503
   }
492 504
 
493 505
   public static function db_upd_record_by_id($location_type, $record_id, $set) {
494
-    if(!($record_id = idval($record_id)) || !($set = trim($set))) return false;
506
+    if(!($record_id = idval($record_id)) || !($set = trim($set))) {
507
+      return false;
508
+    }
495 509
 
496 510
     $location_info = &static::$location_info[$location_type];
497 511
     $id_field = $location_info[P_ID];
498 512
     $table_name = $location_info[P_TABLE_NAME];
499
-    if($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
513
+    if($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) {
514
+      // TODO Как-то вернуть может быть LIMIT 1 ?
500 515
     {
501 516
       if(static::$db->db_affected_rows()) {
502 517
         // Обновляем данные только если ряд был затронут
@@ -504,6 +519,7 @@  discard block
 block discarded – undo
504 519
 
505 520
         // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее
506 521
         static::$data[$location_type][$record_id] = null;
522
+    }
507 523
         // Вытаскиваем обновленную запись
508 524
         static::db_get_record_by_id($location_type, $record_id);
509 525
         static::cache_clear($location_type, false); // Мягкий сброс - только $queries
@@ -513,7 +529,9 @@  discard block
 block discarded – undo
513 529
     return $result;
514 530
   }
515 531
   public static function db_upd_record_list($location_type, $condition, $set) {
516
-    if(!($set = trim($set))) return false;
532
+    if(!($set = trim($set))) {
533
+      return false;
534
+    }
517 535
 
518 536
     $condition = trim($condition);
519 537
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
@@ -534,9 +552,11 @@  discard block
 block discarded – undo
534 552
     $set = trim($set);
535 553
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
536 554
     if($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
537
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
555
+      if(static::$db->db_affected_rows()) {
556
+        // Обновляем данные только если ряд был затронут
538 557
       {
539 558
         $record_id = db_insert_id();
559
+      }
540 560
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
541 561
         $result = static::db_get_record_by_id($location_type, $record_id);
542 562
         // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего
@@ -548,37 +568,43 @@  discard block
 block discarded – undo
548 568
     return $result;
549 569
   }
550 570
 
551
-  public static function db_del_record_by_id($location_type, $safe_record_id)
552
-  {
553
-    if(!($safe_record_id = idval($safe_record_id))) return false;
571
+  public static function db_del_record_by_id($location_type, $safe_record_id) {
572
+    if(!($safe_record_id = idval($safe_record_id))) {
573
+      return false;
574
+    }
554 575
 
555 576
     $location_info = &static::$location_info[$location_type];
556 577
     $id_field = $location_info[P_ID];
557 578
     $table_name = $location_info[P_TABLE_NAME];
558 579
     if($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}"))
559 580
     {
560
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
581
+      if(static::$db->db_affected_rows()) {
582
+        // Обновляем данные только если ряд был затронут
561 583
       {
562 584
         static::cache_unset($location_type, $safe_record_id);
563 585
       }
586
+      }
564 587
     }
565 588
 
566 589
     return $result;
567 590
   }
568
-  public static function db_del_record_list($location_type, $condition)
569
-  {
570
-    if(!($condition = trim($condition))) return false;
591
+  public static function db_del_record_list($location_type, $condition) {
592
+    if(!($condition = trim($condition))) {
593
+      return false;
594
+    }
571 595
 
572 596
     $location_info = &static::$location_info[$location_type];
573 597
     $table_name = $location_info[P_TABLE_NAME];
574 598
 
575 599
     if($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}"))
576 600
     {
577
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
601
+      if(static::$db->db_affected_rows()) {
602
+        // Обновляем данные только если ряд был затронут
578 603
       {
579 604
         // Обнуление кэша, потому что непонятно, что поменялось
580 605
         static::cache_clear($location_type);
581 606
       }
607
+      }
582 608
     }
583 609
 
584 610
     return $result;
@@ -604,8 +630,7 @@  discard block
 block discarded – undo
604 630
    *    <p>false - Нет записи с указанным ID и $player</p>
605 631
    *    <p>array - запись типа $user</p>
606 632
    */
607
-  public static function db_get_user_by_id($user_id_unsafe, $for_update = false, $fields = '*', $player = null)
608
-  {
633
+  public static function db_get_user_by_id($user_id_unsafe, $for_update = false, $fields = '*', $player = null) {
609 634
     $user = static::db_get_record_by_id(LOC_USER, $user_id_unsafe, $for_update, $fields);
610 635
 
611 636
     return (is_array($user) &&
@@ -617,14 +642,15 @@  discard block
 block discarded – undo
617 642
       ($player === false && $user['user_as_ally'])
618 643
     )) ? $user : false;
619 644
   }
620
-  public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false)
621
-  {
645
+  public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) {
622 646
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
623
-    if(!($username_unsafe = trim($username_unsafe))) return false;
647
+    if(!($username_unsafe = trim($username_unsafe))) {
648
+      return false;
649
+    }
624 650
 
625 651
     $user = null;
626
-    if(is_array(static::$data[LOC_USER]))
627
-    foreach(static::$data[LOC_USER] as $user_id => $user_data)
652
+    if(is_array(static::$data[LOC_USER])) {
653
+        foreach(static::$data[LOC_USER] as $user_id => $user_data)
628 654
     {
629 655
       if(is_array($user_data) && isset($user_data['username']))
630 656
       {
@@ -634,6 +660,7 @@  discard block
 block discarded – undo
634 660
         {
635 661
           // $user_as_ally = intval($user_data['user_as_ally']);
636 662
           $user_as_ally = idval($user_data['user_as_ally']);
663
+    }
637 664
           if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally))
638 665
           {
639 666
             $user = $user_data;
@@ -659,7 +686,9 @@  discard block
 block discarded – undo
659 686
   }
660 687
   // UNUSED
661 688
   public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') {
662
-    if(!($email_unsafe = strtolower(trim($email_unsafe)))) return false;
689
+    if(!($email_unsafe = strtolower(trim($email_unsafe)))) {
690
+      return false;
691
+    }
663 692
 
664 693
     $user = null;
665 694
     if(is_array(static::$data[LOC_USER])) {
@@ -718,15 +747,13 @@  discard block
 block discarded – undo
718 747
 
719 748
 
720 749
 
721
-  public static function db_unit_time_restrictions($date = SN_TIME_NOW)
722
-  {
750
+  public static function db_unit_time_restrictions($date = SN_TIME_NOW) {
723 751
     $date = is_numeric($date) ? "FROM_UNIXTIME({$date})" : "'{$date}'";
724 752
     return
725 753
       "(unit_time_start IS NULL OR unit_time_start <= {$date}) AND
726 754
     (unit_time_finish IS NULL OR unit_time_finish = '1970-01-01 03:00:00' OR unit_time_finish >= {$date})";
727 755
   }
728
-  public static function db_get_unit_by_id($unit_id, $for_update = false, $fields = '*')
729
-  {
756
+  public static function db_get_unit_by_id($unit_id, $for_update = false, $fields = '*') {
730 757
     // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id]
731 758
     $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields);
732 759
     if(is_array($unit))
@@ -737,9 +764,10 @@  discard block
 block discarded – undo
737 764
     return $unit;
738 765
   }
739 766
 
740
-  public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id)
741
-  {
742
-    if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false;
767
+  public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) {
768
+    if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) {
769
+      return false;
770
+    }
743 771
 
744 772
     $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id];
745 773
     if(!isset($query_cache))
@@ -764,8 +792,7 @@  discard block
 block discarded – undo
764 792
 
765 793
     return $result;
766 794
   }
767
-  public static function db_get_unit_by_location($user_id = 0, $location_type, $location_id, $unit_snid = 0, $for_update = false, $fields = '*')
768
-  {
795
+  public static function db_get_unit_by_location($user_id = 0, $location_type, $location_id, $unit_snid = 0, $for_update = false, $fields = '*') {
769 796
     static::db_get_unit_list_by_location($user_id, $location_type, $location_id);
770 797
 
771 798
     return $unit_snid ? static::$locator[LOC_UNIT][$location_type][$location_id][$unit_snid] : static::$locator[LOC_UNIT][$location_type][$location_id];
@@ -793,8 +820,7 @@  discard block
 block discarded – undo
793 820
    * TODO Переформатировать вывод данных, что бы можно было возвращать данные по всем планетам и юзерам в одном запросе: добавить подмассивы 'que', 'planets', 'players'
794 821
    *
795 822
    */
796
-  public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false)
797
-  {
823
+  public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false) {
798 824
     if(!$user_id)
799 825
     {
800 826
       pdump(debug_backtrace());
@@ -805,15 +831,18 @@  discard block
 block discarded – undo
805 831
 
806 832
     $query = array();
807 833
 
808
-    if($user_id = idval($user_id))
809
-      $query[] = "`que_player_id` = {$user_id}";
834
+    if($user_id = idval($user_id)) {
835
+          $query[] = "`que_player_id` = {$user_id}";
836
+    }
810 837
 
811
-    if($que_type == QUE_RESEARCH || $planet_id === null)
812
-      $query[] = "`que_planet_id` IS NULL";
813
-    elseif($planet_id)
814
-      $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
815
-    if($que_type)
816
-      $query[] = "`que_type` = {$que_type}";
838
+    if($que_type == QUE_RESEARCH || $planet_id === null) {
839
+          $query[] = "`que_planet_id` IS NULL";
840
+    } elseif($planet_id) {
841
+          $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
842
+    }
843
+    if($que_type) {
844
+          $query[] = "`que_type` = {$que_type}";
845
+    }
817 846
 
818 847
     $ques['items'] = static::db_get_record_list(LOC_QUE, implode(' AND ', $query));
819 848
 
@@ -861,8 +890,7 @@  discard block
 block discarded – undo
861 890
 
862 891
 
863 892
 
864
-  public static function db_changeset_revert()
865
-  {
893
+  public static function db_changeset_revert() {
866 894
     // TODO Для этапа 1 - достаточно чистить только те таблицы, что были затронуты
867 895
     // Для этапа 2 - чистить только записи
868 896
     // Для этапа 3 - возвращать всё
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
    * @return classSupernova
200 200
    */
201 201
   public static function sn() {
202
-    if(!isset(self::$_sn)) {
202
+    if (!isset(self::$_sn)) {
203 203
       self::$_sn = new self();
204 204
     }
205 205
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
 
214 214
   public static function log_file($message, $spaces = 0) {
215
-    if(self::$debug) {
215
+    if (self::$debug) {
216 216
       self::$debug->log_file($message, $spaces);
217 217
     }
218 218
   }
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
   // Перепаковывает массив на заданную глубину, убирая поля с null
221 221
   public static function array_repack(&$array, $level = 0) {
222 222
     // TODO $lock_table не нужна тут
223
-    if(!is_array($array)) return;
223
+    if (!is_array($array)) return;
224 224
 
225
-    foreach($array as $key => &$value) {
226
-      if($value === null) {
225
+    foreach ($array as $key => &$value) {
226
+      if ($value === null) {
227 227
         unset($array[$key]);
228
-      } elseif($level > 0 && is_array($value)) {
228
+      } elseif ($level > 0 && is_array($value)) {
229 229
         static::array_repack($value, $level - 1);
230
-        if(empty($value)) unset($array[$key]);
230
+        if (empty($value)) unset($array[$key]);
231 231
       }
232 232
     }
233 233
   }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
   // TODO Вынести в отдельный объект
237 237
   public static function cache_repack($location_type, $record_id = 0) {
238 238
     // Если есть $user_id - проверяем, а надо ли перепаковывать?
239
-    if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return;
239
+    if ($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return;
240 240
 
241 241
     static::array_repack(static::$data[$location_type]);
242 242
     static::array_repack(static::$locator[$location_type], 3); // TODO У каждого типа локации - своя глубина!!!! Но можно и глубже ???
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
   }
245 245
   public static function cache_clear($location_type, $hard = true) {
246 246
     //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />");
247
-    if($hard && !empty(static::$data[$location_type])) {
247
+    if ($hard && !empty(static::$data[$location_type])) {
248 248
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
249
-      array_walk(static::$data[$location_type], function(&$item){$item = null;});
249
+      array_walk(static::$data[$location_type], function(&$item) {$item = null; });
250 250
     }
251 251
     static::$locator[$location_type] = array();
252 252
     static::$queries[$location_type] = array();
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
   }
255 255
   public static function cache_clear_all($hard = true) {
256 256
     //print('<br />CACHE CLEAR ALL<br />');
257
-    if($hard) {
257
+    if ($hard) {
258 258
       static::$data = array();
259 259
       static::cache_lock_unset_all();
260 260
     }
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
   */
282 282
   public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) {
283 283
     // нет идентификатора - выход
284
-    if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) return;
284
+    if (!($record_id = $record[static::$location_info[$location_type][P_ID]])) return;
285 285
 
286 286
     $in_transaction = static::db_transaction_check(false);
287
-    if(
287
+    if (
288 288
       $force_overwrite
289 289
       ||
290 290
       // Не заменяются заблокированные записи во время транзакции
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
       !static::cache_isset($location_type, $record_id)
295 295
     ) {
296 296
       static::$data[$location_type][$record_id] = $record;
297
-      if($in_transaction && !$skip_lock) {
297
+      if ($in_transaction && !$skip_lock) {
298 298
         static::cache_lock_set($location_type, $record_id);
299 299
       }
300 300
     }
301 301
   }
302 302
   public static function cache_unset($cache_id, $safe_record_id) {
303 303
     // $record_id должен быть проверен заранее !
304
-    if(isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
304
+    if (isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
305 305
       // Выставляем запись в null
306 306
       static::$data[$cache_id][$safe_record_id] = null;
307 307
       // Очищаем кэш мягко - что бы удалить очистить связанные данные - кэш локаций и кэш запоросов и всё, что потребуется впредь
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     return static::$locks[$location_type][$record_id] = true; // Не всегда - от результата
316 316
   }
317 317
   public static function cache_lock_unset($location_type, $record_id) {
318
-    if(isset(static::$locks[$location_type][$record_id]))
318
+    if (isset(static::$locks[$location_type][$record_id]))
319 319
       unset(static::$locks[$location_type][$record_id]);
320 320
     return true; // Не всегда - от результата
321 321
   }
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
    */
346 346
   public static function db_transaction_check($status = null) {
347 347
     $error_msg = false;
348
-    if($status && !static::$db_in_transaction) {
348
+    if ($status && !static::$db_in_transaction) {
349 349
       $error_msg = 'No transaction started for current operation';
350
-    } elseif($status === null && static::$db_in_transaction) {
350
+    } elseif ($status === null && static::$db_in_transaction) {
351 351
       $error_msg = 'Transaction is already started';
352 352
     }
353 353
 
354
-    if($error_msg) {
354
+    if ($error_msg) {
355 355
       // TODO - Убрать позже
356 356
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
357 357
       $backtrace = debug_backtrace();
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     static::$transaction_id++;
373 373
     doquery('START TRANSACTION');
374 374
 
375
-    if($config->db_manual_lock_enabled) {
375
+    if ($config->db_manual_lock_enabled) {
376 376
       $config->db_loadItem('var_db_manually_locked');
377 377
       $config->db_saveItem('var_db_manually_locked', SN_TIME_SQL);
378 378
     }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
    */
415 415
   public static function db_lock_tables($tables) {
416 416
     $tables = is_array($tables) ? $tables : array($tables => '');
417
-    foreach($tables as $table_name => $condition) {
417
+    foreach ($tables as $table_name => $condition) {
418 418
       self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
419 419
     }
420 420
   }
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
   public static function db_get_record_list($location_type, $filter = '', $fetch = false, $no_return = false) {
464 464
     $query_cache = &static::$queries[$location_type][$filter];
465 465
 
466
-    if(!isset($query_cache) || $query_cache === null) {
466
+    if (!isset($query_cache) || $query_cache === null) {
467 467
       $location_info = &static::$location_info[$location_type];
468 468
       $id_field = $location_info[P_ID];
469 469
       $query_cache = array();
470 470
 
471
-      if(static::db_transaction_check(false)) {
471
+      if (static::db_transaction_check(false)) {
472 472
         // Проходим по всем родителям данной записи
473
-        foreach($location_info[P_OWNER_INFO] as $owner_data) {
473
+        foreach ($location_info[P_OWNER_INFO] as $owner_data) {
474 474
           $owner_location_type = $owner_data[P_LOCATION];
475 475
           $parent_id_list = array();
476 476
           // Выбираем родителей данного типа и соответствующие ИД текущего типа
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
             true
485 485
           );
486 486
 
487
-          while($row = db_fetch($query)) {
487
+          while ($row = db_fetch($query)) {
488 488
             // Исключаем из списка родительских ИД уже заблокированные записи
489
-            if(!static::cache_lock_get($owner_location_type, $row['parent_id']))
489
+            if (!static::cache_lock_get($owner_location_type, $row['parent_id']))
490 490
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
491 491
           }
492 492
 
493 493
           // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы
494
-          if($indexes_str = implode(',', $parent_id_list)) {
494
+          if ($indexes_str = implode(',', $parent_id_list)) {
495 495
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
496 496
             static::db_get_record_list($owner_location_type,
497 497
               $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true);
@@ -502,20 +502,20 @@  discard block
 block discarded – undo
502 502
       $query = static::db_query_select(
503 503
         "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . (($filter = trim($filter)) ? " WHERE {$filter}" : '')
504 504
       );
505
-      while($row = db_fetch($query)) {
505
+      while ($row = db_fetch($query)) {
506 506
         static::cache_set($location_type, $row[$id_field], $row);
507 507
         $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]];
508 508
       }
509 509
     }
510 510
 
511
-    if($no_return) {
511
+    if ($no_return) {
512 512
       return true;
513 513
     } else {
514 514
       $result = false;
515
-      if(is_array($query_cache)) {
516
-        foreach($query_cache as $key => $value) {
515
+      if (is_array($query_cache)) {
516
+        foreach ($query_cache as $key => $value) {
517 517
           $result[$key] = $value;
518
-          if($fetch) break;
518
+          if ($fetch) break;
519 519
         }
520 520
       }
521 521
       return $fetch ? (is_array($result) ? reset($result) : false) : $result;
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
   }
524 524
 
525 525
   public static function db_upd_record_by_id($location_type, $record_id, $set) {
526
-    if(!($record_id = idval($record_id)) || !($set = trim($set))) return false;
526
+    if (!($record_id = idval($record_id)) || !($set = trim($set))) return false;
527 527
 
528 528
     $location_info = &static::$location_info[$location_type];
529 529
     $id_field = $location_info[P_ID];
530 530
     $table_name = $location_info[P_TABLE_NAME];
531
-    if($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
531
+    if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
532 532
     {
533
-      if(static::$db->db_affected_rows()) {
533
+      if (static::$db->db_affected_rows()) {
534 534
         // Обновляем данные только если ряд был затронут
535 535
         // TODO - переделать под работу со структурированными $set
536 536
 
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
     return $result;
546 546
   }
547 547
   public static function db_upd_record_list($location_type, $condition, $set) {
548
-    if(!($set = trim($set))) return false;
548
+    if (!($set = trim($set))) return false;
549 549
 
550 550
     $condition = trim($condition);
551 551
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
552 552
 
553
-    if($result = static::db_query_update("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
553
+    if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
554 554
 
555
-      if(static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
555
+      if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
556 556
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
557 557
         // TODO - когда будет структурированный $condition и $set - перепаковывать данные
558 558
         static::cache_clear($location_type, true);
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
   public static function db_ins_record($location_type, $set) {
566 566
     $set = trim($set);
567 567
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
568
-    if($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
569
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
568
+    if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
569
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
570 570
       {
571 571
         $record_id = db_insert_id();
572 572
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
@@ -582,14 +582,14 @@  discard block
 block discarded – undo
582 582
 
583 583
   public static function db_del_record_by_id($location_type, $safe_record_id)
584 584
   {
585
-    if(!($safe_record_id = idval($safe_record_id))) return false;
585
+    if (!($safe_record_id = idval($safe_record_id))) return false;
586 586
 
587 587
     $location_info = &static::$location_info[$location_type];
588 588
     $id_field = $location_info[P_ID];
589 589
     $table_name = $location_info[P_TABLE_NAME];
590
-    if($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}"))
590
+    if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}"))
591 591
     {
592
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
592
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
593 593
       {
594 594
         static::cache_unset($location_type, $safe_record_id);
595 595
       }
@@ -599,14 +599,14 @@  discard block
 block discarded – undo
599 599
   }
600 600
   public static function db_del_record_list($location_type, $condition)
601 601
   {
602
-    if(!($condition = trim($condition))) return false;
602
+    if (!($condition = trim($condition))) return false;
603 603
 
604 604
     $location_info = &static::$location_info[$location_type];
605 605
     $table_name = $location_info[P_TABLE_NAME];
606 606
 
607
-    if($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}"))
607
+    if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}"))
608 608
     {
609
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
609
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
610 610
       {
611 611
         // Обнуление кэша, потому что непонятно, что поменялось
612 612
         static::cache_clear($location_type);
@@ -652,21 +652,21 @@  discard block
 block discarded – undo
652 652
   public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false)
653 653
   {
654 654
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
655
-    if(!($username_unsafe = trim($username_unsafe))) return false;
655
+    if (!($username_unsafe = trim($username_unsafe))) return false;
656 656
 
657 657
     $user = null;
658
-    if(is_array(static::$data[LOC_USER]))
659
-    foreach(static::$data[LOC_USER] as $user_id => $user_data)
658
+    if (is_array(static::$data[LOC_USER]))
659
+    foreach (static::$data[LOC_USER] as $user_id => $user_data)
660 660
     {
661
-      if(is_array($user_data) && isset($user_data['username']))
661
+      if (is_array($user_data) && isset($user_data['username']))
662 662
       {
663 663
         // проверяем поле
664 664
         // TODO Возможно есть смысл всегда искать по strtolower - но может игрок захочет переименоваться с другим регистром? Проверить!
665
-        if((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe)))
665
+        if ((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe)))
666 666
         {
667 667
           // $user_as_ally = intval($user_data['user_as_ally']);
668 668
           $user_as_ally = idval($user_data['user_as_ally']);
669
-          if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally))
669
+          if ($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally))
670 670
           {
671 671
             $user = $user_data;
672 672
             break;
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
       }
676 676
     }
677 677
 
678
-    if($user === null)
678
+    if ($user === null)
679 679
     {
680 680
       // Вытаскиваем запись
681 681
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
682 682
 
683 683
       $user = static::db_query_select(
684
-        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '='). " '{$username_safe}'",
684
+        "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'",
685 685
         true
686 686
       );
687 687
       static::cache_set(LOC_USER, $user['id'], $user); // В кэш-юзер так же заполнять индексы
@@ -691,14 +691,14 @@  discard block
 block discarded – undo
691 691
   }
692 692
   // UNUSED
693 693
   public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') {
694
-    if(!($email_unsafe = strtolower(trim($email_unsafe)))) return false;
694
+    if (!($email_unsafe = strtolower(trim($email_unsafe)))) return false;
695 695
 
696 696
     $user = null;
697
-    if(is_array(static::$data[LOC_USER])) {
698
-      foreach(static::$data[LOC_USER] as $user_id => $user_data) {
699
-        if(is_array($user_data) && isset($user_data['email_2'])) {
697
+    if (is_array(static::$data[LOC_USER])) {
698
+      foreach (static::$data[LOC_USER] as $user_id => $user_data) {
699
+        if (is_array($user_data) && isset($user_data['email_2'])) {
700 700
           // проверяем поле
701
-          if(strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
701
+          if (strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
702 702
             $user = $user_data;
703 703
             break;
704 704
           }
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
       }
707 707
     }
708 708
 
709
-    if($user === null) {
709
+    if ($user === null) {
710 710
       // Вытаскиваем запись
711 711
       $email_safe = db_escape($email_unsafe);
712 712
       $user = static::db_query_select(
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     $user = null;
724 724
     // TODO переделать на индексы
725 725
 
726
-    if($user === null && !empty($where_safe)) {
726
+    if ($user === null && !empty($where_safe)) {
727 727
       // Вытаскиваем запись
728 728
       $user = static::db_query_select(
729 729
         "SELECT * FROM {{users}} WHERE {$where_safe}",
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
   {
762 762
     // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id]
763 763
     $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields);
764
-    if(is_array($unit))
764
+    if (is_array($unit))
765 765
     {
766 766
       static::$locator[LOC_UNIT][$unit['unit_location_type']][$unit['unit_location_id']][$unit['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
767 767
     }
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 
772 772
   public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id)
773 773
   {
774
-    if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false;
774
+    if (!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false;
775 775
 
776 776
     $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id];
777
-    if(!isset($query_cache))
777
+    if (!isset($query_cache))
778 778
     {
779 779
       $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions());
780
-      if(is_array($got_data))
780
+      if (is_array($got_data))
781 781
       {
782
-        foreach($got_data as $unit_id => $unit_data)
782
+        foreach ($got_data as $unit_id => $unit_data)
783 783
         {
784 784
           // static::$data[LOC_LOCATION][$location_type][$location_id][$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
785 785
           $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
     }
789 789
 
790 790
     $result = false;
791
-    if(is_array($query_cache)) {
792
-      foreach($query_cache as $key => $value) {
791
+    if (is_array($query_cache)) {
792
+      foreach ($query_cache as $key => $value) {
793 793
         $result[$key] = $value;
794 794
       }
795 795
     }
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
    */
828 828
   public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false)
829 829
   {
830
-    if(!$user_id)
830
+    if (!$user_id)
831 831
     {
832 832
       pdump(debug_backtrace());
833 833
       die('No user_id for que_get_que()');
@@ -837,14 +837,14 @@  discard block
 block discarded – undo
837 837
 
838 838
     $query = array();
839 839
 
840
-    if($user_id = idval($user_id))
840
+    if ($user_id = idval($user_id))
841 841
       $query[] = "`que_player_id` = {$user_id}";
842 842
 
843
-    if($que_type == QUE_RESEARCH || $planet_id === null)
843
+    if ($que_type == QUE_RESEARCH || $planet_id === null)
844 844
       $query[] = "`que_planet_id` IS NULL";
845
-    elseif($planet_id)
845
+    elseif ($planet_id)
846 846
       $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
847
-    if($que_type)
847
+    if ($que_type)
848 848
       $query[] = "`que_type` = {$que_type}";
849 849
 
850 850
     $ques['items'] = static::db_get_record_list(LOC_QUE, implode(' AND ', $query));
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
   }
969 969
 
970 970
 
971
-  public static function loadFileSettings () {
971
+  public static function loadFileSettings() {
972 972
     $dbsettings = array();
973 973
 
974 974
     require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
 
1033 1033
   public static function services() {
1034
-    if(empty(self::$gc)) {
1034
+    if (empty(self::$gc)) {
1035 1035
       self::$gc = new GlobalContainer(array(
1036 1036
         'cachePrefix' => self::$cache_prefix,
1037 1037
       ));
Please login to merge, or discard this patch.
classes/Common/AccessorsV2.php 1 patch
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -97,9 +97,7 @@
 block discarded – undo
97 97
   /**
98 98
    * Gets accessor for later use
99 99
    *
100
-   * @param string $accessor
101 100
    *
102
-   * @param string $varName
103 101
    *
104 102
    * @return callable|null
105 103
    */
Please login to merge, or discard this patch.
classes/DBAL/DbQuery.php 2 patches
Doc Comments   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -94,6 +94,10 @@  discard block
 block discarded – undo
94 94
    * @param  null|\db_mysql $db
95 95
    */
96 96
   // TODO - $db should be supplied externally
97
+
98
+  /**
99
+   * @param db_mysql $db
100
+   */
97 101
   public function __construct($db = null) {
98 102
     $this->db = empty($db) ? classSupernova::$gc->db : $db;
99 103
   }
@@ -205,7 +209,7 @@  discard block
 block discarded – undo
205 209
 
206 210
 
207 211
   /**
208
-   * @param $table
212
+   * @param string $table
209 213
    *
210 214
    * @return $this
211 215
    */
@@ -313,7 +317,7 @@  discard block
 block discarded – undo
313 317
   /**
314 318
    * Wrapper for db_escape()
315 319
    *
316
-   * @param mixed $string
320
+   * @param string $string
317 321
    *
318 322
    * @return string
319 323
    */
@@ -344,7 +348,7 @@  discard block
 block discarded – undo
344 348
   /**
345 349
    * Quote mysql DB identifier
346 350
    *
347
-   * @param mixed $fieldName
351
+   * @param string $fieldName
348 352
    *
349 353
    * @return string
350 354
    */
@@ -391,7 +395,7 @@  discard block
 block discarded – undo
391 395
   /**
392 396
    * Quote table name with `{{ }}`
393 397
    *
394
-   * @param mixed $tableName
398
+   * @param string $tableName
395 399
    *
396 400
    * @return string
397 401
    */
@@ -438,7 +442,7 @@  discard block
 block discarded – undo
438 442
 
439 443
 
440 444
   /**
441
-   * @param $command
445
+   * @param string $command
442 446
    */
443 447
   protected function buildCommand($command) {
444 448
     switch ($this->command = $command) {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
    * @return string
339 339
    */
340 340
   protected function stringValue($value) {
341
-    return "'" . $this->escape((string)$value) . "'";
341
+    return "'" . $this->escape((string) $value) . "'";
342 342
   }
343 343
 
344 344
   /**
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
    * @return string
350 350
    */
351 351
   public function quote($fieldName) {
352
-    return "`" . $this->escape((string)$fieldName) . "`";
352
+    return "`" . $this->escape((string) $fieldName) . "`";
353 353
   }
354 354
 
355 355
   /**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
    * @return string
397 397
    */
398 398
   protected function quoteTable($tableName) {
399
-    return "`{{" . $this->escape((string)$tableName) . "}}`";
399
+    return "`{{" . $this->escape((string) $tableName) . "}}`";
400 400
   }
401 401
 
402 402
   /**
Please login to merge, or discard this patch.
classes/Design.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -42,6 +42,9 @@
 block discarded – undo
42 42
     $this->addSmiles($sn_data_smiles);
43 43
   }
44 44
 
45
+  /**
46
+   * @param integer $accessLevel
47
+   */
45 48
   protected function detectElementsFormat($elements, $accessLevel = AUTH_LEVEL_REGISTERED) {
46 49
     $firstElement = reset($elements);
47 50
     if (!is_array($firstElement)) {
Please login to merge, or discard this patch.
classes/HelperString.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
   }
28 28
 
29 29
   /**
30
-   * @param $string
30
+   * @param string $string
31 31
    *
32 32
    * @return string
33 33
    */
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
   /**
40 40
    * @param $string
41 41
    *
42
-   * @return mixed
42
+   * @return string
43 43
    */
44 44
   public static function nl2br($string) {
45 45
     return str_replace(array("\r", "\n"), '', nl2br($string));
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
   /**
49 49
    * Make string JS-safe
50 50
    *
51
-   * @param $string
51
+   * @param string $string
52 52
    *
53
-   * @return mixed
53
+   * @return string
54 54
    */
55 55
   public static function jsSafe($string) {
56 56
     return str_replace(array("\r", "\n"), array('\r', '\n'), addslashes($string));
Please login to merge, or discard this patch.
classes/SkinModel.php 1 patch
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -70,6 +70,11 @@
 block discarded – undo
70 70
     return $this->getImageFrom($this->activeSkin->getName(), $image_tag, $template);
71 71
   }
72 72
 
73
+  /**
74
+   * @param string $skinName
75
+   * @param string $image_tag
76
+   * @param template|null $template
77
+   */
73 78
   public function getImageFrom($skinName, $image_tag, $template) {
74 79
     return $this->getSkin($skinName)->imageFromStringTag($image_tag, $template);
75 80
   }
Please login to merge, or discard this patch.
classes/TextEntity.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
   }
40 40
 
41 41
   /**
42
-   * @return array
42
+   * @return integer
43 43
    */
44 44
   public function toArray() {
45 45
     $tutorial = array();
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
    */
44 44
   public function toArray() {
45 45
     $tutorial = array();
46
-    foreach($this->keys() as $key) {
46
+    foreach ($this->keys() as $key) {
47 47
       $tutorial[$key] = $this->$key;
48 48
     }
49 49
 
Please login to merge, or discard this patch.
includes/db.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,6 +11,9 @@  discard block
 block discarded – undo
11 11
 
12 12
 require_once('db/db_queries.php');
13 13
 
14
+/**
15
+ * @param string $tablename
16
+ */
14 17
 function db_change_units_perform($query, $tablename, $object_id) {
15 18
   $query = implode(',', $query);
16 19
   if($query && $object_id) {
@@ -67,11 +70,8 @@  discard block
 block discarded – undo
67 70
 /**
68 71
  * Функция проверяет статус транзакции
69 72
  *
70
- * @param null|true|false $status Должна ли быть запущена транзакция в момент проверки
71
- *   <p>null - транзакция НЕ должна быть запущена</p>
72
- *   <p>true - транзакция должна быть запущена - для совместимости с $for_update</p>
73
- *   <p>false - всё равно - для совместимости с $for_update</p>
74
- * @return bool Текущий статус транзакции
73
+ * @param boolean $transaction_should_be_started
74
+ * @return null|boolean Текущий статус транзакции
75 75
  */
76 76
 function sn_db_transaction_check($transaction_should_be_started = null) {
77 77
   return classSupernova::db_transaction_check($transaction_should_be_started);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @copyright 2008-2015 Gorlum for Project "SuperNova.WS"
6 6
  */
7 7
 
8
-if(!defined('INSIDE')) {
8
+if (!defined('INSIDE')) {
9 9
   die();
10 10
 }
11 11
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 function db_change_units_perform($query, $tablename, $object_id) {
15 15
   $query = implode(',', $query);
16
-  if($query && $object_id) {
16
+  if ($query && $object_id) {
17 17
     return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query);
18 18
   }
19 19
 }
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 
30 30
   $group = sn_get_groups('resources_loot');
31 31
 
32
-  foreach($unit_list as $unit_id => $unit_amount) {
33
-    if(!in_array($unit_id, $group)) {
32
+  foreach ($unit_list as $unit_id => $unit_amount) {
33
+    if (!in_array($unit_id, $group)) {
34 34
       // TODO - remove later
35 35
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>');
36 36
       pdump(debug_backtrace());
37 37
       die('db_change_units() вызван для не-ресурсов!');
38 38
     }
39 39
 
40
-    if(!$unit_amount) {
40
+    if (!$unit_amount) {
41 41
       continue;
42 42
     }
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     $unit_location = sys_get_unit_location($user, $planet, $unit_id);
47 47
 
48 48
     // Changing value in object
49
-    switch($unit_location) {
49
+    switch ($unit_location) {
50 50
       case LOC_USER:
51 51
         $user[$unit_db_name] += $unit_amount;
52 52
         break;
Please login to merge, or discard this patch.