Passed
Push — work-fleets ( 4e1f0c...91349a )
by SuperNova.WS
10:40
created
classes/UBE/UBEUnit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     parent::setUnitId($unitId);
51 51
 
52 52
     // Reset combat stats??
53
-    if($this->_unitId) {
53
+    if ($this->_unitId) {
54 54
       $this->amplify = $this->info[P_AMPLIFY];
55 55
       $this->capacity = $this->info[P_CAPACITY];
56 56
       $this->price[RES_METAL] = $this->info[P_COST][RES_METAL];
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     $this->bonus_attack = $this->info[P_ATTACK];
73 73
     $this->bonus_shield = $this->info[P_SHIELD];
74 74
     $this->bonus_armor = $this->info[P_ARMOR];
75
-    if(is_object($this->unit_bonus)) {
75
+    if (is_object($this->unit_bonus)) {
76 76
       $this->bonus_attack = floor($this->bonus_attack * $this->unit_bonus->calcBonus(P_ATTACK));
77 77
       $this->bonus_shield = floor($this->bonus_shield * $this->unit_bonus->calcBonus(P_SHIELD));
78 78
       $this->bonus_armor = floor($this->bonus_armor * $this->unit_bonus->calcBonus(P_ARMOR));
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     $this->randomized_attack = $this->bonus_attack;
81 81
     $this->randomized_shield = $this->bonus_shield;
82 82
     $this->randomized_armor = $this->bonus_armor;
83
-    if(!$is_simulator) {
83
+    if (!$is_simulator) {
84 84
       // TODO - randomize attack if is not simulator
85 85
       $this->randomized_attack = floor($this->bonus_attack * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100));
86 86
       $this->randomized_shield = floor($this->bonus_shield * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100));
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
    * @version 2016-02-25 23:42:45 41a4.68
160 160
    */
161 161
   public function restore_unit($is_simulator) {
162
-    if($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) {
162
+    if ($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) {
163 163
       return;
164 164
     }
165 165
 
166
-    if($is_simulator) {
166
+    if ($is_simulator) {
167 167
       $units_giveback = round($this->units_lost * UBE_DEFENCE_RESTORATION_CHANCE_AVG / 100); // for simulation just return 75% of loss
168 168
     } else {
169 169
       // Checking - should we trigger mass-restore
170
-      if($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) {
170
+      if ($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) {
171 171
         // For large amount - mass-restoring defence
172 172
         $units_giveback = round($this->units_lost * mt_rand(UBE_DEFENCE_RESTORATION_CHANCE_MIN, UBE_DEFENCE_RESTORATION_CHANCE_MAX) / 100);
173 173
       } else {
174 174
         // For small amount - restoring defence per single unit
175 175
         $units_giveback = 0;
176
-        for($i = 1; $i <= $this->units_lost; $i++) {
177
-          if(mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) {
176
+        for ($i = 1; $i <= $this->units_lost; $i++) {
177
+          if (mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) {
178 178
             $units_giveback++;
179 179
           }
180 180
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
    */
194 194
   public function receive_damage($is_simulator) {
195 195
     // TODO - Добавить взрывы от полуповрежденных юнитов - т.е. заранее вычислить из убитых юнитов еще количество убитых умножить на вероятность от структуры
196
-    if($this->_count <= 0) {
196
+    if ($this->_count <= 0) {
197 197
       return;
198 198
     }
199 199
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     $this->adjustCount(-$units_lost);
217 217
 
218 218
     // Проверяем - не взорвался ли текущий юнит
219
-    while($this->_count > 0 && $this->attack_income > 0) {
219
+    while ($this->_count > 0 && $this->attack_income > 0) {
220 220
       $this->attack_damaged_unit($is_simulator);
221 221
     }
222 222
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     $armor_left = $this->pool_armor % $this->randomized_armor;
242 242
     // Проверка - не атакуем ли мы целый корабль
243 243
     // Такое может быть, если на прошлой итерации поврежденный корабль был взорван и еще осталась входящяя атака
244
-    if($shield_left == 0 && $armor_left == 0) {
244
+    if ($shield_left == 0 && $armor_left == 0) {
245 245
       $shield_left = $this->randomized_shield;
246 246
       $armor_left = $this->randomized_armor;
247 247
     }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     // Вычитаем этот дамадж из щитов пула
256 256
     $this->pool_shield -= $damage_to_shield;
257 257
     // Если весь дамадж был поглощён щитами - выходим
258
-    if($this->attack_income <= 0) {
258
+    if ($this->attack_income <= 0) {
259 259
       return;
260 260
     }
261 261
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     $armor_left -= $damage_to_armor;
273 273
 
274 274
     // Проверяем - осталась ли броня на текущем корабле и вааще
275
-    if($this->pool_armor <= 0 || $armor_left <= 0) {
275
+    if ($this->pool_armor <= 0 || $armor_left <= 0) {
276 276
       // Не осталось - корабль уничтожен
277 277
       $this->adjustCount(-1);
278 278
 
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
     $armor_left_percent = $armor_left / $this->randomized_armor * 100;
284 284
     // Проверяем % здоровья
285 285
     // TODO - сделать динамический процент для каждого вида юнитов
286
-    if($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) {
286
+    if ($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) {
287 287
       // Дамадж пошёл по структуре. Чем более поврежден юнит - тем больше шансов у него взорваться
288 288
       $random = $is_simulator ? UBE_CRITICAL_DAMAGE_THRESHOLD / 2 : mt_rand(0, 100);
289
-      if($random >= $armor_left_percent) {
289
+      if ($random >= $armor_left_percent) {
290 290
         $this->adjustCount(-1);
291 291
         $this->unit_count_boom++;
292 292
 
Please login to merge, or discard this patch.
classes/DBAL/DbQuery.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
    * @return string
305 305
    */
306 306
   protected function stringValue($value) {
307
-    return "'" . $this->escape((string)$value) . "'";
307
+    return "'".$this->escape((string) $value)."'";
308 308
   }
309 309
 
310 310
   /**
@@ -315,20 +315,20 @@  discard block
 block discarded – undo
315 315
    * @return string
316 316
    */
317 317
   public function quote($fieldName) {
318
-    return "`" . $this->escape((string)$fieldName) . "`";
318
+    return "`".$this->escape((string) $fieldName)."`";
319 319
   }
320 320
 
321 321
   public function makeAdjustString($fieldValue, $fieldName) {
322 322
     return is_int($fieldName)
323 323
       ? $fieldValue
324
-      : (($fieldNameQuoted = $this->quote($fieldName)) . " = " .
325
-        $fieldNameQuoted . " + (" . $this->castAsDbValue($fieldValue) . ")");
324
+      : (($fieldNameQuoted = $this->quote($fieldName))." = ".
325
+        $fieldNameQuoted." + (".$this->castAsDbValue($fieldValue).")");
326 326
   }
327 327
 
328 328
   public function makeFieldEqualValue($fieldValue, $fieldName) {
329 329
     return is_int($fieldName)
330 330
       ? $fieldValue
331
-      : ($this->quote($fieldName) . " = " . $this->castAsDbValue($fieldValue));
331
+      : ($this->quote($fieldName)." = ".$this->castAsDbValue($fieldValue));
332 332
   }
333 333
 
334 334
   /**
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
    * @return string
340 340
    */
341 341
   protected function quoteTable($tableName) {
342
-    return "`{{" . $this->escape((string)$tableName) . "}}`";
342
+    return "`{{".$this->escape((string) $tableName)."}}`";
343 343
   }
344 344
 
345 345
   public function castAsDbValue($value) {
@@ -376,21 +376,21 @@  discard block
 block discarded – undo
376 376
   protected function buildCommand() {
377 377
     switch ($this->command) {
378 378
       case static::UPDATE:
379
-        $this->build[] = $this->command . " " . $this->quoteTable($this->table);
379
+        $this->build[] = $this->command." ".$this->quoteTable($this->table);
380 380
       break;
381 381
 
382 382
       case static::DELETE:
383
-        $this->build[] = $this->command . " FROM " . $this->quoteTable($this->table);
383
+        $this->build[] = $this->command." FROM ".$this->quoteTable($this->table);
384 384
       break;
385 385
 
386 386
       case static::REPLACE:
387 387
       case static::INSERT_IGNORE:
388 388
       case static::INSERT:
389
-        $this->build[] = $this->command . " INTO " . $this->quoteTable($this->table);
389
+        $this->build[] = $this->command." INTO ".$this->quoteTable($this->table);
390 390
       break;
391 391
 
392 392
       case static::SELECT:
393
-        $this->build[] = $this->command . " ";
393
+        $this->build[] = $this->command." ";
394 394
       break;
395 395
     }
396 396
   }
@@ -431,12 +431,12 @@  discard block
 block discarded – undo
431 431
   protected function buildValuesVector() {
432 432
     $compiled = array();
433 433
 
434
-    if(!empty($this->valuesDanger)) {
434
+    if (!empty($this->valuesDanger)) {
435 435
       $compiled = $this->valuesDanger;
436 436
     }
437 437
 
438 438
     foreach ($this->values as $valuesVector) {
439
-      $compiled[] = '(' . implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))) . ')';
439
+      $compiled[] = '('.implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))).')';
440 440
     }
441 441
 
442 442
     $this->build[] = implode(',', $compiled);
Please login to merge, or discard this patch.
classes/Account.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     $this->reset();
80 80
     $this->db = is_object($db) ? $db : classSupernova::$db;
81 81
 
82
-    foreach($this->table_check as $table_name) {
83
-      if(empty($this->db->table_list[$table_name])) {
82
+    foreach ($this->table_check as $table_name) {
83
+      if (empty($this->db->table_list[$table_name])) {
84 84
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
85 85
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
86 86
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
    */
105 105
   // OK v4.6
106 106
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
107
-    if(!$this->password_check($old_password_unsafe)) {
107
+    if (!$this->password_check($old_password_unsafe)) {
108 108
       return false;
109 109
     }
110 110
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   // OK v4.5
126 126
   public function assign_from_db_row($row) {
127 127
     $this->reset();
128
-    if(empty($row) || !is_array($row)) {
128
+    if (empty($row) || !is_array($row)) {
129 129
       return false;
130 130
     }
131 131
     $this->account_id = $row['account_id'];
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         `account_email` = LOWER('{$email_safe}'),
243 243
         `account_language` = '{$language_safe}'"
244 244
     );
245
-    if(!$result) {
245
+    if (!$result) {
246 246
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
247 247
     }
248 248
 
249
-    if(!($account_id = $this->db->db_insert_id())) {
249
+    if (!($account_id = $this->db->db_insert_id())) {
250 250
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
251 251
     }
252 252
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
       WHERE `account_id` = '{$account_id_safe}'"
277 277
     ) ? true : false;
278 278
 
279
-    if($result) {
279
+    if ($result) {
280 280
       $result = $this->db_get_by_id($this->account_id);
281 281
     }
282 282
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
   public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) {
364 364
     global $mm_change_legit;
365 365
 
366
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
366
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
367 367
       classSupernova::$debug->error('Ошибка при попытке манипуляции с ММ');
368 368
 
369 369
       return false;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
     $mm_change_legit = true;
375 375
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
376
-    if($already_changed) {
376
+    if ($already_changed) {
377 377
       $metamatter_total_delta = 0;
378 378
       $result = -1;
379 379
     } else {
@@ -383,17 +383,17 @@  discard block
 block discarded – undo
383 383
       $result = $this->db->doquery(
384 384
         "UPDATE {{account}}
385 385
         SET
386
-          `account_metamatter` = `account_metamatter` + '{$metamatter}'" .
387
-        ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
386
+          `account_metamatter` = `account_metamatter` + '{$metamatter}'".
387
+        ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '').
388 388
         " WHERE `account_id` = {$account_id_safe}"
389 389
       );
390
-      if(!$result) {
390
+      if (!$result) {
391 391
         classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
392 392
       }
393 393
       $result = classSupernova::$db->db_affected_rows();
394 394
     }
395 395
 
396
-    if(empty(core_auth::$user['id'])) {
396
+    if (empty(core_auth::$user['id'])) {
397 397
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
398 398
       reset($user_list);
399 399
       $user_id_unsafe = key($user_list);
@@ -402,30 +402,30 @@  discard block
 block discarded – undo
402 402
     }
403 403
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
404 404
 
405
-    if(!$result) {
405
+    if (!$result) {
406 406
       classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
407 407
     }
408 408
 
409
-    if(!$already_changed) {
409
+    if (!$already_changed) {
410 410
       $this->account_metamatter += $metamatter;
411 411
       $this->account_metamatter_total += $metamatter_total_delta;
412 412
     }
413 413
 
414
-    if(is_array($comment)) {
414
+    if (is_array($comment)) {
415 415
       $comment = call_user_func_array('sprintf', $comment);
416 416
     }
417 417
 
418 418
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
419 419
 
420
-    if($metamatter > 0 && !empty($user_id_safe)) {
420
+    if ($metamatter > 0 && !empty($user_id_safe)) {
421 421
       $old_referral = db_referral_get_by_id($user_id_safe);
422
-      if($old_referral['id']) {
422
+      if ($old_referral['id']) {
423 423
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
424 424
         db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter);
425 425
         $new_referral = db_referral_get_by_id($user_id_safe);
426 426
 
427 427
         $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0);
428
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
428
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
429 429
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
430 430
         }
431 431
       }
Please login to merge, or discard this patch.
classes/DbSqlAware.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
    */
46 46
   protected function quoteStringAsFieldByRef(&$string) {
47 47
     $string = $this->stringEscape($string);
48
-    if ((string)$string && '*' != $string) {
49
-      $string = '`' . $string . '`';
48
+    if ((string) $string && '*' != $string) {
49
+      $string = '`'.$string.'`';
50 50
     }
51 51
   }
52 52
 
Please login to merge, or discard this patch.
classes/FleetValidator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     'checkSpeedPercentOld'       => FLIGHT_FLEET_SPEED_WRONG,
15 15
     'checkTargetInUniverse'      => FLIGHT_VECTOR_BEYOND_UNIVERSE,
16 16
     'checkTargetNotSource'       => FLIGHT_VECTOR_SAME_SOURCE,
17
-    'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN,  // tODO
17
+    'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN, // tODO
18 18
     'checkTargetNoVacation'      => FLIGHT_PLAYER_VACATION,
19 19
     'checkFleetNotEmpty'         => FLIGHT_SHIPS_NO_SHIPS,
20 20
     // 'checkUnitsPositive'         => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
       $checkResult = call_user_func(array($this, $condition));
135 135
       defined('DEBUG_FLEET_MISSION_VALIDATE_DUMP_STEPS')
136
-        ? pdump($action, $condition . ' ' . ($checkResult ? 'TRUE' : 'FALSE')) : false;
136
+        ? pdump($action, $condition.' '.($checkResult ? 'TRUE' : 'FALSE')) : false;
137 137
 
138 138
       // If check failed and there no alternative actions - throw exception
139 139
       // Shortcut ACTION => FAIL_STATUS instead of ACTION => array(false => FAIL_STATUS)
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $this->checkMissionRestrictions($action);
157 157
       } else {
158 158
         // No - then just performing action
159
-        if($exception) {
159
+        if ($exception) {
160 160
           throw new ExceptionFleetInvalid($action, $action);
161 161
         } else {
162 162
           return $action;
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
   protected function checkMissionPrefix($name, $prefix) {
599 599
     $result = false;
600 600
     if (strpos($name, $prefix) === 0) {
601
-      $mission = 'MT_' . strtoupper(substr($name, strlen($prefix)));
601
+      $mission = 'MT_'.strtoupper(substr($name, strlen($prefix)));
602 602
       if (!defined($mission)) {
603 603
         // TODO - Ну, как-то получше это обделать
604
-        throw new Exception('Mission type "' . $mission . '" is not defined', FLIGHT_MISSION_UNKNOWN);
604
+        throw new Exception('Mission type "'.$mission.'" is not defined', FLIGHT_MISSION_UNKNOWN);
605 605
       }
606 606
 
607 607
       $result = constant($mission);
Please login to merge, or discard this patch.
classes/oldArrayAccessNd.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
     !is_array($offset) ? $offset = array($offset) : false;
39 39
 
40 40
     $current_leaf = $this->__get(reset($offset));
41
-    while(($leaf_index = next($offset)) !== false) {
42
-      if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
41
+    while (($leaf_index = next($offset)) !== false) {
42
+      if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
43 43
         unset($current_leaf);
44 44
         break;
45 45
       }
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 
65 65
     !is_array($offset) ? $offset = array($offset) : false;
66 66
 
67
-    if($this->offsetExists($offset)) {
67
+    if ($this->offsetExists($offset)) {
68 68
       $result = $this->__get(reset($offset));
69
-      while(($leaf_index = next($offset)) !== false) {
69
+      while (($leaf_index = next($offset)) !== false) {
70 70
         $result = $result[$leaf_index];
71 71
       }
72 72
     }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
    */
92 92
   public function offsetSet($offset, $value = null) {
93 93
     // Если нет никакого индекса - значит нечего записывать
94
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
94
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
95 95
       return;
96 96
     }
97 97
 
98 98
     // Если в массиве индекса только один элемент - значит это просто индекс
99
-    if(is_array($offset) && count($offset) == 1) {
99
+    if (is_array($offset) && count($offset) == 1) {
100 100
       // Разворачиваем его в индекс
101 101
       $offset = array(reset($offset) => $value);
102 102
       unset($value);
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     // Адресация многомерного массива через массив индексов в $option
107
-    if(is_array($offset) && isset($value)) {
107
+    if (is_array($offset) && isset($value)) {
108 108
       // TODO - а не переделать ли это всё на __isset() ??
109 109
 //pdump($offset, '$offset');
110 110
 //pdump($value, '$value');
111 111
       // Вытаскиваем корневой элемент
112 112
       $root = $this->__get(reset($offset));
113 113
       $current_leaf = &$root;
114
-      while(($leaf_index = next($offset)) !== false) {
114
+      while (($leaf_index = next($offset)) !== false) {
115 115
         !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false;
116 116
         $current_leaf = &$current_leaf[$leaf_index];
117 117
       }
118 118
 //pdump($current_leaf, '$current_leaf');
119 119
 //pdump($value, '$value');
120
-      if($current_leaf != $value) {
120
+      if ($current_leaf != $value) {
121 121
         $current_leaf = $value;
122 122
 //pdump(reset($offset), 'reset($offset)');
123 123
 //pdump($root, '$root');
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
       // Пакетная запись из массива ключ -> значение
129 129
       !is_array($offset) ? $offset = array($offset => $value) : false;
130 130
 
131
-      foreach($offset as $key => $value) {
131
+      foreach ($offset as $key => $value) {
132 132
         $this->__get($key) !== $value ? $this->__set($key, $value) : false;
133 133
       }
134 134
     }
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
    */
150 150
   public function offsetUnset($offset) {
151 151
     // Если нет никакого индекса - значит нечего записывать
152
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
152
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
153 153
       return;
154 154
     }
155 155
 
156 156
     !is_array($offset) ? $offset = array($offset) : false;
157 157
 
158
-    if($this->offsetExists($offset)) {
158
+    if ($this->offsetExists($offset)) {
159 159
 //pdump($offset);
160 160
       // Перематываем массив в конец
161 161
       $key_to_delete = end($offset);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 //pdump($key_to_delete, '$key_to_delete');
164 164
       $parent_offset = $offset;
165 165
       array_pop($parent_offset);
166
-      if(!count($parent_offset)) {
166
+      if (!count($parent_offset)) {
167 167
         // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент
168 168
         $this->__unset($key_to_delete);
169 169
       } else {
Please login to merge, or discard this patch.
classes/Fleet.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -421,31 +421,31 @@  discard block
 block discarded – undo
421 421
 
422 422
     return classSupernova::$db->doSelect(
423 423
     // Блокировка самого флота
424
-      "SELECT 1 FROM {{fleets}} AS f " .
424
+      "SELECT 1 FROM {{fleets}} AS f ".
425 425
 
426 426
       // Блокировка всех юнитов, принадлежащих этому флоту
427
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
427
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
428 428
 
429 429
       // Блокировка всех прилетающих и улетающих флотов, если нужно
430 430
       // TODO - lock fleets by COORDINATES
431
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') .
431
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '').
432 432
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
433
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
433
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
434 434
 
435
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
435
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
436 436
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
437
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
437
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
438 438
       // Блокировка планеты-цели
439
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
439
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
440 440
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
441 441
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
442 442
 
443 443
 
444
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
444
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
445 445
       // Блокировка всех юнитов, принадлежащих владельцу флота
446
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
446
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
447 447
       // Блокировка планеты отправления
448
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
448
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
449 449
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
450 450
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
451 451
 
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
   public function dbGetLockById($dbId) {
463 463
     classSupernova::$db->doSelect(
464 464
     // Блокировка самого флота
465
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
465
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
466 466
       // Lock fleet owner
467
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
467
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
468 468
       // Блокировка всех юнитов, принадлежащих этому флоту
469
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
469
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
470 470
 
471 471
       // Без предварительной выборки неизвестно - куда летит этот флот.
472 472
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
483 483
       " .
484 484
       // Блокировка всех юнитов, принадлежащих этим флотам
485
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
485
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
486 486
       // Lock fleet owner
487
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
487
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
488 488
 
489 489
       "LEFT JOIN {{fleets}} AS FLEET2 ON
490 490
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
       " .
495 495
       // Блокировка всех юнитов, принадлежащих этим флотам
496 496
       "LEFT JOIN {{unit}} as UNIT2 ON
497
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
497
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
498 498
         UNIT2.unit_location_id = FLEET2.fleet_id
499 499
       " .
500 500
       // Lock fleet owner
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
       " .
512 512
       // Блокировка всех юнитов, принадлежащих этим флотам
513 513
       "LEFT JOIN {{unit}} as UNIT3 ON
514
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
514
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
515 515
         UNIT3.unit_location_id = FLEET3.fleet_id
516 516
       " .
517 517
       // Lock fleet owner
518
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
518
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
519 519
 
520 520
       "LEFT JOIN {{fleets}} AS FLEET4 ON
521 521
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
       " .
526 526
       // Блокировка всех юнитов, принадлежащих этим флотам
527 527
       "LEFT JOIN {{unit}} as UNIT4 ON
528
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
528
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
529 529
         UNIT4.unit_location_id = FLEET4.fleet_id
530 530
       " .
531 531
       // Lock fleet owner
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
       " .
548 548
       // Блокировка всех юнитов, принадлежащих этой планете
549 549
       "LEFT JOIN {{unit}} as UNIT5 ON
550
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
550
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
551 551
         UNIT5.unit_location_id = PLANETS5.id
552 552
       " .
553 553
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
       " .
566 566
       // Блокировка всех юнитов, принадлежащих этой планете
567 567
       "LEFT JOIN {{unit}} as UNIT6 ON
568
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
568
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
569 569
         UNIT6.unit_location_id = PLANETS6.id
570 570
       " .
571 571
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
       } elseif ($this->isResource($unit_id)) {
685 685
         $this->resource_list[$unit_id] = $unit_count;
686 686
       } else {
687
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG);
687
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG);
688 688
       }
689 689
     }
690 690
   }
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
    * @param int $unit_count
819 819
    */
820 820
   public function shipSetCount($unit_id, $unit_count = 0) {
821
-    pdump(__CLASS__ . '->' . __FUNCTION__);
821
+    pdump(__CLASS__.'->'.__FUNCTION__);
822 822
     $this->shipAdjustCount($unit_id, $unit_count, true);
823 823
   }
824 824
 
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
    */
1017 1017
   public function resourcesSet($resource_list) {
1018 1018
     if (!empty($this->propertiesAdjusted['resource_list'])) {
1019
-      throw new ExceptionPropertyAccess('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
1019
+      throw new ExceptionPropertyAccess('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
1020 1020
     }
1021 1021
     $this->resourcesAdjust($resource_list, true);
1022 1022
   }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
       // Check for negative unit value
1051 1051
       if ($this->resource_list[$resource_id] < 0) {
1052 1052
         // TODO
1053
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1053
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1054 1054
       }
1055 1055
     }
1056 1056
   }
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
 
1238 1238
   protected function printErrorIfNoShips() {
1239 1239
     if ($this->unitList->unitsCount() <= 0) {
1240
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1240
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
1241 1241
     }
1242 1242
   }
1243 1243
 
@@ -1625,14 +1625,14 @@  discard block
 block discarded – undo
1625 1625
       if (FLIGHT_ALLOWED == $validateResult[$missionType]) {
1626 1626
         $this->allowed_missions[$missionType] = $mission;
1627 1627
       } else {
1628
-        if($missionType == $this->mission_type) {
1628
+        if ($missionType == $this->mission_type) {
1629 1629
         }
1630 1630
         unset($this->allowed_missions[$missionType]);
1631 1631
       }
1632 1632
     }
1633 1633
 
1634
-    if(empty($this->allowed_missions)) {
1635
-      if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1634
+    if (empty($this->allowed_missions)) {
1635
+      if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1636 1636
         throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]);
1637 1637
       } else {
1638 1638
         throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE);
@@ -1864,7 +1864,7 @@  discard block
 block discarded – undo
1864 1864
     $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob);
1865 1865
 
1866 1866
     $template_result += array(
1867
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1867
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1868 1868
       'dist'            => pretty_number($this->travelData['distance']),
1869 1869
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1870 1870
       'deute_need'      => pretty_number($this->travelData['consumption']),
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
   /**
1000 1000
    * Set current resource list from array of units
1001 1001
    *
1002
-   * @param array $resource_list
1002
+   * @param integer[] $resource_list
1003 1003
    */
1004 1004
   public function resourcesSet($resource_list) {
1005 1005
     if (!empty($this->propertiesAdjusted['resource_list'])) {
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
   }
1048 1048
 
1049 1049
   /**
1050
-   * @param array $rate
1050
+   * @param integer[] $rate
1051 1051
    *
1052 1052
    * @return float
1053 1053
    */
@@ -1078,8 +1078,6 @@  discard block
 block discarded – undo
1078 1078
    * Restores fleet or resources to planet
1079 1079
    *
1080 1080
    * @param bool $start
1081
-   * @param bool $only_resources
1082
-   * @param int  $result
1083 1081
    */
1084 1082
   public function resourcesUnload($start = true) {
1085 1083
     sn_db_transaction_check(true);
@@ -1243,6 +1241,9 @@  discard block
 block discarded – undo
1243 1241
   }
1244 1242
 
1245 1243
 
1244
+  /**
1245
+   * @param integer $missionStartTimeStamp
1246
+   */
1246 1247
   protected function renderFleetCoordinates($missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) {
1247 1248
     $timeToReturn = $this->travelData['duration'] * 2 + $timeMissionJob;
1248 1249
 
Please login to merge, or discard this patch.
classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
classes/Player.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
    * @return int|mixed
229 229
    */
230 230
   public function calcColonyMaxCount($astrotech = -1) {
231
-    if($astrotech == -1) {
232
-      if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
231
+    if ($astrotech == -1) {
232
+      if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
233 233
 
234 234
         $expeditions = get_player_max_expeditons($this->_dbRow);
235 235
         $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 
304 304
   public function expeditionsMax() {
305
-    if($this->expeditionsMax === null) {
305
+    if ($this->expeditionsMax === null) {
306 306
       $this->expeditionsMax = get_player_max_expeditons($this->_dbRow);
307 307
     }
308 308
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   }
311 311
 
312 312
   public function expeditionsFlying() {
313
-    if($this->expeditionsFlying === null) {
313
+    if ($this->expeditionsFlying === null) {
314 314
       $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE);
315 315
     }
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
   public function fleetsMax() {
322
-    if($this->fleetMax === null) {
322
+    if ($this->fleetMax === null) {
323 323
       $this->fleetMax = GetMaxFleets($this->_dbRow);
324 324
     }
325 325
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   }
328 328
 
329 329
   public function fleetsFlying() {
330
-    if($this->fleetFlying === null) {
330
+    if ($this->fleetFlying === null) {
331 331
       $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId);
332 332
     }
333 333
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
   public function coloniesMax() {
339
-    if($this->coloniesMax === null) {
339
+    if ($this->coloniesMax === null) {
340 340
       $this->coloniesMax = get_player_max_colonies($this->_dbRow);
341 341
     }
342 342
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   public function coloniesCurrent() {
347
-    if($this->coloniesCurrent === null) {
347
+    if ($this->coloniesCurrent === null) {
348 348
       $this->coloniesCurrent = get_player_current_colonies($this->_dbRow);
349 349
     }
350 350
 
Please login to merge, or discard this patch.