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 = []; $methods = [];
$types = []; $types = [];
\danog\MadelineProto\Logger::log('Generating methods documentation...'); \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]); $type = str_replace(['.', '<', '>'], ['_', '_of_', ''], $TL->methods->type[$key]);
$real_type = preg_replace('/.*_of_/', '', $type); $real_type = preg_replace('/.*_of_/', '', $type);
$params = ''; $params = '';
foreach ($TL->methods->params[$key] as $param) { foreach ($TL->methods->params[$key] as $param) {
if ($param['name'] == 'flags') continue; if ($param['name'] == 'flags') {
continue;
}
$stype = 'type'; $stype = 'type';
$link_type = 'types'; $link_type = 'types';
if (isset($param['subtype'])) { if (isset($param['subtype'])) {
@ -77,32 +77,32 @@ foreach ($TL->methods->method as $key => $method) {
case 'false': case 'false':
$ptype = 'Bool'; $ptype = 'Bool';
} }
$params .= "'".$param['name'] . "' => "; $params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '[' : '') . '['.$ptype.'](../'.$link_type.'/'.$ptype.'.md)'.(isset($param['subtype']) ? ']' : '').', '; $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 = ''; $params = '';
$table = '| Name | Type | Required | $table = '| Name | Type | Required |
|----------|:-------------:|---------:| |----------|:-------------:|---------:|
'; ';
foreach ($TL->methods->params[$key] as $param) { 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']); $ptype = str_replace('.', '_', $param[isset($param['subtype']) ? 'subtype' : 'type']);
switch ($ptype) { switch ($ptype) {
case 'true': case 'true':
case 'false': case 'false':
$ptype = 'Bool'; $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).', '; $params .= (isset($param['subtype']) ? '['.$ptype.']' : $ptype).', ';
} }
$example = str_replace('[]', '', ' $example = str_replace('[]', '', '
``` ```
@ -151,9 +151,7 @@ file_put_contents('methods/index.md', '# Methods
} }
</style> </style>
<div class="container"> <div class="container">
'.join('', $methods).'</div>'); '.implode('', $methods).'</div>');
foreach (glob('constructors/*') as $unlink) { foreach (glob('constructors/*') as $unlink) {
unlink($unlink); unlink($unlink);
@ -171,13 +169,15 @@ $constructors = [];
foreach ($TL->constructors->predicate as $key => $constructor) { foreach ($TL->constructors->predicate as $key => $constructor) {
$constructor = str_replace('.', '_', $constructor); $constructor = str_replace('.', '_', $constructor);
$type = str_replace(['.', '<', '>'], ['_', '_of_', ''], $TL->constructors->type[$key]); $type = str_replace(['.', '<', '>'], ['_', '_of_', ''], $TL->constructors->type[$key]);
$real_type = preg_replace('/.*_of_/', '', $type); $real_type = preg_replace('/.*_of_/', '', $type);
$params = ''; $params = '';
foreach ($TL->constructors->params[$key] as $param) { foreach ($TL->constructors->params[$key] as $param) {
if ($param['name'] == 'flags') continue; if ($param['name'] == 'flags') {
continue;
}
$stype = 'type'; $stype = 'type';
$link_type = 'types'; $link_type = 'types';
if (isset($param['subtype'])) { if (isset($param['subtype'])) {
@ -187,22 +187,20 @@ foreach ($TL->constructors->predicate as $key => $constructor) {
} }
} }
$ptype = str_replace('.', '_', $param[$stype]); $ptype = str_replace('.', '_', $param[$stype]);
switch ($ptype) { switch ($ptype) {
case 'true': case 'true':
case 'false': case 'false':
$ptype = 'Bool'; $ptype = 'Bool';
} }
$params .= "'".$param['name'] . "' => "; $params .= "'".$param['name']."' => ";
$params .= (isset($param['subtype']) ? '[' : '') . '['.$ptype.'](../'.$link_type.'/'.$ptype.'.md)'.(isset($param['subtype']) ? ']' : '').', '; $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])) { if (!isset($types[$real_type])) {
$types[$real_type] = []; $types[$real_type] = [];
} }
@ -215,9 +213,11 @@ foreach ($TL->constructors->predicate as $key => $constructor) {
|----------|:-------------:|---------:| |----------|:-------------:|---------:|
'; ';
foreach ($TL->constructors->params[$key] as $param) { 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']); $ptype = str_replace('.', '_', $param[isset($param['subtype']) ? 'subtype' : 'type']);
$link_type = 'types'; $link_type = 'types';
if (isset($param['subtype'])) { if (isset($param['subtype'])) {
if ($param['type'] == 'vector') { if ($param['type'] == 'vector') {
@ -229,12 +229,11 @@ foreach ($TL->constructors->predicate as $key => $constructor) {
case 'false': case 'false':
$ptype = 'Bool'; $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).', '; $params .= (isset($param['subtype']) ? '['.$ptype.']' : $ptype).', ';
} }
$example = str_replace('[]', '', ' $example = str_replace('[]', '', '
``` ```
@ -254,7 +253,6 @@ $'.$constructor.' = ['.$params.'];
file_put_contents('constructors/'.$constructor.'.md', $header.$example); file_put_contents('constructors/'.$constructor.'.md', $header.$example);
} }
\danog\MadelineProto\Logger::log('Generating constructors index...'); \danog\MadelineProto\Logger::log('Generating constructors index...');
ksort($constructors); ksort($constructors);
@ -270,8 +268,7 @@ file_put_contents('constructors/index.md', '# Constructors
} }
</style> </style>
<div class="container"> <div class="container">
'.join('', $constructors).'</div>'); '.implode('', $constructors).'</div>');
foreach (glob('types/*') as $unlink) { foreach (glob('types/*') as $unlink) {
unlink($unlink); unlink($unlink);
@ -316,7 +313,6 @@ foreach ($types as $type => $keys) {
file_put_contents('types/'.$type.'.md', $header); file_put_contents('types/'.$type.'.md', $header);
} }
\danog\MadelineProto\Logger::log('Generating additional types...'); \danog\MadelineProto\Logger::log('Generating additional types...');
file_put_contents('types/string.md', '## Type: string 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\SaltHandler;
use \danog\MadelineProto\MTProtoTools\SeqNoHandler; use \danog\MadelineProto\MTProtoTools\SeqNoHandler;
public $settings = []; public $settings = [];
public $authorized = false; public $authorized = false;
public $waiting_code = false; public $waiting_code = false;
@ -284,7 +283,6 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
\danog\MadelineProto\Logger::log('Generating temporary authorization key...'); \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->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']); $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(); $this->parse_config();
throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key'); throw new \danog\MadelineProto\Exception('I had to recreate the temporary authorization key');
} }
} }
throw new \danog\MadelineProto\RPCErrorException($error, $error); throw new \danog\MadelineProto\RPCErrorException($error, $error);
} }