Passed
Push — main ( ca9ae3...e465fe )
by Miaad
10:35
created
src/receiver/webhook.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
     public static function init () {
23 23
         if (settings::$multi) {
24 24
             multi::init();
25
-        }
26
-        else {
25
+        } else {
27 26
             if (!lock::exist('BPT-HOOK')) {
28 27
                 self::processSetWebhook();
29 28
             }
@@ -108,11 +107,9 @@  discard block
 block discarded – undo
108 107
         ignore_user_abort(true);
109 108
         if (function_exists('fastcgi_finish_request')) {
110 109
             fastcgi_finish_request();
111
-        }
112
-        elseif (function_exists('litespeed_finish_request')) {
110
+        } elseif (function_exists('litespeed_finish_request')) {
113 111
             litespeed_finish_request();
114
-        }
115
-        else {
112
+        } else {
116 113
             return false;
117 114
         }
118 115
 
Please login to merge, or discard this patch.
src/pay/idpay.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,11 +92,9 @@
 block discarded – undo
92 92
     public static function processCallback (): bool|int {
93 93
         if ($_SERVER['REQUEST_METHOD'] === 'POST') {
94 94
             $response = $_POST;
95
-        }
96
-        elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
95
+        } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
97 96
             $response = $_GET;
98
-        }
99
-        else {
97
+        } else {
100 98
             return false;
101 99
         }
102 100
 
Please login to merge, or discard this patch.
src/pay/zarinpal.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@
 block discarded – undo
43 43
     private static function getUrl (string $endpoint, bool $pay = false): string {
44 44
         if ($pay) {
45 45
             $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE;
46
-        }
47
-        else {
46
+        } else {
48 47
             $url = self::$sandbox ? self::SANDBOX_API_BASE : self::API_BASE;
49 48
         }
50 49
         $url .= $endpoint;
Please login to merge, or discard this patch.
src/database/mysql.php 1 patch
Braces   +20 added lines, -27 removed lines patch added patch discarded remove patch
@@ -72,17 +72,13 @@  discard block
 block discarded – undo
72 72
         if (self::$auto_process) {
73 73
             if (isset(BPT::$update->message)) {
74 74
                 self::processMessage(BPT::$update->message);
75
-            }
76
-            elseif (isset(BPT::$update->edited_message)) {
75
+            } elseif (isset(BPT::$update->edited_message)) {
77 76
                 self::processMessage(BPT::$update->edited_message);
78
-            }
79
-            elseif (isset(BPT::$update->callback_query)) {
77
+            } elseif (isset(BPT::$update->callback_query)) {
80 78
                 self::processCallbackQuery(BPT::$update->callback_query);
81
-            }
82
-            elseif (isset(BPT::$update->inline_query)) {
79
+            } elseif (isset(BPT::$update->inline_query)) {
83 80
                 self::processInlineQuery(BPT::$update->inline_query);
84
-            }
85
-            elseif (isset(BPT::$update->my_chat_member)) {
81
+            } elseif (isset(BPT::$update->my_chat_member)) {
86 82
                 self::processMyChatMember(BPT::$update->my_chat_member);
87 83
             }
88 84
         }
@@ -139,8 +135,7 @@  discard block
 block discarded – undo
139 135
         if ($type === chatType::PRIVATE) {
140 136
             if ($update->new_chat_member->status === chatMemberStatus::MEMBER) {
141 137
                 self::update('users', ['blocked' => false], ['id' => $update->from->id], 1);
142
-            }
143
-            else {
138
+            } else {
144 139
                 self::update('users', ['blocked' => true], ['id' => $update->from->id], 1);
145 140
             }
146 141
         }
@@ -280,11 +275,9 @@  discard block
 block discarded – undo
280 275
         foreach ($vars as $var) {
281 276
             if (is_int($var)) {
282 277
                 $types .= 'i';
283
-            }
284
-            elseif (is_double($var)) {
278
+            } elseif (is_double($var)) {
285 279
                 $types .= 'd';
286
-            }
287
-            else {
280
+            } else {
288 281
                 $types .= 's';
289 282
             }
290 283
         }
@@ -308,8 +301,7 @@  discard block
 block discarded – undo
308 301
         foreach ($where as $name => $value) {
309 302
             if ($first) {
310 303
                 $first = false;
311
-            }
312
-            else {
304
+            } else {
313 305
                 $query .= ' AND';
314 306
             }
315 307
 
@@ -375,8 +367,7 @@  discard block
 block discarded – undo
375 367
         foreach ($order_by as $key => $mode) {
376 368
             if ($first) {
377 369
                 $first = false;
378
-            }
379
-            else {
370
+            } else {
380 371
                 $query .= ', ';
381 372
             }
382 373
             if (is_numeric($key)) {
@@ -390,8 +381,7 @@  discard block
 block discarded – undo
390 381
     private static function countBuilder(string &$query, int $count = null, int $offset = null): void {
391 382
         if (!empty($count)) {
392 383
             $query .= !empty($offset) ? " LIMIT $offset,$count" : " LIMIT $count";
393
-        }
394
-        elseif (!empty($offset)) {
384
+        } elseif (!empty($offset)) {
395 385
             $query .= " OFFSET $offset";
396 386
         }
397 387
     }
@@ -403,8 +393,7 @@  discard block
 block discarded – undo
403 393
         foreach ($modify as $name => $value) {
404 394
             if ($first) {
405 395
                 $first = false;
406
-            }
407
-            else {
396
+            } else {
408 397
                 $query .= ' ,';
409 398
             }
410 399
 
@@ -444,7 +433,9 @@  discard block
 block discarded – undo
444 433
 
445 434
     private static function insertBuilder(string &$query, string|array $columns, array|string $values): array {
446 435
         $query .= '(`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES (';
447
-        if (is_string($values)) $values = [$values];
436
+        if (is_string($values)) {
437
+            $values = [$values];
438
+        }
448 439
         $query .= '?' . str_repeat(',?', count($values) - 1) . ')';
449 440
         return $values;
450 441
     }
@@ -452,8 +443,7 @@  discard block
 block discarded – undo
452 443
     private static function selectBuilder(string &$query, string|array $columns): void {
453 444
         if ($columns == '*') {
454 445
             $query .= " * ";
455
-        }
456
-        else {
446
+        } else {
457 447
             $query .= ' `' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` ';
458 448
         }
459 449
     }
@@ -601,9 +591,12 @@  discard block
 block discarded – undo
601 591
     public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = []): bool|Generator {
602 592
         $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by);
603 593
         if ($res) {
604
-            while ($row = $res->fetch_assoc()) yield $row;
594
+            while ($row = $res->fetch_assoc()) {
595
+                yield $row;
596
+            }
597
+        } else {
598
+            return $res;
605 599
         }
606
-        else return $res;
607 600
     }
608 601
 
609 602
     /**
Please login to merge, or discard this patch.
src/tools.php 1 patch
Braces   +34 added lines, -32 removed lines patch added patch discarded remove patch
@@ -217,8 +217,9 @@  discard block
 block discarded – undo
217 217
             if (telegram::$status) {
218 218
                 $check = $check->status;
219 219
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
220
+            } else {
221
+                $result[$id] = null;
220 222
             }
221
-            else $result[$id] = null;
222 223
         }
223 224
         return $result;
224 225
     }
@@ -260,8 +261,7 @@  discard block
 block discarded – undo
260 261
             curl_exec($ch);
261 262
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
262 263
             curl_close($ch);
263
-        }
264
-        else {
264
+        } else {
265 265
             $path = realpath($path);
266 266
             $size = file_exists($path) ? filesize($path) : false;
267 267
         }
@@ -332,8 +332,7 @@  discard block
 block discarded – undo
332 332
                     $zip->addFile($filePath, substr($filePath, $root_len));
333 333
                 }
334 334
             }
335
-        }
336
-        else {
335
+        } else {
337 336
             $zip->addFile($path, basename($path));
338 337
         }
339 338
         return $zip->close();
@@ -352,9 +351,13 @@  discard block
 block discarded – undo
352 351
      */
353 352
     public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool {
354 353
         $file = fopen($url, 'rb');
355
-        if (!$file) return false;
354
+        if (!$file) {
355
+            return false;
356
+        }
356 357
         $path = fopen($path, 'wb');
357
-        if (!$path) return false;
358
+        if (!$path) {
359
+            return false;
360
+        }
358 361
 
359 362
         $length = $chunk_size * 1024;
360 363
         while (!feof($file)){
@@ -461,8 +464,9 @@  discard block
 block discarded – undo
461 464
         foreach ($string as $k => &$v) {
462 465
             if ($diff->$v) {
463 466
                 $v = $diff->$v;
467
+            } else {
468
+                unset($string[$k]);
464 469
             }
465
-            else unset($string[$k]);
466 470
         }
467 471
         $string['status'] = $base_time < $target_time ? 'later' : 'ago';
468 472
 
@@ -528,8 +532,7 @@  discard block
 block discarded – undo
528 532
             if ($last === "\0") {
529 533
                 $new .= str_repeat($last, ord($char));
530 534
                 $last = '';
531
-            }
532
-            else {
535
+            } else {
533 536
                 $new .= $last;
534 537
                 $last = $char;
535 538
             }
@@ -613,7 +616,9 @@  discard block
 block discarded – undo
613 616
             }
614 617
             $rows = [];
615 618
             foreach ($keyboard as $row) {
616
-                if (!is_array($row)) continue;
619
+                if (!is_array($row)) {
620
+                    continue;
621
+                }
617 622
                 $buttons = [];
618 623
                 foreach ($row as $base_button) {
619 624
                     $button_info = explode('||', $base_button);
@@ -622,15 +627,12 @@  discard block
 block discarded – undo
622 627
                     if (count($button_info) > 1) {
623 628
                         if ($button_info[1] === 'con') {
624 629
                             $button->setRequest_contact(true);
625
-                        }
626
-                        elseif ($button_info[1] === 'loc') {
630
+                        } elseif ($button_info[1] === 'loc') {
627 631
                             $button->setRequest_location(true);
628
-                        }
629
-                        elseif ($button_info[1] === 'poll') {
632
+                        } elseif ($button_info[1] === 'poll') {
630 633
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
631 634
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
632
-                        }
633
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
635
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
634 636
                             $url = $button_info[2];
635 637
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
636 638
                         }
@@ -641,8 +643,7 @@  discard block
 block discarded – undo
641 643
             }
642 644
             $keyboard_object->setKeyboard($rows);
643 645
             return $keyboard_object;
644
-        }
645
-        elseif (!empty($inline)) {
646
+        } elseif (!empty($inline)) {
646 647
             $keyboard_object = new inlineKeyboardMarkup();
647 648
             $rows = [];
648 649
             foreach ($inline as $row) {
@@ -652,12 +653,10 @@  discard block
 block discarded – undo
652 653
                     if (isset($button_info[1])) {
653 654
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
654 655
                             $button->setText($button_info[0])->setUrl($button_info[1]);
655
-                        }
656
-                        else {
656
+                        } else {
657 657
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
658 658
                         }
659
-                    }
660
-                    else {
659
+                    } else {
661 660
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
662 661
                     }
663 662
                     $buttons[] = $button;
@@ -666,8 +665,7 @@  discard block
 block discarded – undo
666 665
             }
667 666
             $keyboard_object->setInline_keyboard($rows);
668 667
             return $keyboard_object;
669
-        }
670
-        else {
668
+        } else {
671 669
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
672 670
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
673 671
         }
@@ -686,8 +684,12 @@  discard block
 block discarded – undo
686 684
      * @return string
687 685
      */
688 686
     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;
687
+        if (empty($user_id)) {
688
+            $user_id = telegram::catchFields(fields::USER_ID);
689
+        }
690
+        if (empty($bot_username)) {
691
+            $bot_username = telegram::getMe()->username;
692
+        }
691 693
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
692 694
     }
693 695
 
@@ -722,8 +724,7 @@  discard block
 block discarded – undo
722 724
             $iv = self::randomString();
723 725
             $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv));
724 726
             return ['hash' => $output, 'key' => $key, 'iv' => $iv];
725
-        }
726
-        elseif ($action === codecAction::DECRYPT) {
727
+        } elseif ($action === codecAction::DECRYPT) {
727 728
             if (empty($key)) {
728 729
                 logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR);
729 730
                 throw new bptException('ARGUMENT_NOT_FOUND_KEY');
@@ -733,8 +734,7 @@  discard block
 block discarded – undo
733 734
                 throw new bptException('ARGUMENT_NOT_FOUND_IV');
734 735
             }
735 736
             return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
736
-        }
737
-        else {
737
+        } else {
738 738
             logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
739 739
             return false;
740 740
         }
@@ -756,7 +756,9 @@  discard block
 block discarded – undo
756 756
             $array[] = $num % 62;
757 757
             $num = floor($num / 62);
758 758
         }
759
-        if (count($array) < 1) $array = [0];
759
+        if (count($array) < 1) {
760
+            $array = [0];
761
+        }
760 762
         foreach ($array as &$value) {
761 763
             $value = $codes[$value];
762 764
         }
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
@@ -862,20 +862,17 @@  discard block
 block discarded – undo
862 862
             foreach ($arguments['media'] as $key => $media) {
863 863
                 if ($media['media'] instanceof CURLFile) {
864 864
                     $remove_answer = true;
865
-                }
866
-                elseif (is_string($media['media']) && file_exists(realpath($media['media']))) {
865
+                } elseif (is_string($media['media']) && file_exists(realpath($media['media']))) {
867 866
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
868 867
                     $remove_answer = true;
869 868
                 }
870 869
             }
871
-        }
872
-        elseif ($file_params = self::methodFile($name)) {
870
+        } elseif ($file_params = self::methodFile($name)) {
873 871
             foreach ($file_params as $param) {
874 872
                 if (isset($arguments[$param])) {
875 873
                     if ($arguments[$param] instanceof CURLFile) {
876 874
                         $remove_answer = true;
877
-                    }
878
-                    elseif (is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) {
875
+                    } elseif (is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) {
879 876
                         $arguments[$param] = new CURLFile($arguments[$param]);
880 877
                         $remove_answer = true;
881 878
                     }
@@ -915,8 +912,7 @@  discard block
 block discarded – undo
915 912
                 if (!isset($arguments[$default])){
916 913
                     $arguments[$default] = self::catchFields($default);
917 914
                 }
918
-            }
919
-            elseif (isset(BPT::$update->$key) || $key === 'other') {
915
+            } elseif (isset(BPT::$update->$key) || $key === 'other') {
920 916
                 foreach ($default as $def) {
921 917
                     if (!isset($arguments[$def])){
922 918
                         $arguments[$def] = self::catchFields($def);
@@ -987,9 +983,13 @@  discard block
 block discarded – undo
987 983
                     default => false
988 984
                 };
989 985
             case fields::FILE_ID :
990
-                if (isset(BPT::$update->message)) $type = 'message';
991
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
992
-                else return false;
986
+                if (isset(BPT::$update->message)) {
987
+                    $type = 'message';
988
+                } elseif (isset(BPT::$update->edited_message)) {
989
+                    $type = 'edited_message';
990
+                } else {
991
+                    return false;
992
+                }
993 993
 
994 994
                 return match(true) {
995 995
                     isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id,
Please login to merge, or discard this patch.