Fix type hinting (now, make sure the API is start()ed before calling get methods
This commit is contained in:
parent
918756cb88
commit
a63131583b
@ -160,7 +160,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
||||
$this->logger((string) $e, \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
}
|
||||
if ($e instanceof RPCErrorException && $e->rpc === 'FILE_PARTS_INVALID') {
|
||||
$this->report(json_encode($url));
|
||||
$this->report(\json_encode($url));
|
||||
}
|
||||
try {
|
||||
yield $this->messages->editMessage(['peer' => $peerId, 'id' => $id, 'message' => 'Error: '.$e->getMessage()]);
|
||||
|
@ -274,15 +274,18 @@ class AnnotationsBuilder
|
||||
|
||||
$ret = $type && $type->getName() === 'void' ? '' : 'return';
|
||||
|
||||
$doc .= "\n{\n";
|
||||
if ($async || !$static) {
|
||||
$doc .= "\n{\n";
|
||||
$doc .= " $ret \$this->__call(__FUNCTION__, $finalParamList);\n";
|
||||
$doc .= "}\n";
|
||||
if ($async) {
|
||||
$doc .= " $ret \$this->__call(__FUNCTION__, $finalParamList);\n";
|
||||
} else {
|
||||
$doc .= " $ret \$this->API->$name($paramList);\n";
|
||||
}
|
||||
} else {
|
||||
$doc .= "\n{\n";
|
||||
$doc .= " $ret \\".$method->getDeclaringClass()->getName()."::".$name."($paramList);\n";
|
||||
$doc .= "}\n";
|
||||
}
|
||||
$doc .= "}\n";
|
||||
|
||||
|
||||
if (!$method->getDocComment()) {
|
||||
Logger::log("$name has no PHPDOC!", Logger::FATAL_ERROR);
|
||||
|
@ -4031,7 +4031,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function cleanup(array $extra = []): \danog\MadelineProto\MTProto
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->cleanup($extra);
|
||||
}
|
||||
/**
|
||||
* Logger.
|
||||
@ -4044,7 +4044,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function logger($param, int $level = \danog\MadelineProto\Logger::NOTICE, string $file = '', array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$param, $level, $file, $extra]);
|
||||
$this->API->logger($param, $level, $file, $extra);
|
||||
}
|
||||
/**
|
||||
* Get TL namespaces.
|
||||
@ -4053,7 +4053,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getMethodNamespaces(array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getMethodNamespaces($extra);
|
||||
}
|
||||
/**
|
||||
* Get namespaced methods (method => namespace).
|
||||
@ -4062,7 +4062,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getMethodsNamespaced(array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getMethodsNamespaced($extra);
|
||||
}
|
||||
/**
|
||||
* Get TL serializer.
|
||||
@ -4071,7 +4071,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getTL(array $extra = []): \danog\MadelineProto\TL\TL
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getTL($extra);
|
||||
}
|
||||
/**
|
||||
* Get logger.
|
||||
@ -4080,7 +4080,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getLogger(array $extra = []): \danog\MadelineProto\Logger
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getLogger($extra);
|
||||
}
|
||||
/**
|
||||
* Get async HTTP client.
|
||||
@ -4089,7 +4089,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getHTTPClient(array $extra = []): \Amp\Http\Client\DelegateHttpClient
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getHTTPClient($extra);
|
||||
}
|
||||
/**
|
||||
* Get async DNS client.
|
||||
@ -4098,7 +4098,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getDNSClient(array $extra = []): \Amp\Dns\Resolver
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getDNSClient($extra);
|
||||
}
|
||||
/**
|
||||
* Get contents of remote file asynchronously.
|
||||
@ -4118,7 +4118,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getDataCenterConnections(array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getDataCenterConnections($extra);
|
||||
}
|
||||
/**
|
||||
* Get correct settings array for the latest version.
|
||||
@ -4140,7 +4140,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setupLogger(array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$extra]);
|
||||
$this->API->setupLogger($extra);
|
||||
}
|
||||
/**
|
||||
* Checks whether all datacenters are authorized.
|
||||
@ -4149,7 +4149,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function hasAllAuth(array $extra = []): bool
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->hasAllAuth($extra);
|
||||
}
|
||||
/**
|
||||
* Connects to all datacenters and if necessary creates authorization keys, binds them and writes client info.
|
||||
@ -4169,7 +4169,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function resetUpdateState(array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$extra]);
|
||||
$this->API->resetUpdateState($extra);
|
||||
}
|
||||
/**
|
||||
* Store RSA keys for CDN datacenters.
|
||||
@ -4189,7 +4189,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getCachedConfig(array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getCachedConfig($extra);
|
||||
}
|
||||
/**
|
||||
* Get cached (or eventually re-fetch) server-side config.
|
||||
@ -4214,18 +4214,6 @@ class InternalDoc extends APIFactory
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
}
|
||||
/**
|
||||
* Check validity of g_a parameters.
|
||||
*
|
||||
* @param BigInteger $g_a
|
||||
* @param BigInteger $p
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkG(\tgseclib\Math\BigInteger $g_a, \tgseclib\Math\BigInteger $p, array $extra = []): bool
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$g_a, $p, $extra]);
|
||||
}
|
||||
/**
|
||||
* Call method and wait asynchronously for response.
|
||||
*
|
||||
@ -4302,7 +4290,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function addUser(array $user, array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$user, $extra]);
|
||||
$this->API->addUser($user, $extra);
|
||||
}
|
||||
/**
|
||||
* Check if peer is present in internal peer database.
|
||||
@ -4360,7 +4348,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function fullChatLastUpdated($id, array $extra = []): int
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$id, $extra]);
|
||||
return $this->API->fullChatLastUpdated($id, $extra);
|
||||
}
|
||||
/**
|
||||
* Get full info about peer, returns an FullInfo object.
|
||||
@ -4638,7 +4626,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function secretChatStatus(int $chat, array $extra = []): int
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$chat, $extra]);
|
||||
return $this->API->secretChatStatus($chat, $extra);
|
||||
}
|
||||
/**
|
||||
* Get secret chat.
|
||||
@ -4649,7 +4637,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getSecretChat($chat, array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$chat, $extra]);
|
||||
return $this->API->getSecretChat($chat, $extra);
|
||||
}
|
||||
/**
|
||||
* Check whether secret chat exists.
|
||||
@ -4660,7 +4648,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function hasSecretChat($chat, array $extra = []): bool
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$chat, $extra]);
|
||||
return $this->API->hasSecretChat($chat, $extra);
|
||||
}
|
||||
/**
|
||||
* Discard secret chat.
|
||||
@ -4742,7 +4730,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function unpackFileId(string $file_id, array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$file_id, $extra]);
|
||||
return $this->API->unpackFileId($file_id, $extra);
|
||||
}
|
||||
/**
|
||||
* Get mime type from file extension.
|
||||
@ -4811,7 +4799,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function tdcliToTd(&$params, $key = null, array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$params, $key, $extra]);
|
||||
return $this->API->tdcliToTd($params, $key, $extra);
|
||||
}
|
||||
/**
|
||||
* Convert TD to MTProto parameters.
|
||||
@ -5379,7 +5367,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function callStatus(int $id, array $extra = []): int
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$id, $extra]);
|
||||
return $this->API->callStatus($id, $extra);
|
||||
}
|
||||
/**
|
||||
* Get call info.
|
||||
@ -5390,7 +5378,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getCall(int $call, array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$call, $extra]);
|
||||
return $this->API->getCall($call, $extra);
|
||||
}
|
||||
/**
|
||||
* Check state of calls.
|
||||
@ -5399,7 +5387,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function checkCalls(array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$extra]);
|
||||
$this->API->checkCalls($extra);
|
||||
}
|
||||
/**
|
||||
* Get dialog peers.
|
||||
@ -5432,7 +5420,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setEventHandler($event_handler, array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$event_handler, $extra]);
|
||||
$this->API->setEventHandler($event_handler, $extra);
|
||||
}
|
||||
/**
|
||||
* Get event handler.
|
||||
@ -5441,7 +5429,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getEventHandler(array $extra = []): \EventHandler
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getEventHandler($extra);
|
||||
}
|
||||
/**
|
||||
* Set webhook update handler.
|
||||
@ -5453,7 +5441,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setWebhook(string $hook_url, string $pem_path = '', array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$hook_url, $pem_path, $extra]);
|
||||
$this->API->setWebhook($hook_url, $pem_path, $extra);
|
||||
}
|
||||
/**
|
||||
* Set update handling callback.
|
||||
@ -5464,7 +5452,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setCallback($callback, array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$callback, $extra]);
|
||||
$this->API->setCallback($callback, $extra);
|
||||
}
|
||||
/**
|
||||
* Log out currently logged in user.
|
||||
@ -5574,7 +5562,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setLoopCallback($callback, array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$callback, $extra]);
|
||||
$this->API->setLoopCallback($callback, $extra);
|
||||
}
|
||||
/**
|
||||
* Start MadelineProto's update handling loop, or run the provided async callable.
|
||||
@ -5596,7 +5584,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function closeConnection($message = 'OK!', array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$message, $extra]);
|
||||
$this->API->closeConnection($message, $extra);
|
||||
}
|
||||
/**
|
||||
* Set NOOP update handler, ignoring all updates.
|
||||
@ -5605,7 +5593,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setNoop(array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$extra]);
|
||||
$this->API->setNoop($extra);
|
||||
}
|
||||
/**
|
||||
* Log in to telegram (via CLI or web).
|
||||
@ -5623,7 +5611,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getWebTemplate(array $extra = []): string
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getWebTemplate($extra);
|
||||
}
|
||||
/**
|
||||
* Set web template.
|
||||
@ -5634,7 +5622,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function setWebTemplate(string $template, array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$template, $extra]);
|
||||
$this->API->setWebTemplate($template, $extra);
|
||||
}
|
||||
/**
|
||||
* Check for terms of service update.
|
||||
|
@ -440,6 +440,8 @@ trait AuthKeyHandler
|
||||
* @param BigInteger $g_a
|
||||
* @param BigInteger $p
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkG(BigInteger $g_a, BigInteger $p): bool
|
||||
@ -663,7 +665,9 @@ trait AuthKeyHandler
|
||||
$dcs = [];
|
||||
$postpone = [];
|
||||
foreach ($this->datacenter->getDataCenterConnections() as $id => $socket) {
|
||||
if (!$socket->hasCtx()) continue;
|
||||
if (!$socket->hasCtx()) {
|
||||
continue;
|
||||
}
|
||||
if ($socket->isMedia()) {
|
||||
$oid = \intval($id);
|
||||
if (isset($dcs[$oid])) {
|
||||
|
@ -885,7 +885,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function logger($param, int $level = \danog\MadelineProto\Logger::NOTICE, string $file = '', array $extra = []): void
|
||||
{
|
||||
$this->__call(__FUNCTION__, [$param, $level, $file, $extra]);
|
||||
$this->API->logger($param, $level, $file, $extra);
|
||||
}
|
||||
/**
|
||||
* Call lite method.
|
||||
@ -921,7 +921,7 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function botAPItoMTProto(array $parameters, array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$parameters, $extra]);
|
||||
return $this->API->botAPItoMTProto($parameters, $extra);
|
||||
}
|
||||
/**
|
||||
* Get TL method namespaces.
|
||||
@ -930,6 +930,6 @@ class InternalDoc extends APIFactory
|
||||
*/
|
||||
public function getMethodNamespaces(array $extra = []): array
|
||||
{
|
||||
return $this->__call(__FUNCTION__, [$extra]);
|
||||
return $this->API->getMethodNamespaces($extra);
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,9 @@ echo 'Loading MadelineProto...'.PHP_EOL;
|
||||
$MadelineProto = new \danog\MadelineProto\API(__DIR__.'/../testing.madeline', $settings);
|
||||
$MadelineProto->async(true);
|
||||
$MadelineProto->loop(function () use ($MadelineProto) {
|
||||
yield $MadelineProto->fileGetContents('https://google.com');
|
||||
yield $MadelineProto->start();
|
||||
$MadelineProto->getHttpClient();
|
||||
yield $MadelineProto->fileGetContents('https://google.com');
|
||||
|
||||
try {
|
||||
yield $MadelineProto->getSelf();
|
||||
|
Loading…
Reference in New Issue
Block a user