1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 07:34:41 +01:00

Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2017-05-27 21:22:04 +00:00 committed by StyleCI Bot
parent 86c07f705d
commit 1514af1fed
10 changed files with 46 additions and 28 deletions

View File

@ -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.");

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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 = [];

View File

@ -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']);

View File

@ -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) {

View File

@ -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'});

View File

@ -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],

View File

@ -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],