1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 04:35:12 +01:00

Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-03-12 21:11:18 +00:00 committed by StyleCI Bot
parent 071be3bb80
commit 0918be3060
6 changed files with 42 additions and 31 deletions

View File

@ -70,6 +70,7 @@ class API extends APIFactory
$this->APIFactory(); $this->APIFactory();
$this->session = $realpaths['file']; $this->session = $realpaths['file'];
} }
return; return;
} }
$this->session = $realpaths['file']; $this->session = $realpaths['file'];

View File

@ -132,7 +132,9 @@ class Logger
$param = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); $param = json_encode($param, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
} }
$param = str_pad(basename(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php').$prefix.': ', 16 + strlen($prefix))."\t".$param; $param = str_pad(basename(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php').$prefix.': ', 16 + strlen($prefix))."\t".$param;
if (self::$isatty) self::$mode = 3; if (self::$isatty) {
self::$mode = 3;
}
switch (self::$mode) { switch (self::$mode) {
case 1: case 1:
error_log($param); error_log($param);

View File

@ -30,25 +30,31 @@ trait PeerHandler
return ($log - intval($log)) * 1000 < 10; return ($log - intval($log)) * 1000 < 10;
} }
public function handle_pending_pwrchat() { public function handle_pending_pwrchat()
{
if ($this->postpone_pwrchat || empty($this->pending_pwrchat)) { if ($this->postpone_pwrchat || empty($this->pending_pwrchat)) {
return false; return false;
} }
$this->postpone_pwrchat = true; $this->postpone_pwrchat = true;
try { try {
\danog\MadelineProto\Logger::log("Handling pending pwrchat queries...", \danog\MadelineProto\Logger::VERBOSE); \danog\MadelineProto\Logger::log('Handling pending pwrchat queries...', \danog\MadelineProto\Logger::VERBOSE);
foreach ($this->pending_pwrchat as $query => $params) { foreach ($this->pending_pwrchat as $query => $params) {
unset($this->pending_pwrchat[$query]); unset($this->pending_pwrchat[$query]);
try {
$this->get_pwr_chat($query, ...$params); try {
} catch (\danog\MadelineProto\Exception $e) { $this->get_pwr_chat($query, ...$params);
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); } catch (\danog\MadelineProto\Exception $e) {
} catch (\danog\MadelineProto\RPCErrorException $e) { \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); } catch (\danog\MadelineProto\RPCErrorException $e) {
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
}
} }
} finally {
$this->postpone_pwrchat = false;
} }
} finally { $this->postpone_pwrchat = false; }
} }
public function add_users($users) public function add_users($users)
{ {
foreach ($users as $key => $user) { foreach ($users as $key => $user) {
@ -73,19 +79,18 @@ trait PeerHandler
if (!isset($this->chats[$user['id']]) || $this->chats[$user['id']] !== $user) { if (!isset($this->chats[$user['id']]) || $this->chats[$user['id']] !== $user) {
$this->chats[$user['id']] = $user; $this->chats[$user['id']] = $user;
if ($this->postpone_pwrchat) { if ($this->postpone_pwrchat) {
$this->pending_pwrchat[$user['id']] = [false, true]; $this->pending_pwrchat[$user['id']] = [false, true];
} else { } else {
try { try {
$this->get_pwr_chat($user['id'], false, true); $this->get_pwr_chat($user['id'], false, true);
} catch (\danog\MadelineProto\Exception $e) { } catch (\danog\MadelineProto\Exception $e) {
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
} catch (\danog\MadelineProto\RPCErrorException $e) { } catch (\danog\MadelineProto\RPCErrorException $e) {
\danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING); \danog\MadelineProto\Logger::log($e->getMessage(), \danog\MadelineProto\Logger::WARNING);
}
} }
} }
}
case 'userEmpty': case 'userEmpty':
break; break;
default: default:

View File

@ -427,16 +427,17 @@ trait ResponseHandler
} }
$this->handle_pending_updates(); $this->handle_pending_updates();
\danog\MadelineProto\Logger::log('Parsing updates received via the socket...', \danog\MadelineProto\Logger::VERBOSE); \danog\MadelineProto\Logger::log('Parsing updates received via the socket...', \danog\MadelineProto\Logger::VERBOSE);
try {
$this->postpone_updates = true;
$opts = []; try {
foreach (['date', 'seq', 'seq_start'] as $key) { $this->postpone_updates = true;
if (isset($updates[$key])) {
$opts[$key] = $updates[$key]; $opts = [];
foreach (['date', 'seq', 'seq_start'] as $key) {
if (isset($updates[$key])) {
$opts[$key] = $updates[$key];
}
} }
} switch ($updates['_']) {
switch ($updates['_']) {
case 'updates': case 'updates':
case 'updatesCombined': case 'updatesCombined':
foreach ($updates['updates'] as $update) { foreach ($updates['updates'] as $update) {

View File

@ -664,6 +664,7 @@ trait TL
} }
} }
} }
return $x; return $x;
} }
} }

View File

@ -33,6 +33,7 @@ if (!function_exists('readline')) {
echo 'Deserializing MadelineProto from testing.madeline...'.PHP_EOL; echo 'Deserializing MadelineProto from testing.madeline...'.PHP_EOL;
$MadelineProto = false; $MadelineProto = false;
try { try {
$MadelineProto = new \danog\MadelineProto\API('testing.madeline'); $MadelineProto = new \danog\MadelineProto\API('testing.madeline');
} catch (\danog\MadelineProto\Exception $e) { } catch (\danog\MadelineProto\Exception $e) {