More style improvements

This commit is contained in:
Daniil Gentili 2019-10-29 22:06:51 +01:00
parent 8ea90f796b
commit 40496d374e
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
9 changed files with 13 additions and 12 deletions

View File

@ -31,7 +31,7 @@ class Exception extends \Exception
public function __construct($message = null, $code = 0, self $previous = null, $file = null, $line = null) public function __construct($message = null, $code = 0, self $previous = null, $file = null, $line = null)
{ {
$this->prettifyTl(); $this->prettifyTL();
if ($file !== null) { if ($file !== null) {
$this->file = $file; $this->file = $file;
} }

View File

@ -4740,7 +4740,7 @@ class InternalDoc extends APIFactory
return $this->__call(__FUNCTION__, [$chat, $extra]); return $this->__call(__FUNCTION__, [$chat, $extra]);
} }
public function constructTl($files, $objects = [ public function constructTL($files, $objects = [
], array $extra = []) ], array $extra = [])
{ {
return $this->__call(__FUNCTION__, [$files, $objects, $extra]); return $this->__call(__FUNCTION__, [$files, $objects, $extra]);

View File

@ -31,6 +31,6 @@ class PTSException extends \Exception
public function __construct($message, $file = '') public function __construct($message, $file = '')
{ {
parent::__construct($message); parent::__construct($message);
$this->prettifyTl($file); $this->prettifyTL($file);
} }
} }

View File

@ -116,7 +116,7 @@ class RPCErrorException extends \Exception
{ {
$this->rpc = $message; $this->rpc = $message;
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
$this->prettifyTl($caller); $this->prettifyTL($caller);
$this->caller = $caller; $this->caller = $caller;
$additional = []; $additional = [];

View File

@ -36,6 +36,6 @@ class Exception extends \Exception
public function __construct($message, $file = '') public function __construct($message, $file = '')
{ {
parent::__construct($message); parent::__construct($message);
$this->prettifyTl($file); $this->prettifyTL($file);
} }
} }

View File

@ -36,6 +36,6 @@ class Exception extends \Exception
public function __construct($message, $file = '') public function __construct($message, $file = '')
{ {
parent::__construct($message); parent::__construct($message);
$this->prettifyTl($file); $this->prettifyTL($file);
} }
} }

View File

@ -55,7 +55,7 @@ trait PrettyException
{ {
if (!$this->updated) { if (!$this->updated) {
$this->updated = true; $this->updated = true;
$this->prettifyTl($this->method, $trace); $this->prettifyTL($this->method, $trace);
} }
} }
/** /**
@ -76,7 +76,7 @@ trait PrettyException
* *
* @return void * @return void
*/ */
public function prettifyTl(string $init = '', array $trace = null) public function prettifyTL(string $init = '', array $trace = null)
{ {
$this->method = $init; $this->method = $init;
$previous_trace = $this->tl_trace; $previous_trace = $this->tl_trace;

View File

@ -29,7 +29,7 @@ trait TL
public $td_descriptions; public $td_descriptions;
public $tl_callbacks = []; public $tl_callbacks = [];
public function constructTl($files, $objects = []) public function constructTL($files, $objects = [])
{ {
$this->logger->logger(\danog\MadelineProto\Lang::$current_lang['TL_loading'], \danog\MadelineProto\Logger::VERBOSE); $this->logger->logger(\danog\MadelineProto\Lang::$current_lang['TL_loading'], \danog\MadelineProto\Logger::VERBOSE);
$this->updateCallbacks($objects); $this->updateCallbacks($objects);

View File

@ -29,9 +29,10 @@ foreach ($methods as $methodObj) {
if (\strpos($method, '__') === 0 || $method === 'async') { if (\strpos($method, '__') === 0 || $method === 'async') {
continue; continue;
} }
$new = Tools::from_snake_case($method); $new = Tools::fromSnakeCase($method);
$new = \str_ireplace(['mtproto', 'api'], ['MTProto', 'API'], $new); $new = \str_ireplace(['mtproto', 'api'], ['MTProto', 'API'], $new);
if (!\in_array($method, ['discard_call_async', 'accept_call_async', 'request_call_async'])) { $new = \preg_replace('/TL$/i', 'TL', $new);
if (!\in_array($method, ['discardCallAsync', 'acceptCallAsync', 'requestCallAsync'])) {
$new = \preg_replace('/async$/i', '', $new); $new = \preg_replace('/async$/i', '', $new);
} }
@ -55,7 +56,7 @@ foreach ($methods as $methodObj) {
$replace[] = "function $new("; $replace[] = "function $new(";
} }
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(\realpath('src'))), '/\.php$/') as $filename) { foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(\realpath('.'))), '/\.php$/') as $filename) {
$filename = (string) $filename; $filename = (string) $filename;
$new = \str_replace($find, $replace, $old = \file_get_contents($filename)); $new = \str_replace($find, $replace, $old = \file_get_contents($filename));
do { do {