Method phpdoc
This commit is contained in:
parent
445c647438
commit
bbb908ac68
@ -74,6 +74,17 @@ class AnnotationsBuilder
|
||||
{
|
||||
\danog\MadelineProto\Logger::log('Creating internal classes...', \danog\MadelineProto\Logger::NOTICE);
|
||||
$handle = \fopen(\dirname(__FILE__).'/InternalDoc.php', 'w');
|
||||
\fwrite($handle, "<?php namespace danog\\MadelineProto; class InternalDoc extends APIFactory {}");
|
||||
|
||||
$class = new \ReflectionClass(API::class);
|
||||
$methods = $class->getMethods(\ReflectionMethod::IS_STATIC | \ReflectionMethod::IS_PUBLIC);
|
||||
$ignoreMethods = [];
|
||||
foreach ($methods as $method) {
|
||||
$ignoreMethods[$method->getName()] = $method->getName();
|
||||
}
|
||||
\fclose($handle);
|
||||
$handle = \fopen(\dirname(__FILE__).'/InternalDoc.php', 'w');
|
||||
|
||||
$internalDoc = [];
|
||||
foreach ($this->methods->by_id as $id => $data) {
|
||||
if (!\strpos($data['method'], '.')) {
|
||||
@ -126,12 +137,15 @@ class AnnotationsBuilder
|
||||
}
|
||||
$internalDoc[$namespace][$method]['return'] = $type;
|
||||
}
|
||||
|
||||
$class = new \ReflectionClass(MTProto::class);
|
||||
$methods = $class->getMethods(\ReflectionMethod::IS_STATIC | \ReflectionMethod::IS_PUBLIC);
|
||||
foreach ($methods as $method) {
|
||||
foreach ($methods as $key => $method) {
|
||||
$name = $method->getName();
|
||||
if ($method == 'method_call_async_read') {
|
||||
unset($methods[\array_search('method_call', $methods)]);
|
||||
} elseif (\strpos($name, '__') === 0) {
|
||||
unset($methods[$key]);
|
||||
} elseif (\stripos($name, 'async') !== false) {
|
||||
if (\strpos($name, '_async') !== false) {
|
||||
unset($methods[\array_search(\str_ireplace('_async', '', $method), $methods)]);
|
||||
@ -142,7 +156,13 @@ class AnnotationsBuilder
|
||||
}
|
||||
foreach ($methods as $method) {
|
||||
$name = $method->getName();
|
||||
if (isset($ignoreMethods[$name])) {
|
||||
continue;
|
||||
}
|
||||
$originalName = $name;
|
||||
if ($originalName === 'loop_async') {
|
||||
$originalName = 'loop';
|
||||
}
|
||||
|
||||
if ($name == 'method_call_async_read') {
|
||||
$name = 'method_call';
|
||||
@ -153,13 +173,15 @@ class AnnotationsBuilder
|
||||
$name = \str_ireplace('async', '', $name);
|
||||
}
|
||||
}
|
||||
$name = \strpos($name, '__') === 0 ? $name : Tools::from_snake_case($name);
|
||||
$name = Tools::from_snake_case($name);
|
||||
$name = \str_ireplace(['mtproto', 'api'], ['MTProto', 'API'], $name);
|
||||
|
||||
$doc = 'public function ';
|
||||
$doc .= $name;
|
||||
|
||||
$doc .= '(';
|
||||
$paramList = '';
|
||||
$hasVariadic = false;
|
||||
foreach ($method->getParameters() as $param) {
|
||||
if ($param->allowsNull()) {
|
||||
//$doc .= '?';
|
||||
@ -168,6 +190,9 @@ class AnnotationsBuilder
|
||||
if ($type->allowsNull()) {
|
||||
$doc .= '?';
|
||||
}
|
||||
if (!$type->isBuiltin()) {
|
||||
$doc .= '\\';
|
||||
}
|
||||
$doc .= $type->getName();
|
||||
$doc .= ' ';
|
||||
}
|
||||
@ -182,14 +207,18 @@ class AnnotationsBuilder
|
||||
if ($param->isOptional() && !$param->isVariadic()) {
|
||||
$doc .= ' = ';
|
||||
if ($param->isDefaultValueConstant()) {
|
||||
$doc .= str_replace(['NULL', 'self'], ['null', 'MTProto'], $param->getDefaultValueConstantName());
|
||||
$doc .= \str_replace(['NULL', 'self'], ['null', 'MTProto'], $param->getDefaultValueConstantName());
|
||||
} else {
|
||||
$doc .= str_replace('NULL', 'null', var_export($param->getDefaultValue(), true));
|
||||
$doc .= \str_replace('NULL', 'null', \var_export($param->getDefaultValue(), true));
|
||||
}
|
||||
}
|
||||
$doc .= ', ';
|
||||
|
||||
|
||||
if ($param->isVariadic()) {
|
||||
$hasVariadic = true;
|
||||
$paramList .= '...';
|
||||
}
|
||||
$paramList .= '$'.$param->getName().', ';
|
||||
}
|
||||
$doc = \rtrim($doc, ', ');
|
||||
@ -202,8 +231,10 @@ class AnnotationsBuilder
|
||||
}
|
||||
$doc .= $type->getName();
|
||||
}
|
||||
$paramList = $hasVariadic ? "Tools::arr($paramList)" : "[$paramList]";
|
||||
|
||||
$doc .= "\n{\n";
|
||||
$doc .= " return \$this->__call('$originalName', [$paramList]);\n";
|
||||
$doc .= " return \$this->__call('$originalName', $paramList);\n";
|
||||
$doc .= "}\n";
|
||||
|
||||
$internalDoc['InternalDoc'][$name]['method'] = $method->getDocComment() ?? '';
|
||||
|
@ -4019,16 +4019,6 @@ interface folders
|
||||
class InternalDoc extends APIFactory
|
||||
{
|
||||
|
||||
public function __construct(...$params)
|
||||
{
|
||||
return $this->__call('__construct', [$params]);
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
{
|
||||
return $this->__call('__sleep', []);
|
||||
}
|
||||
|
||||
public function logger($param, $level = danog\MadelineProto\Logger::NOTICE, $file = null)
|
||||
{
|
||||
return $this->__call('logger', [$param, $level, $file]);
|
||||
@ -4078,11 +4068,6 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('hasAllAuth', []);
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
return $this->__call('serialize', []);
|
||||
}
|
||||
|
||||
public function startLoops()
|
||||
{
|
||||
return $this->__call('startLoops', []);
|
||||
@ -4093,16 +4078,6 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('stopLoops', []);
|
||||
}
|
||||
|
||||
public function __wakeup($backtrace)
|
||||
{
|
||||
return $this->__call('__wakeup_async', [$backtrace]);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
return $this->__call('__destruct', []);
|
||||
}
|
||||
|
||||
public function getSettings($settings, $previousSettings = array (
|
||||
))
|
||||
{
|
||||
@ -4228,26 +4203,6 @@ class InternalDoc extends APIFactory
|
||||
{
|
||||
return $this->__call('getTypeMismatchCallbacks', []);
|
||||
}
|
||||
|
||||
public function __debugInfo()
|
||||
{
|
||||
return $this->__call('__debugInfo', []);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
return $this->__call('initAsync', []);
|
||||
}
|
||||
|
||||
public function setInitPromise($promise)
|
||||
{
|
||||
return $this->__call('setInitPromise', [$promise]);
|
||||
}
|
||||
|
||||
public function fetchserializableobject($hash)
|
||||
{
|
||||
return $this->__call('fetchserializableobject', [$hash]);
|
||||
}
|
||||
/**
|
||||
* Create authorization key.
|
||||
*
|
||||
@ -4268,7 +4223,7 @@ class InternalDoc extends APIFactory
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkG(phpseclib\Math\BigInteger $g_a, phpseclib\Math\BigInteger $p): bool
|
||||
public function checkG(\phpseclib\Math\BigInteger $g_a, \phpseclib\Math\BigInteger $p): bool
|
||||
{
|
||||
return $this->__call('check_G', [$g_a, $p]);
|
||||
}
|
||||
@ -4280,7 +4235,7 @@ class InternalDoc extends APIFactory
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkPG(phpseclib\Math\BigInteger $p, phpseclib\Math\BigInteger $g): bool
|
||||
public function checkPG(\phpseclib\Math\BigInteger $p, \phpseclib\Math\BigInteger $g): bool
|
||||
{
|
||||
return $this->__call('check_p_g', [$p, $g]);
|
||||
}
|
||||
@ -4333,7 +4288,7 @@ class InternalDoc extends APIFactory
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
public function initAuthorizationSocket(string $id, danog\MadelineProto\DataCenterConnection $socket): Generator
|
||||
public function initAuthorizationSocket(string $id, \danog\MadelineProto\DataCenterConnection $socket): Generator
|
||||
{
|
||||
return $this->__call('init_authorization_socket_async', [$id, $socket]);
|
||||
}
|
||||
@ -4735,12 +4690,12 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('handle_encrypted_update_async', [$message, $test]);
|
||||
}
|
||||
|
||||
public function tryMtprotoV1Decrypt($message_key, $chat_id, $old, $encrypted_data)
|
||||
public function tryMTProtoV1Decrypt($message_key, $chat_id, $old, $encrypted_data)
|
||||
{
|
||||
return $this->__call('try_mtproto_v1_decrypt', [$message_key, $chat_id, $old, $encrypted_data]);
|
||||
}
|
||||
|
||||
public function tryMtprotoV2Decrypt($message_key, $chat_id, $old, $encrypted_data)
|
||||
public function tryMTProtoV2Decrypt($message_key, $chat_id, $old, $encrypted_data)
|
||||
{
|
||||
return $this->__call('try_mtproto_v2_decrypt', [$message_key, $chat_id, $old, $encrypted_data]);
|
||||
}
|
||||
@ -4857,7 +4812,7 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('parse_reply_markup', [$markup]);
|
||||
}
|
||||
|
||||
public function mTProtoToBotAPI($data, $sent_arguments = array (
|
||||
public function MTProtoToBotAPI($data, $sent_arguments = array (
|
||||
))
|
||||
{
|
||||
return $this->__call('MTProto_to_botAPI_async', [$data, $sent_arguments]);
|
||||
@ -4918,7 +4873,7 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('rle_encode', [$string]);
|
||||
}
|
||||
|
||||
public function photosizeToBotapi($photoSize, $photo, $thumbnail = false)
|
||||
public function photosizeToBotAPI($photoSize, $photo, $thumbnail = false)
|
||||
{
|
||||
return $this->__call('photosize_to_botapi_async', [$photoSize, $photo, $thumbnail]);
|
||||
}
|
||||
@ -4958,17 +4913,17 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('tdcli_to_td', [$params, $key]);
|
||||
}
|
||||
|
||||
public function tdToMtproto($params)
|
||||
public function tdToMTProto($params)
|
||||
{
|
||||
return $this->__call('td_to_mtproto_async', [$params]);
|
||||
}
|
||||
|
||||
public function mtprotoToTdcli($params)
|
||||
public function MTProtoToTdcli($params)
|
||||
{
|
||||
return $this->__call('mtproto_to_tdcli_async', [$params]);
|
||||
}
|
||||
|
||||
public function mtprotoToTd(&$params)
|
||||
public function MTProtoToTd(&$params)
|
||||
{
|
||||
return $this->__call('mtproto_to_td_async', [$params]);
|
||||
}
|
||||
@ -5126,7 +5081,7 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('is_array_or_alike', [$var]);
|
||||
}
|
||||
/**
|
||||
* Convert to camelCase
|
||||
* Convert to camelCase.
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
@ -5137,7 +5092,7 @@ class InternalDoc extends APIFactory
|
||||
return $this->__call('from_snake_case', [$input]);
|
||||
}
|
||||
/**
|
||||
* Convert to snake_case
|
||||
* Convert to snake_case.
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
@ -5147,6 +5102,17 @@ class InternalDoc extends APIFactory
|
||||
{
|
||||
return $this->__call('from_camel_case', [$input]);
|
||||
}
|
||||
/**
|
||||
* Create array
|
||||
*
|
||||
* @param mixed ...$params Params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function arr(...$params): array
|
||||
{
|
||||
return $this->__call('arr', Tools::arr(...$params));
|
||||
}
|
||||
|
||||
public function requestCall($user)
|
||||
{
|
||||
@ -5283,7 +5249,7 @@ class InternalDoc extends APIFactory
|
||||
|
||||
public function loop($max_forks = 0)
|
||||
{
|
||||
return $this->__call('loop_async', [$max_forks]);
|
||||
return $this->__call('loop', [$max_forks]);
|
||||
}
|
||||
|
||||
public function closeConnection($message = 'OK!')
|
||||
|
@ -552,7 +552,6 @@ class MTProto extends AsyncConstruct implements TLCallback
|
||||
}
|
||||
public function a(callable $a, ?string $b = null, $c = null, $d = 2, $e = self::METHOD_BEFORE_CALLBACK): ?string
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* Get all datacenter connections.
|
||||
|
@ -21,7 +21,6 @@ namespace danog\MadelineProto\MTProtoSession;
|
||||
|
||||
use Amp\Loop;
|
||||
use danog\MadelineProto\MTProto;
|
||||
use danog\MadelineProto\TL\PrettyException;
|
||||
|
||||
/**
|
||||
* Manages responses.
|
||||
@ -309,7 +308,7 @@ trait ResponseHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Reject request with exception
|
||||
* Reject request with exception.
|
||||
*
|
||||
* @param array $request Request
|
||||
* @param \Throwable $data Exception
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
namespace danog\MadelineProto\TL;
|
||||
|
||||
use danog\MadelineProto\Tools;
|
||||
|
||||
/**
|
||||
* Handle async stack traces.
|
||||
*/
|
||||
|
@ -450,7 +450,7 @@ trait Tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to camelCase
|
||||
* Convert to camelCase.
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
@ -458,10 +458,10 @@ trait Tools
|
||||
*/
|
||||
public static function from_snake_case(string $input): string
|
||||
{
|
||||
return lcfirst(str_replace('_', '', ucwords($input, '_')));
|
||||
return \lcfirst(\str_replace('_', '', \ucwords($input, '_')));
|
||||
}
|
||||
/**
|
||||
* Convert to snake_case
|
||||
* Convert to snake_case.
|
||||
*
|
||||
* @param string $input
|
||||
*
|
||||
@ -477,4 +477,16 @@ trait Tools
|
||||
|
||||
return \implode('_', $ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create array
|
||||
*
|
||||
* @param mixed ...$params Params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function arr(...$params): array
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
@ -20,24 +20,24 @@
|
||||
namespace danog\MadelineProto;
|
||||
|
||||
/**
|
||||
* Represents a piece of a coroutine stack trace
|
||||
* Represents a piece of a coroutine stack trace.
|
||||
*/
|
||||
class Trace
|
||||
{
|
||||
/**
|
||||
* Next piece of the stack trace
|
||||
* Next piece of the stack trace.
|
||||
*
|
||||
* @var Trace
|
||||
*/
|
||||
private $next;
|
||||
/**
|
||||
* Current stack trace frames
|
||||
* Current stack trace frames.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $frames = [];
|
||||
/**
|
||||
* Create trace
|
||||
* Create trace.
|
||||
*
|
||||
* @param array $frames Current frames
|
||||
* @param self $next Next trace
|
||||
@ -49,17 +49,17 @@ class Trace
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stack trace
|
||||
* Get stack trace.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTrace(): array
|
||||
{
|
||||
return iterator_to_array($this->getTraceGenerator());
|
||||
return \iterator_to_array($this->getTraceGenerator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stack trace
|
||||
* Get stack trace.
|
||||
*
|
||||
* @return \Generator
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user