Completed
Push — work-fleets ( 9e446e...674b8a )
by SuperNova.WS
12:48 queued 05:50
created
classes/classLocale.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -173,6 +173,9 @@
 block discarded – undo
173 173
   }
174 174
 
175 175
 
176
+  /**
177
+   * @param string $path
178
+   */
176 179
   protected function lng_try_filepath($path, $file_path_relative) {
177 180
     $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative;
178 181
     return file_exists($file_path) ? $file_path : false;
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 
36 36
     $this->container = array();
37 37
 
38
-    if(classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) {
38
+    if (classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) {
39 39
       $this->cache = classSupernova::$cache;
40 40
       classSupernova::log_file('locale.__constructor: Cache is present');
41 41
 //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug!
42 42
     }
43 43
 
44
-    if($enable_stat_usage && empty($this->stat_usage)) {
44
+    if ($enable_stat_usage && empty($this->stat_usage)) {
45 45
       $this->enable_stat_usage = $enable_stat_usage;
46 46
       $this->usage_stat_load();
47 47
       // TODO shutdown function
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
     unset($fallback[$this->active]);
68 68
 
69 69
     // Проходим по оставшимся локалям
70
-    foreach($fallback as $try_language) {
70
+    foreach ($fallback as $try_language) {
71 71
       // Если нет такой строки - пытаемся вытащить из кэша
72
-      if(!isset($this->container[$try_language][$offset]) && $this->cache) {
72
+      if (!isset($this->container[$try_language][$offset]) && $this->cache) {
73 73
         $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset);
74 74
 // Записываем результат работы кэша
75 75
 $locale_cache_statistic['queries']++;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
       }
79 79
 
80 80
       // Если мы как-то где-то нашли строку...
81
-      if(isset($this->container[$try_language][$offset])) {
81
+      if (isset($this->container[$try_language][$offset])) {
82 82
         // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер
83 83
         $this[$offset] = $this->container[$try_language][$offset];
84 84
         $locale_cache_statistic['fallbacks']++;
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
       $this->container[$this->active][] = $value;
95 95
     } else {
96 96
       $this->container[$this->active][$offset] = $value;
97
-      if($this->cache) {
97
+      if ($this->cache) {
98 98
         $this->cache->__set($this->cache_prefix_lang . $offset, $value);
99 99
       }
100 100
     }
101 101
   }
102 102
   public function offsetExists($offset) {
103 103
     // Шорткат если у нас уже есть строка в памяти PHP
104
-    if(!isset($this->container[$this->active][$offset])) {
104
+    if (!isset($this->container[$this->active][$offset])) {
105 105
 //        pdump($this->cache_prefix_lang . $offset);
106
-      if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) {
106
+      if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) {
107 107
 //        pdump($this->cache_prefix_lang . $offset);
108 108
         // Если нету такой строки - делаем фоллбэк
109 109
         $this->locale_string_fallback($offset);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   }
120 120
   public function offsetGet($offset) {
121 121
     $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null;
122
-    if($this->enable_stat_usage) {
122
+    if ($this->enable_stat_usage) {
123 123
       $this->usage_stat_log($offset, $value);
124 124
     }
125 125
     return $value;
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
   public function usage_stat_load() {
137
-    $this->stat_usage = classSupernova::$cache->lng_stat_usage  = array();
138
-    if(empty($this->stat_usage)) {
137
+    $this->stat_usage = classSupernova::$cache->lng_stat_usage = array();
138
+    if (empty($this->stat_usage)) {
139 139
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`");
140
-      while($row = db_fetch($query)) {
140
+      while ($row = db_fetch($query)) {
141 141
         $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty'];
142 142
       }
143 143
     }
144 144
   }
145 145
   public function usage_stat_save() {
146
-    if(!empty($this->stat_usage_new)) {
146
+    if (!empty($this->stat_usage_new)) {
147 147
       classSupernova::$cache->lng_stat_usage = $this->stat_usage;
148 148
       classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1");
149 149
 //      foreach($this->stat_usage_new as &$value) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1));
173 173
 
174 174
     $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line'];
175
-    if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) {
175
+    if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) {
176 176
       $this->stat_usage[$string_id] = empty($value);
177 177
       $this->stat_usage_new[] = array(
178 178
         'lang_code' => $this->active,
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
     $cache_file_key = $this->cache_prefix_lang . '__' . $filename;
213 213
 
214 214
     // Подключен ли внешний кэш?
215
-    if($this->cache) {
215
+    if ($this->cache) {
216 216
       // Загружен ли уже данный файл?
217 217
       $cache_file_status = $this->cache->__get($cache_file_key);
218 218
       classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0);
219
-      if($cache_file_status) {
219
+      if ($cache_file_status) {
220 220
         // Если да - повторять загрузку нет смысла
221 221
         return null;
222 222
       }
@@ -230,36 +230,36 @@  discard block
 block discarded – undo
230 230
     $this->make_fallback($language);
231 231
 
232 232
     $file_path = '';
233
-    foreach($this->fallback as $lang_try) {
234
-      if(!$lang_try /* || isset($language_tried[$lang_try]) */) {
233
+    foreach ($this->fallback as $lang_try) {
234
+      if (!$lang_try /* || isset($language_tried[$lang_try]) */) {
235 235
         continue;
236 236
       }
237 237
 
238
-      if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) {
238
+      if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) {
239 239
         break;
240 240
       }
241 241
 
242
-      if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) {
242
+      if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) {
243 243
         break;
244 244
       }
245 245
 
246 246
       $file_path = '';
247 247
     }
248 248
 
249
-    if($file_path) {
249
+    if ($file_path) {
250 250
       $a_lang_array = array();
251 251
       include($file_path);
252 252
 
253
-      if(!empty($a_lang_array)) {
253
+      if (!empty($a_lang_array)) {
254 254
         $this->merge($a_lang_array);
255 255
 
256 256
         // Загрузка данных из файла в кэш
257
-        if($this->cache) {
257
+        if ($this->cache) {
258 258
           classSupernova::log_file("Locale: loading '{$filename}' into cache");
259
-          foreach($a_lang_array as $key => $value) {
259
+          foreach ($a_lang_array as $key => $value) {
260 260
             $value_cache_key = $this->cache_prefix_lang . $key;
261
-            if($this->cache->__isset($value_cache_key)) {
262
-              if(is_array($value)) {
261
+            if ($this->cache->__isset($value_cache_key)) {
262
+              if (is_array($value)) {
263 263
                 $alt_value = $this->cache->__get($value_cache_key);
264 264
                 $value = array_replace_recursive($alt_value, $value);
265 265
                 // pdump($alt_value, $alt_value);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         }
271 271
       }
272 272
 
273
-      if($this->cache) {
273
+      if ($this->cache) {
274 274
         $this->cache->__set($cache_file_key, true);
275 275
       }
276 276
 
@@ -283,14 +283,14 @@  discard block
 block discarded – undo
283 283
   }
284 284
 
285 285
   public function lng_load_i18n($i18n) {
286
-    if(!isset($i18n)) {
286
+    if (!isset($i18n)) {
287 287
       return;
288 288
     }
289 289
 
290
-    foreach($i18n as $i18n_data) {
291
-      if(is_string($i18n_data)) {
290
+    foreach ($i18n as $i18n_data) {
291
+      if (is_string($i18n_data)) {
292 292
         $this->lng_include($i18n_data);
293
-      } elseif(is_array($i18n_data)) {
293
+      } elseif (is_array($i18n_data)) {
294 294
         $this->lng_include($i18n_data['file'], $i18n_data['path']);
295 295
       }
296 296
     }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 
309 309
     classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'");
310 310
 
311
-    if($language_new == $this->active) {
311
+    if ($language_new == $this->active) {
312 312
       classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1);
313 313
       return false;
314 314
     }
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
     $this['LANG_INFO'] = $this->lng_get_info($this->active);
320 320
     $this->make_fallback($this->active);
321 321
 
322
-    if($this->cache) {
322
+    if ($this->cache) {
323 323
       $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT');
324 324
       classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0);
325
-      if($cache_lang_init_status) {
325
+      if ($cache_lang_init_status) {
326 326
         return false;
327 327
       }
328 328
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     // Loading global language files
339 339
     $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']);
340 340
 
341
-    if($this->cache) {
341
+    if ($this->cache) {
342 342
       classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT');
343 343
       $this->cache->__set($this->cache_prefix_lang . '__INIT', true);
344 344
     }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
   public function lng_get_info($entry) {
353 353
     $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php';
354 354
     $lang_info = array();
355
-    if(file_exists($file_name)) {
355
+    if (file_exists($file_name)) {
356 356
       include($file_name);
357 357
     }
358 358
 
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
   }
361 361
 
362 362
   public function lng_get_list() {
363
-    if(empty($this->lang_list)) {
363
+    if (empty($this->lang_list)) {
364 364
       $this->lang_list = array();
365 365
 
366 366
       $path = SN_ROOT_PHYSICAL . 'language/';
367 367
       $dir = dir($path);
368
-      while(false !== ($entry = $dir->read())) {
369
-        if(is_dir($path . $entry) && $entry[0] != '.') {
368
+      while (false !== ($entry = $dir->read())) {
369
+        if (is_dir($path . $entry) && $entry[0] != '.') {
370 370
           $lang_info = $this->lng_get_info($entry);
371
-          if($lang_info['LANG_NAME_ISO2'] == $entry) {
371
+          if ($lang_info['LANG_NAME_ISO2'] == $entry) {
372 372
             $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info;
373 373
           }
374 374
         }
Please login to merge, or discard this patch.
classes/classSupernova.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 use Vector\Vector;
4
-
5 4
 use Common\GlobalContainer;
6 5
 
7 6
 class classSupernova {
Please login to merge, or discard this patch.
classes/Common/snMath.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
    * @param int  $sigma
19 19
    * @param bool $strict
20 20
    *
21
-   * @return int
21
+   * @return double
22 22
    */
23 23
   public static function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) {
24 24
     // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
    *
43 43
    * @param float      $range_start - Начало диапазона
44 44
    * @param float      $range_end - Конец диапазона
45
-   * @param bool|int   $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд
45
+   * @param boolean   $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд
46 46
    * @param int        $strict - В сколько сигм надо уложить результат
47 47
    * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много
48 48
    *
Please login to merge, or discard this patch.
classes/Confirmation.php 2 patches
Doc Comments   +19 added lines patch added patch discarded remove patch
@@ -18,6 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
   // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!!
20 20
   // TODO - OK 4.6
21
+
22
+  /**
23
+   * @param integer $confirmation_type_safe
24
+   * @param string $email_unsafe
25
+   */
21 26
   public function db_confirmation_get_latest_by_type_and_email($confirmation_type_safe, $email_unsafe) {
22 27
     $email_safe = $this->db->db_escape($email_unsafe);
23 28
 
@@ -26,12 +31,21 @@  discard block
 block discarded – undo
26 31
           `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}' ORDER BY create_time DESC LIMIT 1;", true);
27 32
   }
28 33
   // TODO - OK 4.6
34
+
35
+  /**
36
+   * @param integer $confirmation_type_safe
37
+   */
29 38
   public function db_confirmation_delete_by_type_and_email($confirmation_type_safe, $email_unsafe) {
30 39
     $email_safe = $this->db->db_escape($email_unsafe);
31 40
 
32 41
     return $this->db->doquery("DELETE FROM {{confirmations}} WHERE `type` = {$confirmation_type_safe} AND `email` = '{$email_safe}'");
33 42
   }
34 43
   // TODO - OK 4.6
44
+
45
+  /**
46
+   * @param integer $confirmation_type_safe
47
+   * @param string $email_unsafe
48
+   */
35 49
   public function db_confirmation_get_unique_code_by_type_and_email($confirmation_type_safe, $email_unsafe) {
36 50
     $email_safe = $this->db->db_escape($email_unsafe);
37 51
 
@@ -50,6 +64,11 @@  discard block
 block discarded – undo
50 64
     return $confirm_code_unsafe;
51 65
   }
52 66
   // TODO - OK 4.6
67
+
68
+  /**
69
+   * @param integer $confirmation_type_safe
70
+   * @param string $confirmation_code_unsafe
71
+   */
53 72
   public function db_confirmation_get_by_type_and_code($confirmation_type_safe, $confirmation_code_unsafe) {
54 73
     $confirmation_code_safe = $this->db->db_escape($confirmation_code_unsafe);
55 74
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
       // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true);
42 42
       // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем"
43 43
       $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true);
44
-    } while($query);
44
+    } while ($query);
45 45
 
46 46
     $this->db->doquery(
47 47
       "REPLACE INTO {{confirmations}}
Please login to merge, or discard this patch.
classes/core_auth.php 2 patches
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -286,7 +286,6 @@  discard block
 block discarded – undo
286 286
   /**
287 287
    * Функция пытается залогиниться по всем известным провайдерам
288 288
    *
289
-   * @param null $result
290 289
    */
291 290
   public function login() {
292 291
     if(empty(sn_module::$sn_module_list['auth'])) {
@@ -823,10 +822,17 @@  discard block
 block discarded – undo
823 822
 
824 823
   // OK v4.5
825 824
   // TODO - REMEMBER_ME
825
+
826
+  /**
827
+   * @param integer $period
828
+   */
826 829
   protected static function cookie_set($value, $impersonate = false, $period = null) {
827 830
     sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE);
828 831
   }
829 832
 
833
+  /**
834
+   * @param string $message
835
+   */
830 836
   protected static function flog($message, $die = false) {
831 837
     if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
832 838
       return;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@
 block discarded – undo
259 259
       );
260 260
 
261 261
     if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
262
-      $prohibited_characters = array_map(function ($value) {
262
+      $prohibited_characters = array_map(function($value) {
263 263
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
264 264
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
265 265
       $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters);
Please login to merge, or discard this patch.
classes/DBAL/DbTransaction.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
    *   <p>true - транзакция должна быть запущена - для совместимости с $for_update</p>
40 40
    *   <p>false - всё равно - для совместимости с $for_update</p>
41 41
    *
42
-   * @return bool Текущий статус транзакции
42
+   * @return null|boolean Текущий статус транзакции
43 43
    */
44 44
   public function check($status = null) {
45 45
     $error_msg = false;
Please login to merge, or discard this patch.
classes/DbRowDirectOperator.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -85,6 +85,9 @@
 block discarded – undo
85 85
     return $this->db->doSelectIterator($query);
86 86
   }
87 87
 
88
+  /**
89
+   * @param string $table
90
+   */
88 91
   public function doUpdateRowSetAffected($table, $fieldsAndValues, $where) {
89 92
     $this->db->doUpdateRowSet($table, $fieldsAndValues, $where);
90 93
     return $this->db->db_affected_rows();
Please login to merge, or discard this patch.
classes/DbSqlLiteral.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
   }
27 27
 
28 28
   /**
29
-   * @param mixed $value
29
+   * @param string $value
30 30
    *
31 31
    * @return $this
32 32
    */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
    * @return $this
32 32
    */
33 33
   public function literal($value) {
34
-    $this->literal = (string)$value;
34
+    $this->literal = (string) $value;
35 35
 
36 36
     return $this;
37 37
   }
Please login to merge, or discard this patch.
classes/DBStatic/DBStaticAlly.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@
 block discarded – undo
293 293
   }
294 294
 
295 295
   /**
296
-   * @param $ranklist
296
+   * @param string $ranklist
297 297
    * @param $user
298 298
    */
299 299
   public static function db_ally_update_ranklist($ranklist, $user) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,12 +77,12 @@
 block discarded – undo
77 77
    */
78 78
   public static function db_ally_insert($ally_name_unsafe, $ally_tag_unsafe, $userId) {
79 79
     $ally = classSupernova::$db->doInsertSet(TABLE_ALLIANCE, array(
80
-      'ally_name'          => (string)$ally_name_unsafe,
81
-      'ally_tag'           => (string)$ally_tag_unsafe,
80
+      'ally_name'          => (string) $ally_name_unsafe,
81
+      'ally_tag'           => (string) $ally_tag_unsafe,
82 82
       'ally_owner'         => $userId,
83
-      'ally_owner_range'   => (string)classLocale::$lang['ali_leaderRank'],
84
-      'ally_members'       => (int)1,
85
-      'ranklist'           => (string)(classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0"),
83
+      'ally_owner_range'   => (string) classLocale::$lang['ali_leaderRank'],
84
+      'ally_members'       => (int) 1,
85
+      'ranklist'           => (string) (classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0"),
86 86
       'ally_register_time' => SN_TIME_NOW,
87 87
     ));
88 88
 
Please login to merge, or discard this patch.