Passed
Push — main ( fe7ef9...03f6f3 )
by Miaad
10:51
created
src/receiver/multi/exec.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @internal Only for BPT self usage , Don't use it in your source!
19 19
      */
20
-    public static function init(): string|null {
20
+    public static function init(): string | null {
21 21
         return self::getUpdate();
22 22
     }
23 23
 
24
-    private static function getUpdate (): string|null {
24
+    private static function getUpdate(): string | null {
25 25
         $up = glob('*.update');
26 26
         if (!isset($up[0])) {
27
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
27
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
28 28
             BPT::exit();
29 29
         }
30 30
         $up = end($up);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 
56 56
     private static function create($file) {
57
-        file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php ' . $file . ' > /dev/null &");');
57
+        file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php '.$file.' > /dev/null &");');
58 58
     }
59 59
 
60 60
     #[ArrayShape(['url' => "array|string|string[]", 'file' => "string"])]
Please login to merge, or discard this patch.
src/receiver/multi/curl.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * curl class , for multiprocessing with curl tricks
15 15
  */
16 16
 class curl extends webhook {
17
-    public static function init (): string|null {
17
+    public static function init(): string | null {
18 18
         if (!self::checkIP()) {
19
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
19
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
20 20
             BPT::exit();
21 21
         }
22 22
         return self::getUpdate();
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR'];
27 27
     }
28 28
 
29
-    private static function getUpdate (): string {
29
+    private static function getUpdate(): string {
30 30
         $input = json_decode(file_get_contents("php://input"), true);
31 31
         webhook::telegramVerify($input['ip']);
32 32
         return $input['update'];
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
         lock::set('BPT-MULTI-CURL');
44 44
     }
45 45
 
46
-    private static function getTimeout($url): float|int {
46
+    private static function getTimeout($url): float | int {
47 47
         $times = [];
48
-        for ($i = 0; $i < 10; $i ++) {
48
+        for ($i = 0; $i < 10; $i++) {
49 49
             $ch = curl_init($url);
50 50
             curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([]), CURLOPT_TIMEOUT_MS => 100, CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => 100, CURLOPT_HTTPHEADER => ['accept: application/json', 'content-type: application/json']]);
51 51
             $start = microtime(true);
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
         return $timeout > 50 ? $timeout + 10 : 50;
57 57
     }
58 58
 
59
-    private static function create($file,$timeout) {
60
-        file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\'' . $file . '\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => ' . $timeout . ', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => ' . $timeout . ', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>');
59
+    private static function create($file, $timeout) {
60
+        file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\''.$file.'\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => '.$timeout.', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => '.$timeout.', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>');
61 61
     }
62 62
 
63 63
     #[ArrayShape(['url' => "array|string|string[]", 'file' => "array|string|string[]"])]
Please login to merge, or discard this patch.
src/receiver/webhook.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @internal Only for BPT self usage , Don't use it in your source!
21 21
      */
22
-    public static function init () {
22
+    public static function init() {
23 23
         if (settings::$multi) {
24 24
             multi::init();
25 25
         }
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
         lock::deleteIfExist(['BPT-MULTI-EXEC', 'BPT-MULTI-CURL', 'getUpdate', 'getUpdateHook']);
40 40
     }
41 41
 
42
-    protected static function setWebhook(string $url,string $secret = '') {
42
+    protected static function setWebhook(string $url, string $secret = '') {
43 43
         $res = BPT::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret);
44 44
         if (!BPT::$status) {
45
-            logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
46
-            BPT::exit(print_r($res,true));
45
+            logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR);
46
+            BPT::exit(print_r($res, true));
47 47
         }
48
-        logger::write('Webhook was set successfully',loggerTypes::INFO);
48
+        logger::write('Webhook was set successfully', loggerTypes::INFO);
49 49
     }
50 50
 
51 51
     protected static function checkURL() {
52 52
         if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
53
-            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR);
53
+            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR);
54 54
             throw new bptException('WEBHOOK_NEED_URL');
55 55
         }
56 56
     }
57 57
 
58 58
     protected static function setURL(): string {
59 59
         if (isset($_GET['token'])) {
60
-            logger::write("You can not specify token in url",loggerTypes::ERROR);
60
+            logger::write("You can not specify token in url", loggerTypes::ERROR);
61 61
             BPT::exit("You can not specify token in url");
62 62
         }
63
-        return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
63
+        return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
64 64
     }
65 65
 
66 66
     protected static function setCertificate() {
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
         self::checkURL();
76 76
         self::setCertificate();
77 77
         $url = self::setURL();
78
-        $secret = !empty(settings::$secret) ? settings::$secret : str_replace(':','---',settings::$token);
79
-        self::setWebhook($url,$secret);
78
+        $secret = !empty(settings::$secret) ? settings::$secret : str_replace(':', '---', settings::$token);
79
+        self::setWebhook($url, $secret);
80 80
         lock::save('BPT-HOOK', md5($secret));
81 81
         BPT::exit('Done');
82 82
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private static function checkSecret() {
85 85
         $secret_hash = lock::read('BPT-HOOK');
86 86
         if ($secret_hash !== md5(self::getSecret())) {
87
-            logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING);
87
+            logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING);
88 88
             self::processSetWebhook();
89 89
         }
90 90
     }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return bool
107 107
      */
108
-    public static function fastClose (int $timeout = 86400): bool {
108
+    public static function fastClose(int $timeout = 86400): bool {
109 109
         if (settings::$multi || !lock::exist('BPT-HOOK') || settings::$receiver !== \BPT\constants\receiver::WEBHOOK) {
110 110
             return false;
111 111
         }
Please login to merge, or discard this patch.
src/types/switchInlineQueryChosenChat.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     public bool $allow_channel_chats;
32 32
 
33 33
 
34
-    public function __construct(stdClass|null $object = null) {
34
+    public function __construct(stdClass | null $object = null) {
35 35
         if ($object != null) {
36 36
             parent::__construct($object, self::subs);
37 37
         }
Please login to merge, or discard this patch.
src/types/writeAccessAllowed.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /** Optional. Name of the Web App which was launched from a link */
16 16
     public string $web_app_name;
17 17
 
18
-    public function __construct(stdClass|null $object = null) {
18
+    public function __construct(stdClass | null $object = null) {
19 19
         if ($object != null) {
20 20
             parent::__construct($object, self::subs);
21 21
         }
Please login to merge, or discard this patch.
src/types/inputSticker.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL. More information on
20 20
      * Sending Files »
21 21
      */
22
-    public string|CURLFile $sticker;
22
+    public string | CURLFile $sticker;
23 23
 
24 24
     /**
25 25
      * List of 1-20 emoji associated with the sticker
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public array $keywords;
39 39
 
40 40
 
41
-    public function __construct(stdClass|null $object = null) {
41
+    public function __construct(stdClass | null $object = null) {
42 42
         if ($object != null) {
43 43
             parent::__construct($object, self::subs);
44 44
         }
Please login to merge, or discard this patch.
src/types/chatMemberUpdated.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public bool $via_chat_folder_invite_link;
45 45
 
46 46
 
47
-    public function __construct(stdClass|null $object = null) {
47
+    public function __construct(stdClass | null $object = null) {
48 48
         if ($object != null) {
49 49
             parent::__construct($object, self::subs);
50 50
         }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         return $this->chat->isPrivate() && $this->isMe() && $this->isKicked();
59 59
     }
60 60
 
61
-    public function isMe (): bool {
61
+    public function isMe(): bool {
62 62
         return $this->new_chat_member->user->id == settings::$bot_id;
63 63
     }
64 64
 
@@ -74,19 +74,19 @@  discard block
 block discarded – undo
74 74
         return $this->isJoined() && !empty($this->invite_link);
75 75
     }
76 76
 
77
-    public function isLeaved (): bool {
77
+    public function isLeaved(): bool {
78 78
         return $this->new_chat_member->status === chatMemberStatus::LEFT;
79 79
     }
80 80
 
81
-    public function isKicked (): bool {
81
+    public function isKicked(): bool {
82 82
         return $this->new_chat_member->status === chatMemberStatus::KICKED;
83 83
     }
84 84
 
85
-    public function isOldAdmin (): bool {
85
+    public function isOldAdmin(): bool {
86 86
         return $this->old_chat_member->status === chatMemberStatus::ADMINISTRATOR && $this->isJoined();
87 87
     }
88 88
 
89
-    public function isNewAdmin (): bool {
89
+    public function isNewAdmin(): bool {
90 90
         return $this->new_chat_member->status === chatMemberStatus::ADMINISTRATOR;
91 91
     }
92 92
 }
Please login to merge, or discard this patch.
src/types/sticker.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,25 +38,25 @@  discard block
 block discarded – undo
38 38
     public int $height;
39 39
 
40 40
     /** True, if the sticker is animated */
41
-    public null|bool $is_animated = null;
41
+    public null | bool $is_animated = null;
42 42
 
43 43
     /** True, if the sticker is a video sticker */
44
-    public null|bool $is_video = null;
44
+    public null | bool $is_video = null;
45 45
 
46 46
     /** Optional. Sticker thumbnail in the .WEBP or .JPG format */
47
-    public null|photoSize $thumbnail = null;
47
+    public null | photoSize $thumbnail = null;
48 48
 
49 49
     /** Optional. Emoji associated with the sticker */
50
-    public null|string $emoji = null;
50
+    public null | string $emoji = null;
51 51
 
52 52
     /** Optional. Name of the sticker set to which the sticker belongs */
53
-    public null|string $set_name = null;
53
+    public null | string $set_name = null;
54 54
 
55 55
     /** Optional. Premium animation for the sticker, if the sticker is premium */
56
-    public null|file $premium_animation = null;
56
+    public null | file $premium_animation = null;
57 57
 
58 58
     /** Optional. For mask stickers, the position where the mask should be placed */
59
-    public null|maskPosition $mask_position = null;
59
+    public null | maskPosition $mask_position = null;
60 60
 
61 61
     /** Optional. For custom emoji stickers, unique identifier of the custom emoji */
62 62
     public string $custom_emoji_id;
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
     public bool $needs_repainting;
69 69
 
70 70
     /** Optional. File size in bytes */
71
-    public null|int $file_size = null;
71
+    public null | int $file_size = null;
72 72
 
73 73
 
74
-    public function __construct(stdClass|null $object = null) {
74
+    public function __construct(stdClass | null $object = null) {
75 75
         if ($object != null) {
76 76
             parent::__construct($object, self::subs);
77 77
         }
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
      *
93 93
      * @return bool|string string will be returned when destination doesn't set
94 94
      */
95
-    public function download(string|null $destination = null): bool|string {
96
-        return telegram::downloadFile($destination ?? 'unknown.png',$this->file_id);
95
+    public function download(string | null $destination = null): bool | string {
96
+        return telegram::downloadFile($destination ?? 'unknown.png', $this->file_id);
97 97
     }
98 98
 
99 99
     public function link(): string {
Please login to merge, or discard this patch.
src/types/inlineQueryResultsButton.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     public string $start_parameter;
34 34
 
35 35
 
36
-    public function __construct(stdClass|null $object = null) {
36
+    public function __construct(stdClass | null $object = null) {
37 37
         if ($object != null) {
38 38
             parent::__construct($object, self::subs);
39 39
         }
Please login to merge, or discard this patch.