Apply fixes from StyleCI
This commit is contained in:
parent
ba740d7be7
commit
f15631ab86
@ -32,7 +32,6 @@ class API extends APIFactory
|
||||
\danog\MadelineProto\Logger::log('Getting future salts...');
|
||||
$this->future_salts = $this->get_future_salts([3]);
|
||||
|
||||
|
||||
\danog\MadelineProto\Logger::log('MadelineProto is ready!');
|
||||
restore_error_handler();
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ class Connection extends Tools
|
||||
public $authorization = null;
|
||||
public $waiting_code = false;
|
||||
|
||||
|
||||
public $incoming_messages = [];
|
||||
public $outgoing_messages = [];
|
||||
public $new_incoming = [];
|
||||
|
@ -51,7 +51,6 @@ class MTProto extends MTProtoTools
|
||||
}
|
||||
$this->ipv6 = strlen($google) > 0;
|
||||
|
||||
|
||||
// Detect device model
|
||||
$device_model = 'Web server';
|
||||
try {
|
||||
@ -59,7 +58,6 @@ class MTProto extends MTProtoTools
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
|
||||
// Detect system version
|
||||
$system_version = phpversion();
|
||||
try {
|
||||
|
@ -243,7 +243,6 @@ class AuthKeyHandler extends AckHandler
|
||||
|
||||
\danog\MadelineProto\Logger::log(sprintf('Server-client time delta = %.1f s', $this->datacenter->time_delta));
|
||||
|
||||
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* Define some needed numbers for BigInteger
|
||||
@ -264,7 +263,6 @@ class AuthKeyHandler extends AckHandler
|
||||
throw new \danog\MadelineProto\Exception("dh_prime isn't a safe 2048-bit prime (dh_prime isn't a prime).");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* Check validity of dh_prime
|
||||
@ -407,7 +405,6 @@ class AuthKeyHandler extends AckHandler
|
||||
$new_nonce_hash2 = substr(sha1($new_nonce.chr(2).$auth_key_aux_hash, true), -16);
|
||||
$new_nonce_hash3 = substr(sha1($new_nonce.chr(3).$auth_key_aux_hash, true), -16);
|
||||
|
||||
|
||||
/*
|
||||
* ***********************************************************************
|
||||
* Check if the client's nonce and the server's nonce are the same
|
||||
|
@ -51,7 +51,6 @@ class CallHandler extends AuthKeyHandler
|
||||
\danog\MadelineProto\Logger::log('Received request to switch to DC '.$dc);
|
||||
$this->switch_dc($dc);
|
||||
throw new \danog\MadelineProto\Exception('I had to switch to datacenter '.$dc);
|
||||
|
||||
break;
|
||||
case 401:
|
||||
switch ($server_answer['error_message']) {
|
||||
|
@ -89,10 +89,10 @@ class MessageHandler extends Crypt
|
||||
$message_id = \danog\PHP\Struct::unpack('<Q', substr($decrypted_data, 16, 8))[0];
|
||||
$this->check_message_id($message_id, false);
|
||||
|
||||
$seq_no = \danog\PHP\Struct::unpack('<I', substr($decrypted_data, 24, 4)) [0];
|
||||
$seq_no = \danog\PHP\Struct::unpack('<I', substr($decrypted_data, 24, 4))[0];
|
||||
// Dunno how to handle any incorrect sequence numbers
|
||||
|
||||
$message_data_length = \danog\PHP\Struct::unpack('<I', substr($decrypted_data, 28, 4)) [0];
|
||||
$message_data_length = \danog\PHP\Struct::unpack('<I', substr($decrypted_data, 28, 4))[0];
|
||||
|
||||
if ($message_data_length > strlen($decrypted_data)) {
|
||||
throw new \danog\MadelineProto\Exception('message_data_length is too big');
|
||||
|
@ -127,7 +127,6 @@ class PrimeModule extends Tools
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
throw new Exception("Couldn't calculate pq!");
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class TL extends \danog\MadelineProto\Tools
|
||||
|
||||
public function deserialize_bool($data)
|
||||
{
|
||||
$id = \danog\PHP\Struct::unpack('<i', $data) [0];
|
||||
$id = \danog\PHP\Struct::unpack('<i', $data)[0];
|
||||
$tl_elem = $this->constructors->find_by_id($id);
|
||||
if ($tl_elem === false) {
|
||||
throw new Exception('Could not extract boolean');
|
||||
@ -240,13 +240,13 @@ class TL extends \danog\MadelineProto\Tools
|
||||
case 'Bool':
|
||||
return $this->deserialize_bool(fread($bytes_io, 4));
|
||||
case 'int':
|
||||
return \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4)) [0];
|
||||
return \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4))[0];
|
||||
case '#':
|
||||
return \danog\PHP\Struct::unpack('<I', fread($bytes_io, 4)) [0];
|
||||
return \danog\PHP\Struct::unpack('<I', fread($bytes_io, 4))[0];
|
||||
case 'long':
|
||||
return \danog\PHP\Struct::unpack('<q', fread($bytes_io, 8)) [0];
|
||||
return \danog\PHP\Struct::unpack('<q', fread($bytes_io, 8))[0];
|
||||
case 'double':
|
||||
return \danog\PHP\Struct::unpack('<d', fread($bytes_io, 8)) [0];
|
||||
return \danog\PHP\Struct::unpack('<d', fread($bytes_io, 8))[0];
|
||||
case 'int128':
|
||||
return fread($bytes_io, 16);
|
||||
case 'int256':
|
||||
@ -255,12 +255,12 @@ class TL extends \danog\MadelineProto\Tools
|
||||
return fread($bytes_io, 32);
|
||||
case 'string':
|
||||
case 'bytes':
|
||||
$l = \danog\PHP\Struct::unpack('<B', fread($bytes_io, 1)) [0];
|
||||
$l = \danog\PHP\Struct::unpack('<B', fread($bytes_io, 1))[0];
|
||||
if ($l > 254) {
|
||||
throw new Exception('Length is too big');
|
||||
}
|
||||
if ($l == 254) {
|
||||
$long_len = \danog\PHP\Struct::unpack('<I', fread($bytes_io, 3).$this->string2bin('\x00')) [0];
|
||||
$long_len = \danog\PHP\Struct::unpack('<I', fread($bytes_io, 3).$this->string2bin('\x00'))[0];
|
||||
$x = fread($bytes_io, $long_len);
|
||||
$resto = $this->posmod(-$long_len, 4);
|
||||
if ($resto > 0) {
|
||||
@ -281,7 +281,7 @@ class TL extends \danog\MadelineProto\Tools
|
||||
case 'true':
|
||||
return true;
|
||||
case 'Vector t':
|
||||
$id = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4)) [0];
|
||||
$id = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4))[0];
|
||||
$constructorData = $this->constructors->find_by_id($id);
|
||||
if ($constructorData === false) {
|
||||
throw new Exception('Could not extract type: '.$type['type'].' with id '.$id);
|
||||
@ -296,7 +296,7 @@ class TL extends \danog\MadelineProto\Tools
|
||||
throw new Exception('Invalid vector constructor: '.$constructorData['predicate']);
|
||||
}
|
||||
case 'vector':
|
||||
$count = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4)) [0];
|
||||
$count = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4))[0];
|
||||
$result = [];
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$result[] = $this->deserialize($bytes_io, ['type' => $type['subtype']]);
|
||||
@ -313,7 +313,7 @@ class TL extends \danog\MadelineProto\Tools
|
||||
} else {
|
||||
$constructorData = $this->constructors->find_by_predicate($type['type']);
|
||||
if ($constructorData === false) {
|
||||
$id = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4)) [0];
|
||||
$id = \danog\PHP\Struct::unpack('<i', fread($bytes_io, 4))[0];
|
||||
$constructorData = $this->constructors->find_by_id($id);
|
||||
if ($constructorData === false) {
|
||||
throw new Exception('Could not extract type: '.$type['type'].' with id '.$id);
|
||||
|
@ -13,7 +13,6 @@ If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
|
||||
if (file_exists('number.php') && !file_exists('session.madeline')) {
|
||||
include_once 'number.php';
|
||||
$MadelineProto = new \danog\MadelineProto\API();
|
||||
|
Loading…
Reference in New Issue
Block a user