mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 05:34:42 +01:00
Apply fixes from StyleCI
This commit is contained in:
parent
86c07f705d
commit
1514af1fed
@ -48,7 +48,7 @@ class API extends APIFactory
|
||||
}
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return ['API', 'storage'];
|
||||
|
@ -215,6 +215,7 @@ class Connection extends \Volatile
|
||||
$this->close_and_reopen();
|
||||
throw new Exception("WARNING: Wrong length was read (should've read ".($length).', read '.strlen($packet).')!');
|
||||
}
|
||||
|
||||
return $packet;
|
||||
case 'udp':
|
||||
throw new Exception("Connection: This protocol wasn't implemented yet.");
|
||||
|
@ -49,18 +49,18 @@ class MTProto extends \Volatile
|
||||
const WAITING_PASSWORD = 2;
|
||||
const LOGGED_IN = 3;
|
||||
const DISALLOWED_METHODS = [
|
||||
'auth.logOut' => 'You cannot use this method directly, use the logout method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.logOut' => 'You cannot use this method directly, use the logout method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.importBotAuthorization' => 'You cannot use this method directly, use the bot_login method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.sendCode' => 'You cannot use this method directly, use the phone_login method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.signIn' => 'You cannot use this method directly, use the complete_phone_login method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.signUp' => 'You cannot use this method directly, use the complete_signup method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'users.getFullUser' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'channels.getFullChannel' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'messages.getFullChat' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'channels.getParticipants' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'contacts.resolveUsername' => 'You cannot use this method directly, use the resolve_username, get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.sendCode' => 'You cannot use this method directly, use the phone_login method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.signIn' => 'You cannot use this method directly, use the complete_phone_login method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'auth.signUp' => 'You cannot use this method directly, use the complete_signup method instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'users.getFullUser' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'channels.getFullChannel' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'messages.getFullChat' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'channels.getParticipants' => 'You cannot use this method directly, use the get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
'contacts.resolveUsername' => 'You cannot use this method directly, use the resolve_username, get_pwr_chat, get_info, get_full_info methods instead (see https://daniil.it/MadelineProto for more info)',
|
||||
|
||||
'messages.acceptEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
'messages.acceptEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
'messages.discardEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
'messages.requestEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
/*
|
||||
@ -70,13 +70,13 @@ class MTProto extends \Volatile
|
||||
'phone.discardCall' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling calls',
|
||||
*/
|
||||
'updates.getChannelDifference' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
'updates.getDifference' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
'updates.getState' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
'updates.getDifference' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
'updates.getState' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
|
||||
'upload.getCdnFile' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.getCdnFile' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.reuploadCdnFile' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.getFile' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.saveFilePart' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.getFile' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.saveFilePart' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
'upload.saveBigFilePart' => 'You cannot use this method directly, use the upload, download_to_stream, download_to_file, download_to_dir methods instead; see https://daniil.it/MadelineProto for more info',
|
||||
|
||||
];
|
||||
@ -142,14 +142,11 @@ class MTProto extends \Volatile
|
||||
private $twoe2047;
|
||||
private $twoe2048;
|
||||
|
||||
|
||||
|
||||
private $ipv6 = false;
|
||||
public $should_serialize = false;
|
||||
public $run_workers = false;
|
||||
public $threads = false;
|
||||
|
||||
|
||||
public function ___construct($settings = [])
|
||||
{
|
||||
\danog\MadelineProto\Logger::class_exists();
|
||||
@ -229,7 +226,6 @@ class MTProto extends \Volatile
|
||||
// Detect ipv6
|
||||
$this->ipv6 = (bool) strlen(@file_get_contents('http://ipv6.test-ipv6.com/', false, stream_context_create(['http' => ['timeout' => 1]]))) > 0;
|
||||
|
||||
|
||||
$keys = array_keys((array) get_object_vars($this));
|
||||
if (count($keys) !== count(array_unique($keys))) {
|
||||
throw new Bug74586Exception();
|
||||
|
@ -42,6 +42,7 @@ trait AckHandler
|
||||
}
|
||||
|
||||
$this->object_call('msgs_ack', ['msg_ids' => [$message_id]], ['datacenter' => $datacenter]);
|
||||
|
||||
return $this->datacenter->sockets[$datacenter]->incoming_messages[$message_id]['ack'] = true;
|
||||
}
|
||||
}
|
||||
|
@ -416,7 +416,9 @@ trait AuthKeyHandler
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log(['An exception occurred while generating the authorization key: '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...'], \danog\MadelineProto\Logger::WARNING);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->rpc === 'RPC_CALL_FAIL') throw $e;
|
||||
if ($e->rpc === 'RPC_CALL_FAIL') {
|
||||
throw $e;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['An RPCErrorException occurred while generating the authorization key: '.$e->getMessage().' Retrying (try number '.$retry_id_total.')...'], \danog\MadelineProto\Logger::WARNING);
|
||||
} finally {
|
||||
$this->datacenter->sockets[$datacenter]->new_outgoing = [];
|
||||
|
@ -31,7 +31,9 @@ trait CallHandler
|
||||
if (basename(debug_backtrace(0)[0]['file']) === 'APIFactory.php' && isset(self::DISALLOWED_METHODS[$method])) {
|
||||
if ($method === 'channels.getParticipants' && $args['filter'] === ['_' => 'channelParticipantsRecent']) {
|
||||
\danog\MadelineProto\Logger::log([self::DISALLOWED_METHODS[$method]], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
} else throw new \danog\MadelineProto\Exception(self::DISALLOWED_METHODS[$method], 0, null, 'MadelineProto', 1);
|
||||
} else {
|
||||
throw new \danog\MadelineProto\Exception(self::DISALLOWED_METHODS[$method], 0, null, 'MadelineProto', 1);
|
||||
}
|
||||
}
|
||||
if (isset($args['message']) && is_string($args['message']) && mb_strlen($args['message']) > 4096) {
|
||||
$message_chunks = $this->split_to_chunks($args['message']);
|
||||
|
@ -27,7 +27,7 @@ trait Files
|
||||
}
|
||||
$datacenter = is_null($datacenter) ? $this->datacenter->curdc : $datacenter;
|
||||
$file_size = filesize($file);
|
||||
if ($file_size > 512*1024*3000) {
|
||||
if ($file_size > 512 * 1024 * 3000) {
|
||||
throw new \danog\MadelineProto\Exception('Given file is too big!');
|
||||
}
|
||||
if ($cb === null) {
|
||||
|
@ -82,6 +82,7 @@ trait MsgIdHandler
|
||||
$message_id = $key->add($this->four);
|
||||
}
|
||||
$this->check_message_id($message_id, ['outgoing' => true, 'datacenter' => $datacenter, 'container' => false]);
|
||||
|
||||
return strrev($message_id->toBytes());
|
||||
}
|
||||
|
||||
@ -91,6 +92,7 @@ trait MsgIdHandler
|
||||
if (isset($this->datacenter->sockets[$datacenter]->{'max_'.$incoming.'_id'}) && is_object($this->datacenter->sockets[$datacenter]->{'max_'.$incoming.'_id'})) {
|
||||
return $this->datacenter->sockets[$datacenter]->{'max_'.$incoming.'_id'};
|
||||
}
|
||||
|
||||
return $this->zero;
|
||||
/*
|
||||
$keys = array_keys((array) $this->datacenter->sockets[$datacenter]->{$incoming.'_messages'});
|
||||
|
@ -47,6 +47,7 @@ class TLConstructor extends \Volatile
|
||||
public function find_by_type($type)
|
||||
{
|
||||
$id = array_search($type, (array) $this->type, true);
|
||||
|
||||
return ($id === false) ? false : [
|
||||
'id' => substr($id, 1),
|
||||
'predicate' => $this->predicate[$id],
|
||||
@ -59,13 +60,18 @@ class TLConstructor extends \Volatile
|
||||
{
|
||||
if ($layer !== '' && !isset($this->id[$predicate.$layer])) {
|
||||
foreach ($this->layers as $newlayer) {
|
||||
if (isset($this->id[$predicate.$newlayer]) || $newlayer > $layer) break;
|
||||
if (isset($this->id[$predicate.$newlayer]) || $newlayer > $layer) {
|
||||
break;
|
||||
}
|
||||
$nlayer = $newlayer;
|
||||
}
|
||||
$layer = $nlayer;
|
||||
}
|
||||
if (!isset($this->id[$predicate.$layer])) return false;
|
||||
if (!isset($this->id[$predicate.$layer])) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->id[$predicate.$layer];
|
||||
|
||||
return [
|
||||
'id' => substr($id, 1),
|
||||
'predicate' => $this->predicate[$id],
|
||||
@ -77,7 +83,10 @@ class TLConstructor extends \Volatile
|
||||
public function find_by_id($oid)
|
||||
{
|
||||
$id = 'a'.$oid;
|
||||
if (!isset($this->predicate[$id])) return false;
|
||||
if (!isset($this->predicate[$id])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $oid,
|
||||
'predicate' => $this->predicate[$id],
|
||||
|
@ -45,7 +45,9 @@ class TLMethod extends \Volatile
|
||||
|
||||
public function find_by_method($method)
|
||||
{
|
||||
if (!isset($this->id[$method])) return false;
|
||||
if (!isset($this->id[$method])) {
|
||||
return false;
|
||||
}
|
||||
$id = $this->id[$method];
|
||||
|
||||
return [
|
||||
@ -59,7 +61,10 @@ class TLMethod extends \Volatile
|
||||
public function find_by_id($oid)
|
||||
{
|
||||
$id = 'a'.$oid;
|
||||
if (!isset($this->method[$id])) return false;
|
||||
if (!isset($this->method[$id])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $oid,
|
||||
'method' => $this->method[$id],
|
||||
|
Loading…
Reference in New Issue
Block a user