From 8aaedac7a702d00200c54b857c0c0d346612c901 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 26 Jul 2017 06:31:15 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/danog/MadelineProto/Exception.php | 5 ++++- src/danog/MadelineProto/Logger.php | 2 +- src/danog/MadelineProto/MTProto.php | 2 +- src/danog/MadelineProto/MTProtoTools/CallHandler.php | 2 +- src/danog/MadelineProto/RPCErrorException.php | 7 ++++++- src/danog/MadelineProto/Serialization.php | 3 ++- src/danog/MadelineProto/TL/Conversion/BotAPI.php | 4 +++- src/danog/MadelineProto/TL/Exception.php | 10 ++++++++-- 8 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/danog/MadelineProto/Exception.php b/src/danog/MadelineProto/Exception.php index 16ba3f34..da5c8b78 100644 --- a/src/danog/MadelineProto/Exception.php +++ b/src/danog/MadelineProto/Exception.php @@ -15,9 +15,12 @@ namespace danog\MadelineProto; class Exception extends \Exception { use TL\PrettyException; - public function __toString() { + + public function __toString() + { return $this->file === 'MadelineProto' ? $this->message : '\danog\MadelineProto\Exception'.($this->message !== '' ? ': ' : '').$this->message.' in '.$this->file.':'.$this->line.PHP_EOL.'TL Trace:'.PHP_EOL.$this->getTLTrace(); } + public function __construct($message = null, $code = 0, Exception $previous = null, $file = null, $line = null) { $this->prettify_tl(); diff --git a/src/danog/MadelineProto/Logger.php b/src/danog/MadelineProto/Logger.php index 652bfbaf..c68a7616 100644 --- a/src/danog/MadelineProto/Logger.php +++ b/src/danog/MadelineProto/Logger.php @@ -111,7 +111,7 @@ class Logger throw new \danog\MadelineProto\Exception(hex2bin('506c656173652075706461746520746f20746865206c61746573742076657273696f6e206f66204d6164656c696e6550726f746f2e'), 0, null, 'MadelineProto', 1); } if (class_exists('\danog\MadelineProto\VoIP')) { - if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== "1.1") { + if (!defined('\danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION') || \danog\MadelineProto\VoIP::PHP_LIBTGVOIP_VERSION !== '1.1') { throw new \danog\MadelineProto\Exception(hex2bin('506c6561736520757064617465207068702d6c69627467766f6970'), 0, null, 'MadelineProto', 1); } try { diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index d27dcedf..e8076c6f 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -273,7 +273,7 @@ class MTProto extends \Volatile foreach ($this->calls as $id => $controller) { if (!is_object($controller)) { unset($this->calls[$id]); - } else if ($controller->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) { + } elseif ($controller->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_ENDED) { $controller->setMadeline($this); $controller->discard(); } else { diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index d262f387..1af7beef 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -249,7 +249,7 @@ trait CallHandler $server_answer = [$server_answer]; foreach ($message_chunks as $message) { $args['message'] = $message; - $server_answer[]= $this->method_call($method, $args, $aargs); + $server_answer[] = $this->method_call($method, $args, $aargs); } } diff --git a/src/danog/MadelineProto/RPCErrorException.php b/src/danog/MadelineProto/RPCErrorException.php index 4bcbea6a..4583a6a7 100644 --- a/src/danog/MadelineProto/RPCErrorException.php +++ b/src/danog/MadelineProto/RPCErrorException.php @@ -15,7 +15,12 @@ namespace danog\MadelineProto; class RPCErrorException extends \Exception { use TL\PrettyException; - public function __toString() { return 'Telegram returned an RPC error: '.$this->message.' ('.$this->rpc.'), caused by '.$this->file.':'.$this->line.PHP_EOL.PHP_EOL.'TL trace:'.PHP_EOL.$this->getTLTrace().PHP_EOL; } + + public function __toString() + { + return 'Telegram returned an RPC error: '.$this->message.' ('.$this->rpc.'), caused by '.$this->file.':'.$this->line.PHP_EOL.PHP_EOL.'TL trace:'.PHP_EOL.$this->getTLTrace().PHP_EOL; + } + public function __construct($message = null, $code = 0, Exception $previous = null) { $this->rpc = $message; diff --git a/src/danog/MadelineProto/Serialization.php b/src/danog/MadelineProto/Serialization.php index cbe79f94..7b325687 100644 --- a/src/danog/MadelineProto/Serialization.php +++ b/src/danog/MadelineProto/Serialization.php @@ -62,7 +62,8 @@ class Serialization $unserialized = \danog\Serialization::unserialize($unserialized); /*} catch (Exception $e) { $unserialized = \danog\Serialization::unserialize($unserialized); - */} catch (\Error $e) { + */ + } catch (\Error $e) { $unserialized = \danog\Serialization::unserialize($unserialized); } } else { diff --git a/src/danog/MadelineProto/TL/Conversion/BotAPI.php b/src/danog/MadelineProto/TL/Conversion/BotAPI.php index e453536f..615273bc 100644 --- a/src/danog/MadelineProto/TL/Conversion/BotAPI.php +++ b/src/danog/MadelineProto/TL/Conversion/BotAPI.php @@ -232,7 +232,9 @@ trait BotAPI return $data; case 'messageMediaPhoto': - if (isset($data['caption'])) $res['caption'] = $data['caption']; + if (isset($data['caption'])) { + $res['caption'] = $data['caption']; + } $res['photo'] = []; foreach ($data['photo']['sizes'] as $key => $photo) { $res['photo'][$key] = $this->photosize_to_botapi($photo, $data['photo']); diff --git a/src/danog/MadelineProto/TL/Exception.php b/src/danog/MadelineProto/TL/Exception.php index 54335edf..de47ddf3 100644 --- a/src/danog/MadelineProto/TL/Exception.php +++ b/src/danog/MadelineProto/TL/Exception.php @@ -15,8 +15,14 @@ namespace danog\MadelineProto\TL; class Exception extends \Exception { use PrettyException; - public function __toString() { return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.'TL Trace'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; } - public function __construct($message, $file = '') { + + public function __toString() + { + return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.'TL Trace'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; + } + + public function __construct($message, $file = '') + { parent::__construct($message); $this->prettify_tl($file); }