Passed
Push — main ( cb0dfb...09414e )
by Miaad
10:52
created
src/receiver/receiver.php 1 patch
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -97,51 +97,41 @@
 block discarded – undo
97 97
             if (self::handlerExist('message')) {
98 98
                 BPT::$handler->message(BPT::$update->message);
99 99
             }
100
-        }
101
-        elseif (isset(BPT::$update->edited_message)) {
100
+        } elseif (isset(BPT::$update->edited_message)) {
102 101
             if (self::handlerExist('edited_message')) {
103 102
                 BPT::$handler->edited_message(BPT::$update->edited_message);
104 103
             }
105
-        }
106
-        elseif (isset(BPT::$update->channel_post)) {
104
+        } elseif (isset(BPT::$update->channel_post)) {
107 105
             if (self::handlerExist('channel_post')) {
108 106
                 BPT::$handler->channel_post(BPT::$update->channel_post);
109 107
             }
110
-        }
111
-        elseif (isset(BPT::$update->edited_channel_post)) {
108
+        } elseif (isset(BPT::$update->edited_channel_post)) {
112 109
             if (self::handlerExist('edited_channel_post')) {
113 110
                 BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post);
114 111
             }
115
-        }
116
-        elseif (isset(BPT::$update->inline_query)) {
112
+        } elseif (isset(BPT::$update->inline_query)) {
117 113
             if (self::handlerExist('inline_query')) {
118 114
                 BPT::$handler->inline_query(BPT::$update->inline_query);
119 115
             }
120
-        }
121
-        elseif (isset(BPT::$update->callback_query)) {
116
+        } elseif (isset(BPT::$update->callback_query)) {
122 117
             if (self::handlerExist('callback_query')) {
123 118
                 BPT::$handler->callback_query(BPT::$update->callback_query);
124 119
             }
125
-        }
126
-        elseif (isset(BPT::$update->my_chat_member)) {
120
+        } elseif (isset(BPT::$update->my_chat_member)) {
127 121
             if (self::handlerExist('my_chat_member')) {
128 122
                 BPT::$handler->my_chat_member(BPT::$update->my_chat_member);
129 123
             }
130
-        }
131
-        elseif (isset(BPT::$update->chat_member)) {
124
+        } elseif (isset(BPT::$update->chat_member)) {
132 125
             if (self::handlerExist('chat_member')) {
133 126
                 BPT::$handler->chat_member(BPT::$update->chat_member);
134 127
             }
135
-        }
136
-        elseif (isset(BPT::$update->chat_join_request)) {
128
+        } elseif (isset(BPT::$update->chat_join_request)) {
137 129
             if (self::handlerExist('chat_join_request')) {
138 130
                 BPT::$handler->chat_join_request(BPT::$update->chat_join_request);
139 131
             }
140
-        }
141
-        elseif (self::handlerExist('something_else')) {
132
+        } elseif (self::handlerExist('something_else')) {
142 133
             BPT::$handler->something_else(BPT::$update);
143
-        }
144
-        else {
134
+        } else {
145 135
             logger::write('Update received but handlers are not set',loggerTypes::WARNING);
146 136
         }
147 137
     }
Please login to merge, or discard this patch.
src/tools/tools.php 1 patch
Braces   +30 added lines, -24 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
                         }
@@ -652,12 +654,10 @@  discard block
 block discarded – undo
652 654
                     if (isset($button_info[1])) {
653 655
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
654 656
                             $button->setText($button_info[0])->setUrl($button_info[1]);
655
-                        }
656
-                        else {
657
+                        } else {
657 658
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
658 659
                         }
659
-                    }
660
-                    else {
660
+                    } else {
661 661
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
662 662
                     }
663 663
                     $buttons[] = $button;
@@ -684,8 +684,12 @@  discard block
 block discarded – undo
684 684
      * @return string
685 685
      */
686 686
     public static function inviteLink (int $user_id = null, string $bot_username = null): string {
687
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
688
-        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
+        }
689 693
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
690 694
     }
691 695
 
@@ -752,7 +756,9 @@  discard block
 block discarded – undo
752 756
             $array[] = $num % 62;
753 757
             $num = floor($num / 62);
754 758
         }
755
-        if (count($array) < 1) $array = [0];
759
+        if (count($array) < 1) {
760
+            $array = [0];
761
+        }
756 762
         foreach ($array as &$value) {
757 763
             $value = $codes[$value];
758 764
         }
Please login to merge, or discard this patch.
src/tools/cpanel.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@
 block discarded – undo
85 85
         $create_user = self::createMysqlUser($user, $password);
86 86
         if (empty($privileges)) {
87 87
             $set_privileges = self::setMysqlPrivilegesAll($database, $user);
88
-        }
89
-        else {
88
+        } else {
90 89
             $set_privileges = self::setMysqlPrivileges($database, $user, $privileges);
91 90
         }
92 91
         return [
Please login to merge, or discard this patch.
examples/wallet/bot.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (file_exists('vendor/autoload.php')) {
13 13
     require 'vendor/autoload.php';
14
-}
15
-else {
14
+} else {
16 15
     if (!file_exists('BPT.phar')) {
17 16
         copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar');
18 17
     }
@@ -174,14 +173,12 @@  discard block
 block discarded – undo
174 173
             }
175 174
             if (isset($update->user_shared)) {
176 175
                 $target_id = $update->user_shared->user_id;
177
-            }
178
-            elseif (isset($update->forward_date)) {
176
+            } elseif (isset($update->forward_date)) {
179 177
                 if (!isset($update->forward_from)) {
180 178
                     return $this->sendMessage(texts::USER_FORWARD_CLOSED, answer: true);
181 179
                 }
182 180
                 $target_id = $update->forward_from->id;
183
-            }
184
-            else {
181
+            } else {
185 182
                 if (!is_numeric($text) || $text != floor($text)) {
186 183
                     return $this->sendMessage(texts::ONLY_INT, answer: true);
187 184
                 }
Please login to merge, or discard this patch.
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.