Passed
Push — main ( 0084f7...f34b86 )
by Miaad
12:18
created
src/receiver/webhook.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@
 block discarded – undo
21 21
     public static function init () {
22 22
         if (settings::$multi) {
23 23
             multi::init();
24
-        }
25
-        else {
24
+        } else {
26 25
             if (!lock::exist('BPT-HOOK')) {
27 26
                 self::processSetWebhook();
28 27
             }
Please login to merge, or discard this patch.
src/logger.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,8 +46,7 @@
 block discarded – undo
46 46
         $text = date('Y/m/d H:i:s') . ($type !== loggerTypes::NONE ? " : ⤵\n$type" : '') . " : $data\n\n";
47 47
         if (!is_null(self::$handler)) {
48 48
             fwrite(self::$handler, $text);
49
-        }
50
-        else {
49
+        } else {
51 50
             self::$waited_logs[] = $text;
52 51
         }
53 52
     }
Please login to merge, or discard this patch.
src/telegram/request/curl.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
             $curl_handler = curl_init(settings::$base_url."/bot$token/");
44 44
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
45 45
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
46
-        }
47
-        else{
46
+        } else{
48 47
             $token = settings::$token;
49 48
             if (!isset(self::$curl_handler)){
50 49
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
@@ -66,11 +65,9 @@  discard block
 block discarded – undo
66 65
         if (isset($data['forgot'])) {
67 66
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
68 67
             unset($data['forgot']);
69
-        }
70
-        elseif ($method === 'getUpdates' || $method === 'setWebhook'){
68
+        } elseif ($method === 'getUpdates' || $method === 'setWebhook'){
71 69
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
72
-        }
73
-        elseif (settings::$base_timeout > 0) {
70
+        } elseif (settings::$base_timeout > 0) {
74 71
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout);
75 72
         }
76 73
     }
Please login to merge, or discard this patch.
src/database/mysql.php 1 patch
Braces   +26 added lines, -32 removed lines patch added patch discarded remove patch
@@ -89,7 +89,10 @@  discard block
 block discarded – undo
89 89
             foreach ($allowed_file_names as $allowed_file_name) {
90 90
                 if (file_exists($allowed_file_name)) {
91 91
                     $mysqli->multi_query(file_get_contents($allowed_file_name));
92
-                    while ($mysqli->next_result()){if (!$mysqli->more_results()) break;}
92
+                    while ($mysqli->next_result()){if (!$mysqli->more_results()) {
93
+                        break;
94
+                    }
95
+                    }
93 96
                     $loaded = true;
94 97
                 }
95 98
             }
@@ -107,17 +110,13 @@  discard block
 block discarded – undo
107 110
         if (self::$auto_process) {
108 111
             if (isset(BPT::$update->message)) {
109 112
                 self::processMessage(BPT::$update->message);
110
-            }
111
-            elseif (isset(BPT::$update->edited_message)) {
113
+            } elseif (isset(BPT::$update->edited_message)) {
112 114
                 self::processMessage(BPT::$update->edited_message);
113
-            }
114
-            elseif (isset(BPT::$update->callback_query)) {
115
+            } elseif (isset(BPT::$update->callback_query)) {
115 116
                 self::processCallbackQuery(BPT::$update->callback_query);
116
-            }
117
-            elseif (isset(BPT::$update->inline_query)) {
117
+            } elseif (isset(BPT::$update->inline_query)) {
118 118
                 self::processInlineQuery(BPT::$update->inline_query);
119
-            }
120
-            elseif (isset(BPT::$update->my_chat_member)) {
119
+            } elseif (isset(BPT::$update->my_chat_member)) {
121 120
                 self::processMyChatMember(BPT::$update->my_chat_member);
122 121
             }
123 122
         }
@@ -174,8 +173,7 @@  discard block
 block discarded – undo
174 173
         if ($type === chatType::PRIVATE) {
175 174
             if ($update->new_chat_member->status === chatMemberStatus::MEMBER) {
176 175
                 self::update('users', ['blocked' => false], ['id' => $update->from->id], 1);
177
-            }
178
-            else {
176
+            } else {
179 177
                 self::update('users', ['blocked' => true], ['id' => $update->from->id], 1);
180 178
             }
181 179
         }
@@ -195,8 +193,7 @@  discard block
 block discarded – undo
195 193
     public static function addDefaultWhere (array $where): bool {
196 194
         if (empty(self::$default_where)) {
197 195
             self::$default_where = $where;
198
-        }
199
-        else {
196
+        } else {
200 197
             self::$default_where = array_merge(self::$default_where, $where);
201 198
         }
202 199
         return true;
@@ -336,11 +333,9 @@  discard block
 block discarded – undo
336 333
         foreach ($vars as $var) {
337 334
             if (is_int($var)) {
338 335
                 $types .= 'i';
339
-            }
340
-            elseif (is_double($var)) {
336
+            } elseif (is_double($var)) {
341 337
                 $types .= 'd';
342
-            }
343
-            else {
338
+            } else {
344 339
                 $types .= 's';
345 340
             }
346 341
         }
@@ -368,8 +363,7 @@  discard block
 block discarded – undo
368 363
         foreach ($where as $name => $value) {
369 364
             if ($first) {
370 365
                 $first = false;
371
-            }
372
-            else {
366
+            } else {
373 367
                 $query .= ' AND';
374 368
             }
375 369
 
@@ -387,8 +381,7 @@  discard block
 block discarded – undo
387 381
             foreach ($value as $sub_value) {
388 382
                 if ($sub_first) {
389 383
                     $sub_first = false;
390
-                }
391
-                else {
384
+                } else {
392 385
                     $query .= ' AND';
393 386
                 }
394 387
                 $operator = substr($sub_value,0,2);
@@ -468,8 +461,7 @@  discard block
 block discarded – undo
468 461
         foreach ($order_by as $key => $mode) {
469 462
             if ($first) {
470 463
                 $first = false;
471
-            }
472
-            else {
464
+            } else {
473 465
                 $query .= ', ';
474 466
             }
475 467
             if (is_numeric($key)) {
@@ -483,8 +475,7 @@  discard block
 block discarded – undo
483 475
     private static function countBuilder(string &$query, int $count = null, int $offset = null): void {
484 476
         if (!empty($count)) {
485 477
             $query .= !empty($offset) ? " LIMIT $offset, $count" : " LIMIT $count";
486
-        }
487
-        elseif (!empty($offset)) {
478
+        } elseif (!empty($offset)) {
488 479
             $query .= " OFFSET $offset";
489 480
         }
490 481
     }
@@ -496,8 +487,7 @@  discard block
 block discarded – undo
496 487
         foreach ($modify as $name => $value) {
497 488
             if ($first) {
498 489
                 $first = false;
499
-            }
500
-            else {
490
+            } else {
501 491
                 $query .= ',';
502 492
             }
503 493
 
@@ -543,7 +533,9 @@  discard block
 block discarded – undo
543 533
 
544 534
     private static function insertBuilder(string &$query, string|array $columns, array|string $values): array {
545 535
         $query .= '(`' . (is_string($columns) ? $columns : implode('`, `', $columns)) . '`) VALUES (';
546
-        if (is_string($values)) $values = [$values];
536
+        if (is_string($values)) {
537
+            $values = [$values];
538
+        }
547 539
         $query .= '?' . str_repeat(', ?', count($values) - 1) . ')';
548 540
         return $values;
549 541
     }
@@ -568,8 +560,7 @@  discard block
 block discarded – undo
568 560
                     $column = 'all';
569 561
                 }
570 562
                 $query .= strtoupper($function) . "($formatted) as `{$function}_$column`";
571
-            }
572
-            else {
563
+            } else {
573 564
                 $query .= "`$column`";
574 565
             }
575 566
 
@@ -757,9 +748,12 @@  discard block
 block discarded – undo
757 748
     public static function selectEach (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|Generator {
758 749
         $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by, ignore_default_where: $ignore_default_where);
759 750
         if ($res) {
760
-            while ($row = $res->fetch_assoc()) yield $row;
751
+            while ($row = $res->fetch_assoc()) {
752
+                yield $row;
753
+            }
754
+        } else {
755
+            return $res;
761 756
         }
762
-        else return $res;
763 757
     }
764 758
 
765 759
     /**
Please login to merge, or discard this patch.
src/database/json.php 1 patch
Braces   +43 added lines, -56 removed lines patch added patch discarded remove patch
@@ -195,17 +195,13 @@  discard block
 block discarded – undo
195 195
     public static function process (): void {
196 196
         if (isset(BPT::$update->message)) {
197 197
             self::processMessage(BPT::$update->message);
198
-        }
199
-        elseif (isset(BPT::$update->edited_message)) {
198
+        } elseif (isset(BPT::$update->edited_message)) {
200 199
             self::processMessage(BPT::$update->edited_message);
201
-        }
202
-        elseif (isset(BPT::$update->callback_query)) {
200
+        } elseif (isset(BPT::$update->callback_query)) {
203 201
             self::processCallbackQuery(BPT::$update->callback_query);
204
-        }
205
-        elseif (isset(BPT::$update->inline_query)) {
202
+        } elseif (isset(BPT::$update->inline_query)) {
206 203
             self::processInlineQuery(BPT::$update->inline_query);
207
-        }
208
-        elseif (isset(BPT::$update->chat_member)) {
204
+        } elseif (isset(BPT::$update->chat_member)) {
209 205
             self::processChatMember(BPT::$update->chat_member);
210 206
         }
211 207
     }
@@ -230,8 +226,7 @@  discard block
 block discarded – undo
230 226
             if (empty(self::$group)) {
231 227
                 $category = 'supergroups';
232 228
                 $group_id = self::$supergroup_id;
233
-            }
234
-            else {
229
+            } else {
235 230
                 $category = 'groups';
236 231
                 $group_id = self::$group_id;
237 232
             }
@@ -247,8 +242,7 @@  discard block
 block discarded – undo
247 242
             if (empty(self::$group)) {
248 243
                 $category = 'supergroups';
249 244
                 $group_id = self::$supergroup_id;
250
-            }
251
-            else {
245
+            } else {
252 246
                 $category = 'groups';
253 247
                 $group_id = self::$group_id;
254 248
             }
@@ -265,8 +259,7 @@  discard block
 block discarded – undo
265 259
                 self::$user = self::read($category . '/' . self::$user_id);
266 260
                 self::$old_user = clone self::$user;
267 261
                 self::$user->last_active = time();
268
-            }
269
-            else {
262
+            } else {
270 263
                 self::$ids[$category][] = self::$user_id;
271 264
                 self::$user = (object) self::$user_default_data;
272 265
                 self::$user->first_active = self::$user->last_active = time();
@@ -279,19 +272,16 @@  discard block
 block discarded – undo
279 272
                     }
280 273
                 }
281 274
             }
282
-        }
283
-        elseif ($type === chatType::CHANNEL) {
275
+        } elseif ($type === chatType::CHANNEL) {
284 276
             self::$channel_id = $update->chat->id;
285 277
             if (in_array(self::$channel_id,self::$ids[$category])) {
286 278
                 self::$channel = self::read($category . '/' . self::$channel_id);
287 279
                 self::$old_channel = clone self::$channel;
288
-            }
289
-            else {
280
+            } else {
290 281
                 self::$ids[$category][] = self::$channel_id;
291 282
                 self::$channel = (object) self::$channel_default_data;
292 283
             }
293
-        }
294
-        else {
284
+        } else {
295 285
             self::$user_id = $update->from->id;
296 286
             self::$group_user_id = self::$user_id;
297 287
             $chat_id = $update->chat->id;
@@ -302,22 +292,19 @@  discard block
 block discarded – undo
302 292
                     self::$old_supergroup = clone self::$supergroup;
303 293
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
304 294
                     self::$old_group_ids = clone self::$group_ids;
305
-                }
306
-                else {
295
+                } else {
307 296
                     self::$ids[$category][] = $chat_id;
308 297
                     self::$supergroup = (object) self::$supergroup_default_data;
309 298
                     self::$group_ids = [];
310 299
                 }
311
-            }
312
-            else {
300
+            } else {
313 301
                 self::$group_id = $update->chat->id;
314 302
                 if (in_array($chat_id,self::$ids[$category])) {
315 303
                     self::$group = self::read($category . '/' . $chat_id);
316 304
                     self::$old_group = clone self::$group;
317 305
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
318 306
                     self::$old_group_ids = clone self::$group_ids;
319
-                }
320
-                else {
307
+                } else {
321 308
                     self::$ids[$category][] = $chat_id;
322 309
                     self::$group = (object) self::$group_default_data;
323 310
                     self::$group_ids = [];
@@ -327,15 +314,16 @@  discard block
 block discarded – undo
327 314
             if (in_array(self::$user_id,self::$group_ids)) {
328 315
                 self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id);
329 316
                 self::$old_group_user = clone self::$group_user;
330
-            }
331
-            else {
317
+            } else {
332 318
                 self::$group_ids[] = self::$user_id;
333 319
                 self::$group_user = (object) self::$group_user_default_data;
334 320
             }
335 321
 
336 322
             self::$user = self::read($category.'/'.self::$user_id);
337 323
             self::$old_user = clone self::$user;
338
-            if (!empty(self::$user)) self::$user->last_active = time();
324
+            if (!empty(self::$user)) {
325
+                self::$user->last_active = time();
326
+            }
339 327
         }
340 328
     }
341 329
 
@@ -349,15 +337,13 @@  discard block
 block discarded – undo
349 337
                 self::$old_user = clone self::$user;
350 338
                 self::$user->last_active = time();
351 339
             }
352
-        }
353
-        elseif ($type === chatType::CHANNEL) {
340
+        } elseif ($type === chatType::CHANNEL) {
354 341
             self::$channel_id = $update->message->chat->id;
355 342
             if (in_array(self::$channel_id,self::$ids[$category])) {
356 343
                 self::$channel = self::read($category . '/' . self::$channel_id);
357 344
                 self::$old_channel = clone self::$channel;
358 345
             }
359
-        }
360
-        else {
346
+        } else {
361 347
             self::$user_id = $update->from->id;
362 348
             $chat_id = $update->message->chat->id;
363 349
             if (in_array($chat_id,self::$ids[$category])) {
@@ -365,8 +351,7 @@  discard block
 block discarded – undo
365 351
                     self::$supergroup_id = $update->message->chat->id;
366 352
                     self::$supergroup = self::read($category . '/' . $chat_id);
367 353
                     self::$old_supergroup = clone self::$supergroup;
368
-                }
369
-                else {
354
+                } else {
370 355
                     self::$group_id = $update->message->chat->id;
371 356
                     self::$group = self::read($category . '/' . $chat_id);
372 357
                     self::$old_group = clone self::$group;
@@ -383,7 +368,9 @@  discard block
 block discarded – undo
383 368
 
384 369
             self::$user = self::read($category.'/'.self::$user_id);
385 370
             self::$old_user = clone self::$user;
386
-            if (!empty(self::$user)) self::$user->last_active = time();
371
+            if (!empty(self::$user)) {
372
+                self::$user->last_active = time();
373
+            }
387 374
         }
388 375
     }
389 376
 
@@ -409,13 +396,11 @@  discard block
 block discarded – undo
409 396
             if (in_array(self::$channel_id,self::$ids[$category])) {
410 397
                 self::$channel = self::read($category . '/' . self::$channel_id);
411 398
                 self::$old_channel = clone self::$channel;
412
-            }
413
-            else {
399
+            } else {
414 400
                 self::$ids[$category][] = self::$channel_id;
415 401
                 self::$channel = (object) self::$channel_default_data;
416 402
             }
417
-        }
418
-        else {
403
+        } else {
419 404
             $chat_id = $update->chat->id;
420 405
             $by_id = $update->from->id;
421 406
             $old_user = $update->old_chat_member;
@@ -431,22 +416,19 @@  discard block
 block discarded – undo
431 416
                     self::$old_supergroup = clone self::$supergroup;
432 417
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
433 418
                     self::$old_group_ids = clone self::$group_ids;
434
-                }
435
-                else {
419
+                } else {
436 420
                     self::$ids[$category][] = $chat_id;
437 421
                     self::$supergroup = (object) self::$supergroup_default_data;
438 422
                     self::$group_ids = [];
439 423
                 }
440
-            }
441
-            elseif ($type === chatType::GROUP) {
424
+            } elseif ($type === chatType::GROUP) {
442 425
                 self::$group_id = $chat_id;
443 426
                 if (in_array($chat_id,self::$ids[$category])) {
444 427
                     self::$group = self::read($category . '/' . $chat_id);
445 428
                     self::$old_group = clone self::$group;
446 429
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
447 430
                     self::$old_group_ids = clone self::$group_ids;
448
-                }
449
-                else {
431
+                } else {
450 432
                     self::$ids[$category][] = $chat_id;
451 433
                     self::$group = (object) self::$group_default_data;
452 434
                     self::$group_ids = [];
@@ -456,8 +438,7 @@  discard block
 block discarded – undo
456 438
             if (!in_array($user_id,self::$group_ids)) {
457 439
                 self::$group_ids[] = $user_id;
458 440
                 self::$group_user = (object) self::$group_user_default_data;
459
-            }
460
-            else {
441
+            } else {
461 442
                 self::$group_user_id = $by_id == $user_id ? $user_id : $by_id;
462 443
                 self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id);
463 444
             }
@@ -470,8 +451,7 @@  discard block
 block discarded – undo
470 451
                         self::$group_user->removed_by = $by_id;
471 452
                     }
472 453
                 }
473
-            }
474
-            elseif ($old_user->status === chatMemberStatus::LEFT || $old_user->status === chatMemberStatus::KICKED) {
454
+            } elseif ($old_user->status === chatMemberStatus::LEFT || $old_user->status === chatMemberStatus::KICKED) {
475 455
                 self::$group_user->presence = true;
476 456
                 self::$group_user->removed = false;
477 457
                 self::$group_user->removed_by = null;
@@ -480,8 +460,7 @@  discard block
 block discarded – undo
480 460
                     if (!empty($invite_link)) {
481 461
                         self::$group_user->accepted_by = $by_id;
482 462
                         self::$group_user->invited_by = null;
483
-                    }
484
-                    else {
463
+                    } else {
485 464
                         self::$group_user->invited_by = $by_id;
486 465
                         self::$group_user->accepted_by = null;
487 466
                     }
@@ -499,7 +478,9 @@  discard block
 block discarded – undo
499 478
      * @throws bptException
500 479
      */
501 480
     public static function deleteUser (int $user_id = null): bool {
502
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
481
+        if (empty($user_id)) {
482
+            $user_id = telegram::catchFields(fields::USER_ID);
483
+        }
503 484
         if (!file_exists(realpath(self::$folder . '/privates/' . $user_id . '.json'))) {
504 485
             return false;
505 486
         }
@@ -520,7 +501,9 @@  discard block
 block discarded – undo
520 501
      * @throws bptException
521 502
      */
522 503
     public static function deleteGroup (int $group_id = null): bool {
523
-        if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
504
+        if (empty($group_id)) {
505
+            $group_id = telegram::catchFields(fields::CHAT_ID);
506
+        }
524 507
         if (!file_exists(realpath(self::$folder . '/groups/' . $group_id . '.json'))) {
525 508
             return false;
526 509
         }
@@ -542,7 +525,9 @@  discard block
 block discarded – undo
542 525
      * @throws bptException
543 526
      */
544 527
     public static function deleteSuperGroup (int $group_id = null): bool {
545
-        if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
528
+        if (empty($group_id)) {
529
+            $group_id = telegram::catchFields(fields::CHAT_ID);
530
+        }
546 531
         if (!file_exists(realpath(self::$folder . '/supergroups/' . $group_id . '.json'))) {
547 532
             return false;
548 533
         }
@@ -564,7 +549,9 @@  discard block
 block discarded – undo
564 549
      * @throws bptException
565 550
      */
566 551
     public static function deleteChannel (int $channel_id = null): bool {
567
-        if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID);
552
+        if (empty($channel_id)) {
553
+            $channel_id = telegram::catchFields(fields::CHAT_ID);
554
+        }
568 555
         if (!file_exists(realpath(self::$folder . '/channels/' . $channel_id . '.json'))) {
569 556
             return false;
570 557
         }
Please login to merge, or discard this patch.
src/types/types.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,23 +22,19 @@  discard block
 block discarded – undo
22 22
         foreach ($object as $key=>$value) {
23 23
             if (isset($subs[$key])) {
24 24
                 $this->{$key} = new ($subs[$key]) ($value);
25
-            }
26
-            elseif (is_array($value) && isset($subs['array'])) {
25
+            } elseif (is_array($value) && isset($subs['array'])) {
27 26
                 foreach ($value as $sub_key => $sub_value) {
28 27
                     if (is_array($sub_value) && isset($subs['array']['array'])) {
29 28
                         foreach ($sub_value as $sub2_value) {
30 29
                             $this->{$key}[$sub_key][] = new ($subs['array']['array'][$key]) ($sub2_value);
31 30
                         }
32
-                    }
33
-                    elseif (isset($subs['array'][$key])) {
31
+                    } elseif (isset($subs['array'][$key])) {
34 32
                         $this->{$key}[] = new ($subs['array'][$key]) ($sub_value);
35
-                    }
36
-                    else {
33
+                    } else {
37 34
                         $this->{$key}[] = $sub_value;
38 35
                     }
39 36
                 }
40
-            }
41
-            else {
37
+            } else {
42 38
                 $this->{$key} = $value;
43 39
                 if (ucfirst($key) === basename(get_class($this)) . '_id') {
44 40
                     $this->{'id'} = $value;
@@ -53,8 +49,7 @@  discard block
 block discarded – undo
53 49
             $name = substr($name,3);
54 50
             if (isset($arguments[0])) {
55 51
                 $this->{$name} = $arguments[0];
56
-            }
57
-            elseif (isset($arguments['value'])) {
52
+            } elseif (isset($arguments['value'])) {
58 53
                 $this->{$name} = $arguments['value'];
59 54
             }
60 55
         }
Please login to merge, or discard this patch.
src/tools/tools.php 1 patch
Braces   +29 added lines, -22 removed lines patch added patch discarded remove patch
@@ -219,8 +219,9 @@  discard block
 block discarded – undo
219 219
             if (telegram::$status) {
220 220
                 $check = $check->status;
221 221
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
222
+            } else {
223
+                $result[$id] = null;
222 224
             }
223
-            else $result[$id] = null;
224 225
         }
225 226
         return $result;
226 227
     }
@@ -262,8 +263,7 @@  discard block
 block discarded – undo
262 263
             curl_exec($ch);
263 264
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
264 265
             curl_close($ch);
265
-        }
266
-        else {
266
+        } else {
267 267
             $path = realpath($path);
268 268
             $size = file_exists($path) ? filesize($path) : false;
269 269
         }
@@ -353,9 +353,13 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool {
355 355
         $file = fopen($url, 'rb');
356
-        if (!$file) return false;
356
+        if (!$file) {
357
+            return false;
358
+        }
357 359
         $path = fopen($path, 'wb');
358
-        if (!$path) return false;
360
+        if (!$path) {
361
+            return false;
362
+        }
359 363
 
360 364
         $length = $chunk_size * 1024;
361 365
         while (!feof($file)){
@@ -462,8 +466,9 @@  discard block
 block discarded – undo
462 466
         foreach ($string as $k => &$v) {
463 467
             if ($diff->{$v}) {
464 468
                 $v = $diff->{$v};
469
+            } else {
470
+                unset($string[$k]);
465 471
             }
466
-            else unset($string[$k]);
467 472
         }
468 473
         $string['status'] = $base_time < $target_time ? 'later' : 'ago';
469 474
 
@@ -529,8 +534,7 @@  discard block
 block discarded – undo
529 534
             if ($last === "\0") {
530 535
                 $new .= str_repeat($last, ord($char));
531 536
                 $last = '';
532
-            }
533
-            else {
537
+            } else {
534 538
                 $new .= $last;
535 539
                 $last = $char;
536 540
             }
@@ -614,7 +618,9 @@  discard block
 block discarded – undo
614 618
             }
615 619
             $rows = [];
616 620
             foreach ($keyboard as $row) {
617
-                if (!is_array($row)) continue;
621
+                if (!is_array($row)) {
622
+                    continue;
623
+                }
618 624
                 $buttons = [];
619 625
                 foreach ($row as $base_button) {
620 626
                     $button_info = explode('||', $base_button);
@@ -623,15 +629,12 @@  discard block
 block discarded – undo
623 629
                     if (count($button_info) > 1) {
624 630
                         if ($button_info[1] === 'con') {
625 631
                             $button->setRequest_contact(true);
626
-                        }
627
-                        elseif ($button_info[1] === 'loc') {
632
+                        } elseif ($button_info[1] === 'loc') {
628 633
                             $button->setRequest_location(true);
629
-                        }
630
-                        elseif ($button_info[1] === 'poll') {
634
+                        } elseif ($button_info[1] === 'poll') {
631 635
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
632 636
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
633
-                        }
634
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
637
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
635 638
                             $url = $button_info[2];
636 639
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
637 640
                         }
@@ -654,12 +657,10 @@  discard block
 block discarded – undo
654 657
                     if (isset($button_info[1])) {
655 658
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
656 659
                             $button->setUrl($button_info[1]);
657
-                        }
658
-                        else {
660
+                        } else {
659 661
                             $button->setCallback_data($button_info[1]);
660 662
                         }
661
-                    }
662
-                    else {
663
+                    } else {
663 664
                         $button->setUrl('https://t.me/BPT_CH');
664 665
                     }
665 666
                     $buttons[] = $button;
@@ -686,8 +687,12 @@  discard block
 block discarded – undo
686 687
      * @return string
687 688
      */
688 689
     public static function inviteLink (int $user_id = null, string $bot_username = null): string {
689
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
690
-        if (empty($bot_username)) $bot_username = telegram::getMe()->username;
690
+        if (empty($user_id)) {
691
+            $user_id = telegram::catchFields(fields::USER_ID);
692
+        }
693
+        if (empty($bot_username)) {
694
+            $bot_username = telegram::getMe()->username;
695
+        }
691 696
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
692 697
     }
693 698
 
@@ -756,7 +761,9 @@  discard block
 block discarded – undo
756 761
             $array[] = $num % 62;
757 762
             $num = floor($num / 62);
758 763
         }
759
-        if (count($array) < 1) $array = [0];
764
+        if (count($array) < 1) {
765
+            $array = [0];
766
+        }
760 767
         foreach ($array as &$value) {
761 768
             $value = $codes[$value];
762 769
         }
Please login to merge, or discard this patch.
src/telegram/request.php 1 patch
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -881,20 +881,17 @@  discard block
 block discarded – undo
881 881
             foreach ($arguments['media'] as $key => $media) {
882 882
                 if ($media['media'] instanceof CURLFile) {
883 883
                     $remove_answer = true;
884
-                }
885
-                elseif (is_string($media['media']) && file_exists(realpath($media['media']))) {
884
+                } elseif (is_string($media['media']) && file_exists(realpath($media['media']))) {
886 885
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
887 886
                     $remove_answer = true;
888 887
                 }
889 888
             }
890
-        }
891
-        elseif ($file_params = self::methodFile($name)) {
889
+        } elseif ($file_params = self::methodFile($name)) {
892 890
             foreach ($file_params as $param) {
893 891
                 if (isset($arguments[$param])) {
894 892
                     if ($arguments[$param] instanceof CURLFile) {
895 893
                         $remove_answer = true;
896
-                    }
897
-                    elseif (is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) {
894
+                    } elseif (is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) {
898 895
                         $arguments[$param] = new CURLFile($arguments[$param]);
899 896
                         $remove_answer = true;
900 897
                     }
@@ -937,8 +934,7 @@  discard block
 block discarded – undo
937 934
                 if (!isset($arguments[$default])){
938 935
                     $arguments[$default] = self::catchFields($default);
939 936
                 }
940
-            }
941
-            elseif (isset(BPT::$update->{$key}) || $key === 'other') {
937
+            } elseif (isset(BPT::$update->{$key}) || $key === 'other') {
942 938
                 foreach ($default as $def) {
943 939
                     if (!isset($arguments[$def])){
944 940
                         $arguments[$def] = self::catchFields($def);
@@ -1010,9 +1006,13 @@  discard block
 block discarded – undo
1010 1006
                     default => false
1011 1007
                 };
1012 1008
             case fields::FILE_ID :
1013
-                if (isset(BPT::$update->message)) $type = 'message';
1014
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
1015
-                else return false;
1009
+                if (isset(BPT::$update->message)) {
1010
+                    $type = 'message';
1011
+                } elseif (isset(BPT::$update->edited_message)) {
1012
+                    $type = 'edited_message';
1013
+                } else {
1014
+                    return false;
1015
+                }
1016 1016
 
1017 1017
                 return match(true) {
1018 1018
                     isset(BPT::$update->{$type}->animation) => BPT::$update->{$type}->animation->file_id,
Please login to merge, or discard this patch.