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 2016-12-19 17:58:09 +00:00 committed by StyleCI Bot
parent fa1183b25e
commit 9fd4b22c42
3 changed files with 27 additions and 34 deletions

View File

@ -51,7 +51,6 @@ mkdir('methods');
$methods = [];
$types = [];
\danog\MadelineProto\Logger::log('Generating methods documentation...');
@ -59,10 +58,11 @@ foreach ($TL->methods->method as $key => $method) {
$type = str_replace(['.', '<', '>'], ['_', '_of_', ''], $TL->methods->type[$key]);
$real_type = preg_replace('/.*_of_/', '', $type);
$params = '';
foreach ($TL->methods->params[$key] as $param) {
if ($param['name'] == 'flags') continue;
if ($param['name'] == 'flags') {
continue;
}
$stype = 'type';
$link_type = 'types';
if (isset($param['subtype'])) {
@ -77,32 +77,32 @@ foreach ($TL->methods->method as $key => $method) {
case 'false':
$ptype = 'Bool';
}
$params .= "'".$param['name'] . "' => ";
$params .= (isset($param['subtype']) ? '[' : '') . '['.$ptype.'](../'.$link_type.'/'.$ptype.'.md)'.(isset($param['subtype']) ? ']' : '').', ';
$params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '[' : '').'['.$ptype.'](../'.$link_type.'/'.$ptype.'.md)'.(isset($param['subtype']) ? ']' : '').', ';
}
$methods [$method]= str_replace(['_', '\[\]'],['\_', ''], '$MadelineProto->['.str_replace('.', '->', $method).']('.$method.'.md)(\['.$params.'\]) == [$'.$type.'](../types/'.$real_type.'.md);
$methods[$method] = str_replace(['_', '\[\]'], ['\_', ''], '$MadelineProto->['.str_replace('.', '->', $method).']('.$method.'.md)(\['.$params.'\]) == [$'.$type.'](../types/'.$real_type.'.md);
');
$params = '';
$table = '| Name | Type | Required |
|----------|:-------------:|---------:|
';
foreach ($TL->methods->params[$key] as $param) {
if ($param['name'] == 'flags') continue;
if ($param['name'] == 'flags') {
continue;
}
$ptype = str_replace('.', '_', $param[isset($param['subtype']) ? 'subtype' : 'type']);
switch ($ptype) {
case 'true':
case 'false':
$ptype = 'Bool';
}
$table .= '|'.$param['name'] . '|' . (isset($param['subtype']) ? 'Array of ' : ''). '['.$ptype.'](../types/'.$ptype.'.md) | '.($param['flag'] ? 'Optional' : 'Required').'|
$table .= '|'.$param['name'].'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.$ptype.'](../types/'.$ptype.'.md) | '.($param['flag'] ? 'Optional' : 'Required').'|
';
$params .= "'".$param['name'] . "' => ";
$params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '['.$ptype.']' : $ptype).', ';
}
$example = str_replace('[]', '', '
```
@ -151,9 +151,7 @@ file_put_contents('methods/index.md', '# Methods
}
</style>
<div class="container">
'.join('', $methods).'</div>');
'.implode('', $methods).'</div>');
foreach (glob('constructors/*') as $unlink) {
unlink($unlink);
@ -171,13 +169,15 @@ $constructors = [];
foreach ($TL->constructors->predicate as $key => $constructor) {
$constructor = str_replace('.', '_', $constructor);
$type = str_replace(['.', '<', '>'], ['_', '_of_', ''], $TL->constructors->type[$key]);
$real_type = preg_replace('/.*_of_/', '', $type);
$params = '';
foreach ($TL->constructors->params[$key] as $param) {
if ($param['name'] == 'flags') continue;
if ($param['name'] == 'flags') {
continue;
}
$stype = 'type';
$link_type = 'types';
if (isset($param['subtype'])) {
@ -187,22 +187,20 @@ foreach ($TL->constructors->predicate as $key => $constructor) {
}
}
$ptype = str_replace('.', '_', $param[$stype]);
switch ($ptype) {
case 'true':
case 'false':
$ptype = 'Bool';
}
$params .= "'".$param['name'] . "' => ";
$params .= (isset($param['subtype']) ? '[' : '') . '['.$ptype.'](../'.$link_type.'/'.$ptype.'.md)'.(isset($param['subtype']) ? ']' : '').', ';
$params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '[' : '').'['.$ptype.'](../'.$link_type.'/'.$ptype.'.md)'.(isset($param['subtype']) ? ']' : '').', ';
}
$constructors [$constructor]= str_replace(['_', '\[\]'],['\_', ''], '[$'.$real_type.'](../types/'.$real_type.'.md)\[\'['.str_replace('.', '->', $constructor).']('.$constructor.'.md)\'\] = \['.$params.'\]
$constructors[$constructor] = str_replace(['_', '\[\]'], ['\_', ''], '[$'.$real_type.'](../types/'.$real_type.'.md)\[\'['.str_replace('.', '->', $constructor).']('.$constructor.'.md)\'\] = \['.$params.'\]
');
if (!isset($types[$real_type])) {
$types[$real_type] = [];
}
@ -215,9 +213,11 @@ foreach ($TL->constructors->predicate as $key => $constructor) {
|----------|:-------------:|---------:|
';
foreach ($TL->constructors->params[$key] as $param) {
if ($param['name'] == 'flags') continue;
if ($param['name'] == 'flags') {
continue;
}
$ptype = str_replace('.', '_', $param[isset($param['subtype']) ? 'subtype' : 'type']);
$link_type = 'types';
if (isset($param['subtype'])) {
if ($param['type'] == 'vector') {
@ -229,12 +229,11 @@ foreach ($TL->constructors->predicate as $key => $constructor) {
case 'false':
$ptype = 'Bool';
}
$table .= '|'.$param['name'] . '|' . (isset($param['subtype']) ? 'Array of ' : ''). '['.$ptype.'](../'.$link_type.'/'.$ptype.'.md) | '.($param['flag'] ? 'Optional' : 'Required').'|
$table .= '|'.$param['name'].'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.$ptype.'](../'.$link_type.'/'.$ptype.'.md) | '.($param['flag'] ? 'Optional' : 'Required').'|
';
$params .= "'".$param['name'] . "' => ";
$params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '['.$ptype.']' : $ptype).', ';
}
$example = str_replace('[]', '', '
```
@ -254,7 +253,6 @@ $'.$constructor.' = ['.$params.'];
file_put_contents('constructors/'.$constructor.'.md', $header.$example);
}
\danog\MadelineProto\Logger::log('Generating constructors index...');
ksort($constructors);
@ -270,8 +268,7 @@ file_put_contents('constructors/index.md', '# Constructors
}
</style>
<div class="container">
'.join('', $constructors).'</div>');
'.implode('', $constructors).'</div>');
foreach (glob('types/*') as $unlink) {
unlink($unlink);
@ -316,7 +313,6 @@ foreach ($types as $type => $keys) {
file_put_contents('types/'.$type.'.md', $header);
}
\danog\MadelineProto\Logger::log('Generating additional types...');
file_put_contents('types/string.md', '## Type: string

View File

@ -27,7 +27,6 @@ class MTProto extends PrimeModule
use \danog\MadelineProto\MTProtoTools\SaltHandler;
use \danog\MadelineProto\MTProtoTools\SeqNoHandler;
public $settings = [];
public $authorized = false;
public $waiting_code = false;
@ -284,7 +283,6 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
\danog\MadelineProto\Logger::log('Generating temporary authorization key...');
$this->datacenter->temp_auth_key = $this->create_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in']);
$this->bind_temp_auth_key($this->settings['authorization']['default_temp_auth_key_expires_in']);
}
}

View File

@ -65,7 +65,6 @@ trait MessageHandler
$this->parse_config();
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
}
}
throw new \danog\MadelineProto\RPCErrorException($error, $error);
}