@@ -22,8 +22,7 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -92,11 +92,9 @@ |
||
| 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 | |
@@ -43,8 +43,7 @@ |
||
| 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; |
@@ -72,17 +72,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | /** |