Apply fixes from StyleCI
This commit is contained in:
parent
ec23e14c68
commit
43ba430b6d
@ -24,28 +24,28 @@ description: PHP implementation of telegram\'s MTProto protocol
|
||||
|
||||
$docs = [
|
||||
[
|
||||
'tl_schema' => ['mtproto' => __DIR__.'/src/danog/MadelineProto/TL_mtproto_v1.json'],
|
||||
'title' => 'MadelineProto API documentation (mtproto)',
|
||||
'tl_schema' => ['mtproto' => __DIR__.'/src/danog/MadelineProto/TL_mtproto_v1.json'],
|
||||
'title' => 'MadelineProto API documentation (mtproto)',
|
||||
'description' => 'MadelineProto API documentation (mtproto)',
|
||||
'output_dir' => __DIR__.'/docs/MTProto_docs'
|
||||
'output_dir' => __DIR__.'/docs/MTProto_docs',
|
||||
],
|
||||
[
|
||||
'tl_schema' => ['telegram' => __DIR__.'/src/danog/MadelineProto/TL_telegram_v57.json'],
|
||||
'title' => 'MadelineProto API documentation (layer 57)',
|
||||
'tl_schema' => ['telegram' => __DIR__.'/src/danog/MadelineProto/TL_telegram_v57.json'],
|
||||
'title' => 'MadelineProto API documentation (layer 57)',
|
||||
'description' => 'MadelineProto API documentation (layer 57)',
|
||||
'output_dir' => __DIR__.'/docs/API_docs'
|
||||
'output_dir' => __DIR__.'/docs/API_docs',
|
||||
],
|
||||
[
|
||||
'tl_schema' => ['telegram' => __DIR__.'/src/danog/MadelineProto/TL_telegram_v55.json'],
|
||||
'title' => 'MadelineProto API documentation (layer 55)',
|
||||
'tl_schema' => ['telegram' => __DIR__.'/src/danog/MadelineProto/TL_telegram_v55.json'],
|
||||
'title' => 'MadelineProto API documentation (layer 55)',
|
||||
'description' => 'MadelineProto API documentation (layer 55)',
|
||||
'output_dir' => __DIR__.'/docs/API_docs_55'
|
||||
'output_dir' => __DIR__.'/docs/API_docs_55',
|
||||
],
|
||||
[
|
||||
'tl_schema' => ['telegram' => __DIR__.'/src/danog/MadelineProto/TL_telegram_v46.tl'],
|
||||
'title' => 'MadelineProto API documentation (layer 46)',
|
||||
'tl_schema' => ['telegram' => __DIR__.'/src/danog/MadelineProto/TL_telegram_v46.tl'],
|
||||
'title' => 'MadelineProto API documentation (layer 46)',
|
||||
'description' => 'MadelineProto API documentation (layer 46)',
|
||||
'output_dir' => __DIR__.'/docs/API_docs_46'
|
||||
'output_dir' => __DIR__.'/docs/API_docs_46',
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -15,14 +15,19 @@ namespace danog\MadelineProto;
|
||||
class DocsBuilder
|
||||
{
|
||||
use \danog\MadelineProto\TL\TL;
|
||||
public function __construct($settings) {
|
||||
|
||||
public function __construct($settings)
|
||||
{
|
||||
$this->construct_TL($settings['tl_schema']);
|
||||
$this->settings = $settings;
|
||||
if (!file_exists($this->settings['output_dir'])) mkdir($this->settings['output_dir']);
|
||||
if (!file_exists($this->settings['output_dir'])) {
|
||||
mkdir($this->settings['output_dir']);
|
||||
}
|
||||
chdir($this->settings['output_dir']);
|
||||
|
||||
}
|
||||
public function mk_docs() {
|
||||
|
||||
public function mk_docs()
|
||||
{
|
||||
$types = [];
|
||||
|
||||
\danog\MadelineProto\Logger::log('Generating documentation index...');
|
||||
@ -206,11 +211,9 @@ description: List of methods
|
||||
$type = str_replace(['.', '<', '>'], ['_', '_of_', ''], $this->constructors->type[$key]);
|
||||
$real_type = preg_replace('/.*_of_/', '', $type);
|
||||
|
||||
|
||||
$constructor = str_replace(['.', '<', '>'], ['_', '_of_', ''], $constructor);
|
||||
$real_constructor = preg_replace('/.*_of_/', '', $constructor);
|
||||
|
||||
|
||||
$params = '';
|
||||
foreach ($this->constructors->params[$key] as $param) {
|
||||
if (in_array($param['name'], ['flags', 'random_id'])) {
|
||||
@ -543,6 +546,6 @@ description: Represents a boolean.
|
||||
|
||||
Represents a boolean.');
|
||||
|
||||
\danog\MadelineProto\Logger::log('Done!');
|
||||
\danog\MadelineProto\Logger::log('Done!');
|
||||
}
|
||||
}
|
||||
|
@ -29,24 +29,39 @@ trait TL
|
||||
$tl_file = explode("\n", $filec);
|
||||
$key = 0;
|
||||
foreach ($tl_file as $line) {
|
||||
if ($line == '') continue;
|
||||
if ($line == '---functions---') { $type = 'methods'; continue; }
|
||||
if (!preg_match('/^[^\s]+#/', $line)) continue;
|
||||
if (preg_match('/^vector#/', $line)) continue;
|
||||
if ($line == '') {
|
||||
continue;
|
||||
}
|
||||
if ($line == '---functions---') {
|
||||
$type = 'methods';
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('/^[^\s]+#/', $line)) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match('/^vector#/', $line)) {
|
||||
continue;
|
||||
}
|
||||
$TL_dict[$type][$key][$type == 'constructors' ? 'predicate' : 'method'] = preg_replace('/#.*/', '', $line);
|
||||
$TL_dict[$type][$key]['id'] = \danog\PHP\Struct::unpack('<i', \danog\PHP\Struct::pack('<I', hexdec(preg_replace(['/^[^#]+#/', '/\s.+/'], '', $line))))[0];
|
||||
$TL_dict[$type][$key]['params'] = [];
|
||||
$TL_dict[$type][$key]['type'] = preg_replace(['/.+\s/', '/;/'], '', $line);
|
||||
foreach (explode(' ', preg_replace(['/^[^\s]+\s/', '/=\s[^\s]+/', '/\s$/'], '', $line)) as $param) {
|
||||
if ($param == '') continue;
|
||||
if ($param[0] == '{') continue;
|
||||
if ($param == '') {
|
||||
continue;
|
||||
}
|
||||
if ($param[0] == '{') {
|
||||
continue;
|
||||
}
|
||||
$explode = explode(':', $param);
|
||||
$TL_dict[$type][$key]['params'][] = ['name' => $explode[0], 'type' => $explode[1]];
|
||||
}
|
||||
$key++;
|
||||
}
|
||||
}
|
||||
if (empty($TL_dict) || empty($TL_dict['constructors']) || empty($TL_dict['methods'])) throw new Exception('Invalid source file was provided: '.$file);
|
||||
if (empty($TL_dict) || empty($TL_dict['constructors']) || empty($TL_dict['methods'])) {
|
||||
throw new Exception('Invalid source file was provided: '.$file);
|
||||
}
|
||||
\danog\MadelineProto\Logger::log('Translating objects...');
|
||||
foreach ($TL_dict['constructors'] as $elem) {
|
||||
$this->constructors->add($elem, $type);
|
||||
|
@ -32,7 +32,7 @@ if (file_exists('number.php') && $MadelineProto === false) {
|
||||
$sentCode = $MadelineProto->phone_login($number);
|
||||
\danog\MadelineProto\Logger::log($sentCode);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5)+1);
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log($authorization);
|
||||
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL;
|
||||
@ -91,7 +91,7 @@ if (file_exists('number.php') && $MadelineProto === false) {
|
||||
$sentCode = $MadelineProto->phone_login($number);
|
||||
\danog\MadelineProto\Logger::log($sentCode);
|
||||
echo 'Enter the code you received: ';
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5)+1);
|
||||
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);
|
||||
|
||||
$authorization = $MadelineProto->complete_phone_login($code);
|
||||
\danog\MadelineProto\Logger::log($authorization);
|
||||
@ -100,6 +100,3 @@ if (file_exists('number.php') && $MadelineProto === false) {
|
||||
}
|
||||
echo 'Deserializing MadelineProto from session_old.madeline...'.PHP_EOL;
|
||||
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session_old.madeline');
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user