Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2017-05-18 10:13:05 +00:00 committed by StyleCI Bot
parent b67ce553fc
commit 59c9bc0572
11 changed files with 57 additions and 15 deletions

View File

@ -55,14 +55,25 @@ class API extends APIFactory
{
return ['API'];
}
public function &__get($name) {
if ($name === 'settings') return $this->API->settings;
public function &__get($name)
{
if ($name === 'settings') {
return $this->API->settings;
}
return $this->{$name};
}
public function &__set($name, $value) {
if ($name === 'settings') return $this->API->__construct($value);
public function &__set($name, $value)
{
if ($name === 'settings') {
return $this->API->__construct($value);
}
return $this->{$name} = $value;
}
public function APIFactory()
{
foreach ($this->API->get_method_namespaces() as $namespace) {

View File

@ -154,6 +154,7 @@ class MTProto extends \Volatile
$this->get_config([], ['datacenter' => $this->datacenter->curdc]);
$this->v = $this->getV();
$this->should_serialize = true;
return $this->settings;
}

View File

@ -20,7 +20,6 @@ namespace danog\MadelineProto\MTProtoTools;
*/
trait AuthKeyHandler
{
public function create_auth_key($expires_in, $datacenter)
{
for ($retry_id_total = 1; $retry_id_total <= $this->settings['max_tries']['authorization']; $retry_id_total++) {

View File

@ -21,7 +21,6 @@ trait MessageHandler
* Forming the message frame and sending message to server
* :param message: byte string to send.
*/
public function send_message($message_data, $content_related, $aargs = [])
{
if (!isset($aargs['message_id']) || $aargs['message_id'] === null) {
@ -120,6 +119,7 @@ trait MessageHandler
$this->datacenter->sockets[$datacenter]->incoming_messages[$message_id]['response'] = -1;
$this->datacenter->sockets[$datacenter]->new_incoming[$message_id] = $message_id;
$this->last_recv = time();
return true;
}
}

View File

@ -52,7 +52,12 @@ class RSA extends \Volatile
return true;
}
public function __sleep() { return ['e', 'n', 'fp']; }
public function __sleep()
{
return ['e', 'n', 'fp'];
}
public function encrypt($data)
{
\danog\MadelineProto\Logger::log(['Encrypting with rsa key...'], Logger::VERBOSE);

View File

@ -594,7 +594,9 @@ trait TL
return $this->deserialize($stream, $constructorData);
}
if ($constructorData['type'] === 'Bool') return $constructorData['predicate'] === 'boolTrue';
if ($constructorData['type'] === 'Bool') {
return $constructorData['predicate'] === 'boolTrue';
}
$x = ['_' => $constructorData['predicate']];
foreach ($constructorData['params'] as $arg) {
if ($arg['flag']) {
@ -654,6 +656,7 @@ trait TL
}
}
}
return $x;
}
}

View File

@ -24,7 +24,11 @@ class TLConstructor extends \Volatile
public $params = [];
public $layer = [];
public $key = 0;
public function __sleep() { return ['id', 'predicate', 'type', 'params', 'layer', 'key']; }
public function __sleep()
{
return ['id', 'predicate', 'type', 'params', 'layer', 'key'];
}
public function add($json_dict, $scheme_type)
{

View File

@ -23,7 +23,12 @@ class TLMethod extends \Volatile
public $params = [];
public $method_namespace = [];
public $key = 0;
public function __sleep() { return ['id', 'method', 'type', 'params', 'method_namespace', 'key']; }
public function __sleep()
{
return ['id', 'method', 'type', 'params', 'method_namespace', 'key'];
}
public function add($json_dict)
{
$this->id[$this->key] = $json_dict['id'];

View File

@ -25,7 +25,12 @@ class Button extends \Volatile implements \JsonSerializable
$this->info['id'] = $message['id'];
$this->info['API'] = $API;
}
public function __sleep() { return ['data', 'info']; }
public function __sleep()
{
return ['data', 'info'];
}
public function click($donotwait = false)
{
switch ($this->data['_']) {

View File

@ -21,8 +21,17 @@ class Bytes extends \Volatile implements \JsonSerializable
{
$this->bytes = $bytes;
}
public function __sleep() { return ['bytes']; }
public function __toString() { return $this->bytes; }
public function __sleep()
{
return ['bytes'];
}
public function __toString()
{
return $this->bytes;
}
public function jsonSerialize()
{
return utf8_encode($this->bytes);

View File

@ -49,11 +49,11 @@ class SocketReader extends \Threaded implements \Collectable
while ($this->API->run_workers) {
try {
$this->API->datacenter->sockets[$this->current]->reading = true;
var_dumP('RECEIVING');
var_dump('RECEIVING');
$error = $this->API->recv_message($this->current);
var_dump('NOW HANDLE');
$handler_pool->submit(new SocketHandler($this->API, $this->current, $error));
var_dump("SUBMITTED");
var_dump('SUBMITTED');
$this->API->datacenter->sockets[$this->current]->reading = false;
} catch (\danog\MadelineProto\NothingInTheSocketException $e) {
\danog\MadelineProto\Logger::log(['Nothing in the socket for dc '.$this->current], \danog\MadelineProto\Logger::VERBOSE);