From 59c9bc057280ca6ad702e43038e90392aa505d9a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Thu, 18 May 2017 10:13:05 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/danog/MadelineProto/API.php | 19 +++++++++++++++---- src/danog/MadelineProto/MTProto.php | 1 + .../MTProtoTools/AuthKeyHandler.php | 1 - .../MTProtoTools/MessageHandler.php | 2 +- src/danog/MadelineProto/RSA.php | 7 ++++++- src/danog/MadelineProto/TL/TL.php | 5 ++++- src/danog/MadelineProto/TL/TLConstructor.php | 6 +++++- src/danog/MadelineProto/TL/TLMethod.php | 7 ++++++- src/danog/MadelineProto/TL/Types/Button.php | 7 ++++++- src/danog/MadelineProto/TL/Types/Bytes.php | 13 +++++++++++-- .../MadelineProto/Threads/SocketReader.php | 4 ++-- 11 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index abd79b23..1c9415b5 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -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) { diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index b89d3c7d..f56cc004 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -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; } diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index 6e6f3b13..14056445 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -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++) { diff --git a/src/danog/MadelineProto/MTProtoTools/MessageHandler.php b/src/danog/MadelineProto/MTProtoTools/MessageHandler.php index 22c28a4c..3f2aea6a 100644 --- a/src/danog/MadelineProto/MTProtoTools/MessageHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/MessageHandler.php @@ -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; } } diff --git a/src/danog/MadelineProto/RSA.php b/src/danog/MadelineProto/RSA.php index 7542aaf0..133ab3bf 100644 --- a/src/danog/MadelineProto/RSA.php +++ b/src/danog/MadelineProto/RSA.php @@ -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); diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index c1a36243..cad40bfa 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -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; } } diff --git a/src/danog/MadelineProto/TL/TLConstructor.php b/src/danog/MadelineProto/TL/TLConstructor.php index 1efb2d84..ff779cb4 100644 --- a/src/danog/MadelineProto/TL/TLConstructor.php +++ b/src/danog/MadelineProto/TL/TLConstructor.php @@ -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) { diff --git a/src/danog/MadelineProto/TL/TLMethod.php b/src/danog/MadelineProto/TL/TLMethod.php index b180a67a..c76cf115 100644 --- a/src/danog/MadelineProto/TL/TLMethod.php +++ b/src/danog/MadelineProto/TL/TLMethod.php @@ -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']; diff --git a/src/danog/MadelineProto/TL/Types/Button.php b/src/danog/MadelineProto/TL/Types/Button.php index 8fb5d784..58da6292 100644 --- a/src/danog/MadelineProto/TL/Types/Button.php +++ b/src/danog/MadelineProto/TL/Types/Button.php @@ -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['_']) { diff --git a/src/danog/MadelineProto/TL/Types/Bytes.php b/src/danog/MadelineProto/TL/Types/Bytes.php index 49db0ff2..cf545c0c 100644 --- a/src/danog/MadelineProto/TL/Types/Bytes.php +++ b/src/danog/MadelineProto/TL/Types/Bytes.php @@ -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); diff --git a/src/danog/MadelineProto/Threads/SocketReader.php b/src/danog/MadelineProto/Threads/SocketReader.php index 9f4be5f8..fb8dde50 100644 --- a/src/danog/MadelineProto/Threads/SocketReader.php +++ b/src/danog/MadelineProto/Threads/SocketReader.php @@ -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);