1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 02:54:42 +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->session = $realpaths['file'];
}
return;
}
$this->session = $realpaths['file'];

View File

@ -132,7 +132,9 @@ class Logger
$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;
if (self::$isatty) self::$mode = 3;
if (self::$isatty) {
self::$mode = 3;
}
switch (self::$mode) {
case 1:
error_log($param);

View File

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

View File

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

View File

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

View File

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