From 660462318825c6226a87d8292b958746f379e31c Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 4 Mar 2018 00:00:18 +0000 Subject: [PATCH] Apply fixes from StyleCI --- .../MadelineProto/MTProtoTools/PeerHandler.php | 7 ++++--- src/danog/MadelineProto/TL/Conversion/BotAPI.php | 16 ++++++++-------- src/danog/MadelineProto/TL/TLParams.php | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index 9f25aba2..fab9b2b0 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -18,16 +18,18 @@ namespace danog\MadelineProto\MTProtoTools; */ trait PeerHandler { - public function to_supergroup($id) { return -($id + pow(10, (int) floor(log($id, 10) + 3))); } + public function is_supergroup($id) { $log = log(-$id, 10); - return ($log-intval($log))*1000<10; + + return ($log - intval($log)) * 1000 < 10; } + public function add_users($users) { foreach ($users as $key => $user) { @@ -581,5 +583,4 @@ trait PeerHandler return false; } - } diff --git a/src/danog/MadelineProto/TL/Conversion/BotAPI.php b/src/danog/MadelineProto/TL/Conversion/BotAPI.php index 38cd0574..d34235ac 100644 --- a/src/danog/MadelineProto/TL/Conversion/BotAPI.php +++ b/src/danog/MadelineProto/TL/Conversion/BotAPI.php @@ -358,37 +358,37 @@ trait BotAPI case 'b': case 'strong': $text = $this->html_entity_decode($node->textContent); - + $length = $this->mb_strlen($text); $entities[] = ['_' => 'messageEntityBold', 'offset' => $offset, 'length' => $length]; - + $new_message .= $text; $offset += $length; break; case 'i': case 'em': $text = $this->html_entity_decode($node->textContent); - + $length = $this->mb_strlen($text); $entities[] = ['_' => 'messageEntityItalic', 'offset' => $offset, 'length' => $length]; - + $new_message .= $text; $offset += $length; break; case 'code': $text = $this->html_entity_decode($node->textContent); - + $length = $this->mb_strlen($text); $entities[] = ['_' => 'messageEntityCode', 'offset' => $offset, 'length' => $length]; - + $new_message .= $text; $offset += $length; break; case 'pre': $text = $this->html_entity_decode($node->textContent); - + $length = $this->mb_strlen($text); - + $language = $node->getAttribute('language'); if ($language === null) { $language = ''; diff --git a/src/danog/MadelineProto/TL/TLParams.php b/src/danog/MadelineProto/TL/TLParams.php index 6261c048..9278439f 100644 --- a/src/danog/MadelineProto/TL/TLParams.php +++ b/src/danog/MadelineProto/TL/TLParams.php @@ -23,7 +23,7 @@ trait TLParams $param['type'] = $matches[2]; } if (preg_match('/^(v|V)ector\<(.*)\>$/', $param['type'], $matches)) { - $param['type'] = $matches[1] === 'v' ? 'vector': 'Vector t'; + $param['type'] = $matches[1] === 'v' ? 'vector' : 'Vector t'; $param['subtype'] = $matches[2]; $param['subtype'] = ($mtproto && $param['subtype'] === 'Message' ? 'MT' : '').$param['subtype']; $param['subtype'] = $mtproto && $param['subtype'] === '%Message' ? '%MTMessage' : $param['subtype'];