Add missing return typehints
This commit is contained in:
parent
05a859ea50
commit
ca2cbe4ecb
@ -131,9 +131,9 @@ final class APIWrapper
|
|||||||
/**
|
/**
|
||||||
* Get MTProto instance.
|
* Get MTProto instance.
|
||||||
*
|
*
|
||||||
* @return MTProto|null
|
* @return Client|MTProto|null
|
||||||
*/
|
*/
|
||||||
public function &getAPI(): ?MTProto
|
public function &getAPI()
|
||||||
{
|
{
|
||||||
return $this->API;
|
return $this->API;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class AnnotationsBuilder
|
|||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
}
|
}
|
||||||
public function mkAnnotations()
|
public function mkAnnotations(): void
|
||||||
{
|
{
|
||||||
\danog\MadelineProto\Logger::log('Generating annotations...', \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log('Generating annotations...', \danog\MadelineProto\Logger::NOTICE);
|
||||||
$this->setProperties();
|
$this->setProperties();
|
||||||
|
@ -56,7 +56,7 @@ trait Templates
|
|||||||
/**
|
/**
|
||||||
* Set web API login HTML template string.
|
* Set web API login HTML template string.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setWebAPITemplate(string $template): void
|
public function setWebAPITemplate(string $template): void
|
||||||
{
|
{
|
||||||
|
@ -319,7 +319,9 @@ class Connection extends Session
|
|||||||
*
|
*
|
||||||
* @param ConnectionContext $ctx Connection context
|
* @param ConnectionContext $ctx Connection context
|
||||||
*
|
*
|
||||||
* @return \Amp\Promise
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<mixed, StreamInterface, mixed, void>
|
||||||
*/
|
*/
|
||||||
public function connect(ConnectionContext $ctx): \Generator
|
public function connect(ConnectionContext $ctx): \Generator
|
||||||
{
|
{
|
||||||
@ -475,9 +477,9 @@ class Connection extends Session
|
|||||||
/**
|
/**
|
||||||
* Get main instance.
|
* Get main instance.
|
||||||
*
|
*
|
||||||
* @return MTProto
|
* @return MTProtoSession\MTProto
|
||||||
*/
|
*/
|
||||||
public function getExtra()
|
public function getExtra(): MTProtoSession\MTProto
|
||||||
{
|
{
|
||||||
return $this->API;
|
return $this->API;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,10 @@ final class Coroutine implements Promise, \ArrayAccess
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param \Throwable $reason Failure reason.
|
* @param \Throwable $reason Failure reason.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function fail(\Throwable $reason)
|
public function fail(\Throwable $reason): void
|
||||||
{
|
{
|
||||||
$this->resolve(new Failure($reason));
|
$this->resolve(new Failure($reason));
|
||||||
}
|
}
|
||||||
@ -199,7 +201,7 @@ final class Coroutine implements Promise, \ArrayAccess
|
|||||||
return $result[$offset];
|
return $result[$offset];
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
public function offsetSet($offset, $value)
|
public function offsetSet($offset, $value): Promise
|
||||||
{
|
{
|
||||||
return Tools::call((function () use ($offset, $value): \Generator {
|
return Tools::call((function () use ($offset, $value): \Generator {
|
||||||
$result = yield $this;
|
$result = yield $this;
|
||||||
@ -209,7 +211,7 @@ final class Coroutine implements Promise, \ArrayAccess
|
|||||||
return $result[$offset] = $value;
|
return $result[$offset] = $value;
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
public function offsetUnset($offset)
|
public function offsetUnset($offset): Promise
|
||||||
{
|
{
|
||||||
return Tools::call((function () use ($offset): \Generator {
|
return Tools::call((function () use ($offset): \Generator {
|
||||||
$result = yield $this;
|
$result = yield $this;
|
||||||
|
@ -546,7 +546,9 @@ class DataCenter
|
|||||||
*
|
*
|
||||||
* @param string $url URL to fetch
|
* @param string $url URL to fetch
|
||||||
*
|
*
|
||||||
* @return \Generator<string>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, \Amp\Promise<string>, mixed, string>
|
||||||
*/
|
*/
|
||||||
public function fileGetContents(string $url): \Generator
|
public function fileGetContents(string $url): \Generator
|
||||||
{
|
{
|
||||||
@ -579,7 +581,9 @@ class DataCenter
|
|||||||
*
|
*
|
||||||
* @param string $dc DC ID
|
* @param string $dc DC ID
|
||||||
*
|
*
|
||||||
* @return \Generator<Connection>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, \Amp\Promise, mixed, Connection>
|
||||||
*/
|
*/
|
||||||
public function waitGetConnection(string $dc): \Generator
|
public function waitGetConnection(string $dc): \Generator
|
||||||
{
|
{
|
||||||
|
@ -507,16 +507,18 @@ class DataCenterConnection implements JsonSerializable
|
|||||||
*
|
*
|
||||||
* @param integer $id Connection ID
|
* @param integer $id Connection ID
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
public function hasConnection(int $id = -1): bool
|
public function hasConnection(int $id = -1)
|
||||||
{
|
{
|
||||||
return $id < 0 ? \count($this->connections) : isset($this->connections[$id]);
|
return $id < 0 ? \count($this->connections) : isset($this->connections[$id]);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get best socket in round robin, asynchronously.
|
* Get best socket in round robin, asynchronously.
|
||||||
*
|
*
|
||||||
* @return \Generator<Connection>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise, mixed, Connection>
|
||||||
*/
|
*/
|
||||||
public function waitGetConnection(): \Generator
|
public function waitGetConnection(): \Generator
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@ class Redis
|
|||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $db
|
* @param string $db
|
||||||
*
|
|
||||||
* @param int $maxConnections
|
* @param int $maxConnections
|
||||||
* @param int $idleTimeout
|
* @param int $idleTimeout
|
||||||
*
|
*
|
||||||
@ -26,7 +25,9 @@ class Redis
|
|||||||
* @throws \Amp\Sql\FailureException
|
* @throws \Amp\Sql\FailureException
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*
|
*
|
||||||
* @return \Generator<RedisRedis>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, \Amp\Promise<void>, mixed, RedisRedis>
|
||||||
*/
|
*/
|
||||||
public static function getConnection(DatabaseRedis $settings): \Generator
|
public static function getConnection(DatabaseRedis $settings): \Generator
|
||||||
{
|
{
|
||||||
|
@ -198,8 +198,11 @@ class MysqlArray extends SqlArray
|
|||||||
/**
|
/**
|
||||||
* Create table for property.
|
* Create table for property.
|
||||||
*
|
*
|
||||||
* @return array|null
|
* @return \Generator
|
||||||
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
protected function prepareTable(): \Generator
|
protected function prepareTable(): \Generator
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,9 @@ namespace danog\MadelineProto\Db\NullCache;
|
|||||||
|
|
||||||
trait NullCacheTrait
|
trait NullCacheTrait
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function getCache(string $key, $default = null)
|
protected function getCache(string $key, $default = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,11 @@ class PostgresArray extends SqlArray
|
|||||||
/**
|
/**
|
||||||
* Create table for property.
|
* Create table for property.
|
||||||
*
|
*
|
||||||
* @return array|null
|
* @return \Generator
|
||||||
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise, mixed, void>
|
||||||
*/
|
*/
|
||||||
protected function prepareTable(): \Generator
|
protected function prepareTable(): \Generator
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,11 @@ class RedisArray extends SqlArray
|
|||||||
// Legacy
|
// Legacy
|
||||||
protected array $settings;
|
protected array $settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Generator
|
||||||
|
*
|
||||||
|
* @psalm-return Generator<int, Success<null>, mixed, void>
|
||||||
|
*/
|
||||||
protected function prepareTable(): Generator
|
protected function prepareTable(): Generator
|
||||||
{
|
{
|
||||||
yield new Success;
|
yield new Success;
|
||||||
|
@ -75,7 +75,7 @@ class DocsBuilder
|
|||||||
|
|
||||||
public $types = [];
|
public $types = [];
|
||||||
public $any = '*';
|
public $any = '*';
|
||||||
public function mkDocs()
|
public function mkDocs(): void
|
||||||
{
|
{
|
||||||
\danog\MadelineProto\Logger::log('Generating documentation index...', \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log('Generating documentation index...', \danog\MadelineProto\Logger::NOTICE);
|
||||||
\file_put_contents($this->index, $this->template('index', $this->settings['title'], $this->settings['description']));
|
\file_put_contents($this->index, $this->template('index', $this->settings['title'], $this->settings['description']));
|
||||||
@ -145,7 +145,7 @@ class DocsBuilder
|
|||||||
}
|
}
|
||||||
\danog\MadelineProto\Logger::log('Done!', \danog\MadelineProto\Logger::NOTICE);
|
\danog\MadelineProto\Logger::log('Done!', \danog\MadelineProto\Logger::NOTICE);
|
||||||
}
|
}
|
||||||
public static function addToLang(string $key, string $value = '', bool $force = false)
|
public static function addToLang(string $key, string $value = '', bool $force = false): void
|
||||||
{
|
{
|
||||||
if (!isset(\danog\MadelineProto\Lang::$lang['en'][$key]) || $force) {
|
if (!isset(\danog\MadelineProto\Lang::$lang['en'][$key]) || $force) {
|
||||||
\danog\MadelineProto\Lang::$lang['en'][$key] = $value;
|
\danog\MadelineProto\Lang::$lang['en'][$key] = $value;
|
||||||
|
@ -24,7 +24,7 @@ use danog\MadelineProto\Tools;
|
|||||||
|
|
||||||
trait Constructors
|
trait Constructors
|
||||||
{
|
{
|
||||||
public function mkConstructors()
|
public function mkConstructors(): void
|
||||||
{
|
{
|
||||||
foreach (\glob('constructors/'.$this->any) as $unlink) {
|
foreach (\glob('constructors/'.$this->any) as $unlink) {
|
||||||
\unlink($unlink);
|
\unlink($unlink);
|
||||||
|
@ -24,7 +24,7 @@ use danog\MadelineProto\Tools;
|
|||||||
|
|
||||||
trait Methods
|
trait Methods
|
||||||
{
|
{
|
||||||
public function mkMethods()
|
public function mkMethods(): void
|
||||||
{
|
{
|
||||||
static $bots;
|
static $bots;
|
||||||
if (!$bots) {
|
if (!$bots) {
|
||||||
|
@ -75,8 +75,10 @@ class Exception extends \Exception
|
|||||||
* ExceptionErrorHandler.
|
* ExceptionErrorHandler.
|
||||||
*
|
*
|
||||||
* Error handler
|
* Error handler
|
||||||
|
*
|
||||||
|
* @return false
|
||||||
*/
|
*/
|
||||||
public static function exceptionErrorHandler($errno = 0, $errstr = null, $errfile = null, $errline = null)
|
public static function exceptionErrorHandler($errno = 0, $errstr = null, $errfile = null, $errline = null): bool
|
||||||
{
|
{
|
||||||
// If error is suppressed with @, don't throw an exception
|
// If error is suppressed with @, don't throw an exception
|
||||||
if (\error_reporting() === 0 || \strpos($errstr, 'headers already sent') || $errfile && (\strpos($errfile, 'vendor/amphp') !== false || \strpos($errfile, 'vendor/league') !== false)) {
|
if (\error_reporting() === 0 || \strpos($errstr, 'headers already sent') || $errfile && (\strpos($errfile, 'vendor/amphp') !== false || \strpos($errfile, 'vendor/league') !== false)) {
|
||||||
@ -88,8 +90,10 @@ class Exception extends \Exception
|
|||||||
* ExceptionErrorHandler.
|
* ExceptionErrorHandler.
|
||||||
*
|
*
|
||||||
* Error handler
|
* Error handler
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function exceptionHandler($exception)
|
public static function exceptionHandler($exception): void
|
||||||
{
|
{
|
||||||
Logger::log($exception, Logger::FATAL_ERROR);
|
Logger::log($exception, Logger::FATAL_ERROR);
|
||||||
Magic::shutdown(1);
|
Magic::shutdown(1);
|
||||||
|
@ -140,7 +140,9 @@ class Client extends ClientAbstract
|
|||||||
* @param boolean $seekable Whether chunks can be fetched out of order
|
* @param boolean $seekable Whether chunks can be fetched out of order
|
||||||
* @param boolean $encrypted Whether to encrypt file for secret chats
|
* @param boolean $encrypted Whether to encrypt file for secret chats
|
||||||
*
|
*
|
||||||
* @return \Generator<array>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise<ChannelledSocket>|Promise<mixed>, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function uploadFromCallable(callable $callable, int $size, string $mime, string $fileName = '', $cb = null, bool $seekable = true, bool $encrypted = false): \Generator
|
public function uploadFromCallable(callable $callable, int $size, string $mime, string $fileName = '', $cb = null, bool $seekable = true, bool $encrypted = false): \Generator
|
||||||
{
|
{
|
||||||
@ -161,7 +163,9 @@ class Client extends ClientAbstract
|
|||||||
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
||||||
* @param boolean $encrypted Whether to encrypt file for secret chats
|
* @param boolean $encrypted Whether to encrypt file for secret chats
|
||||||
*
|
*
|
||||||
* @return \Generator<array>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise<ChannelledSocket>|Promise<mixed>, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function uploadFromTgfile($media, $cb = null, bool $encrypted = false): \Generator
|
public function uploadFromTgfile($media, $cb = null, bool $encrypted = false): \Generator
|
||||||
{
|
{
|
||||||
@ -181,7 +185,9 @@ class Client extends ClientAbstract
|
|||||||
* @param string|FileCallbackInterface $dir Directory where to download the file
|
* @param string|FileCallbackInterface $dir Directory where to download the file
|
||||||
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
||||||
*
|
*
|
||||||
* @return \Generator<string> Downloaded file path
|
* @return \Generator Downloaded file path
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise<ChannelledSocket>|Promise<mixed>, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function downloadToDir($messageMedia, $dir, $cb = null): \Generator
|
public function downloadToDir($messageMedia, $dir, $cb = null): \Generator
|
||||||
{
|
{
|
||||||
@ -201,7 +207,9 @@ class Client extends ClientAbstract
|
|||||||
* @param string|FileCallbackInterface $file Downloaded file path
|
* @param string|FileCallbackInterface $file Downloaded file path
|
||||||
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
||||||
*
|
*
|
||||||
* @return \Generator<string> Downloaded file path
|
* @return \Generator Downloaded file path
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise<ChannelledSocket>|Promise<mixed>, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function downloadToFile($messageMedia, $file, $cb = null): \Generator
|
public function downloadToFile($messageMedia, $file, $cb = null): \Generator
|
||||||
{
|
{
|
||||||
@ -228,7 +236,9 @@ class Client extends ClientAbstract
|
|||||||
* @param int $end Offset where to stop downloading (inclusive)
|
* @param int $end Offset where to stop downloading (inclusive)
|
||||||
* @param int $part_size Size of each chunk
|
* @param int $part_size Size of each chunk
|
||||||
*
|
*
|
||||||
* @return \Generator<bool>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise<ChannelledSocket>|Promise<mixed>, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function downloadToCallable($messageMedia, callable $callable, $cb = null, bool $seekable = true, int $offset = 0, int $end = -1, int $part_size = null): \Generator
|
public function downloadToCallable($messageMedia, callable $callable, $cb = null, bool $seekable = true, int $offset = 0, int $end = -1, int $part_size = null): \Generator
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,9 @@ abstract class ClientAbstract
|
|||||||
/**
|
/**
|
||||||
* Disconnect cleanly from main instance.
|
* Disconnect cleanly from main instance.
|
||||||
*
|
*
|
||||||
* @return Promise
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise, mixed, void>
|
||||||
*/
|
*/
|
||||||
public function disconnect(): \Generator
|
public function disconnect(): \Generator
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ final class ExitFailure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getException()
|
public function getException(): object
|
||||||
{
|
{
|
||||||
$previous = $this->previous ? $this->previous->getException() : null;
|
$previous = $this->previous ? $this->previous->getException() : null;
|
||||||
|
|
||||||
|
@ -247,11 +247,11 @@ class FeedLoop extends ResumableSignalLoop
|
|||||||
$this->incomingUpdates[] = $update;
|
$this->incomingUpdates[] = $update;
|
||||||
return $this->channelId;
|
return $this->channelId;
|
||||||
}
|
}
|
||||||
public function save($update)
|
public function save($update): void
|
||||||
{
|
{
|
||||||
$this->parsedUpdates[] = $update;
|
$this->parsedUpdates[] = $update;
|
||||||
}
|
}
|
||||||
public function saveMessages($messages)
|
public function saveMessages($messages): void
|
||||||
{
|
{
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
if (!$this->API->checkMsgId($message)) {
|
if (!$this->API->checkMsgId($message)) {
|
||||||
|
@ -114,7 +114,7 @@ class SeqLoop extends ResumableSignalLoop
|
|||||||
yield from $this->save($update);
|
yield from $this->save($update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function feed($updates)
|
public function feed($updates): void
|
||||||
{
|
{
|
||||||
$this->API->logger->logger('Was fed updates of type '.$updates['_'].'...', \danog\MadelineProto\Logger::VERBOSE);
|
$this->API->logger->logger('Was fed updates of type '.$updates['_'].'...', \danog\MadelineProto\Logger::VERBOSE);
|
||||||
$this->incomingUpdates[] = $updates;
|
$this->incomingUpdates[] = $updates;
|
||||||
@ -123,7 +123,7 @@ class SeqLoop extends ResumableSignalLoop
|
|||||||
{
|
{
|
||||||
$this->pendingWakeups += (yield from $this->feeder->feed($updates['updates']));
|
$this->pendingWakeups += (yield from $this->feeder->feed($updates['updates']));
|
||||||
}
|
}
|
||||||
public function addPendingWakeups($wakeups)
|
public function addPendingWakeups($wakeups): void
|
||||||
{
|
{
|
||||||
$this->pendingWakeups += $wakeups;
|
$this->pendingWakeups += $wakeups;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,9 @@ class Lua
|
|||||||
$this->MadelineProto->{$namespace}->lua = true;
|
$this->MadelineProto->{$namespace}->lua = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return \Generator|int
|
||||||
|
*/
|
||||||
public function tdcliFunction($params, $cb = null, $cb_extra = null)
|
public function tdcliFunction($params, $cb = null, $cb_extra = null)
|
||||||
{
|
{
|
||||||
$params = $this->MadelineProto->td_to_mtproto($this->MadelineProto->tdcliToTd($params));
|
$params = $this->MadelineProto->td_to_mtproto($this->MadelineProto->tdcliToTd($params));
|
||||||
@ -96,7 +99,7 @@ class Lua
|
|||||||
self::convertObjects($result);
|
self::convertObjects($result);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
public function tdcliUpdateCallback($update)
|
public function tdcliUpdateCallback($update): void
|
||||||
{
|
{
|
||||||
$this->Lua->tdcliUpdateCallback($this->MadelineProto->mtproto_to_tdcli($update));
|
$this->Lua->tdcliUpdateCallback($this->MadelineProto->mtproto_to_tdcli($update));
|
||||||
}
|
}
|
||||||
@ -111,7 +114,7 @@ class Lua
|
|||||||
}, \array_flip($array)));
|
}, \array_flip($array)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function isSequential(array $arr)
|
private function isSequential(array $arr): bool
|
||||||
{
|
{
|
||||||
if ([] === $arr) {
|
if ([] === $arr) {
|
||||||
return false;
|
return false;
|
||||||
@ -150,7 +153,7 @@ class Lua
|
|||||||
{
|
{
|
||||||
return $this->Lua->{$name} = $value;
|
return $this->Lua->{$name} = $value;
|
||||||
}
|
}
|
||||||
public static function convertObjects(&$data)
|
public static function convertObjects(&$data): void
|
||||||
{
|
{
|
||||||
\array_walk_recursive($data, function (&$value, $key) {
|
\array_walk_recursive($data, function (&$value, $key) {
|
||||||
if (\is_object($value) && !$value instanceof \tgseclib\Math\BigInteger) {
|
if (\is_object($value) && !$value instanceof \tgseclib\Math\BigInteger) {
|
||||||
|
@ -166,9 +166,9 @@ class TempAuthKey extends AuthKey implements JsonSerializable
|
|||||||
/**
|
/**
|
||||||
* Wakeup function.
|
* Wakeup function.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __wakeup()
|
public function __wakeup(): void
|
||||||
{
|
{
|
||||||
$this->inited = (bool) $this->inited;
|
$this->inited = (bool) $this->inited;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ use danog\MadelineProto\MTProto;
|
|||||||
trait ResponseHandler
|
trait ResponseHandler
|
||||||
{
|
{
|
||||||
public $n = 0;
|
public $n = 0;
|
||||||
public function handleMessages()
|
public function handleMessages(): bool
|
||||||
{
|
{
|
||||||
$only_updates = true;
|
$only_updates = true;
|
||||||
while ($this->new_incoming) {
|
while ($this->new_incoming) {
|
||||||
@ -287,6 +287,9 @@ trait ResponseHandler
|
|||||||
$this->logger->logger("Rejecting: {$data}");
|
$this->logger->logger("Rejecting: {$data}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function handleResponse($request_id, $response_id)
|
public function handleResponse($request_id, $response_id)
|
||||||
{
|
{
|
||||||
$response =& $this->incoming_messages[$response_id]['content'];
|
$response =& $this->incoming_messages[$response_id]['content'];
|
||||||
|
@ -37,7 +37,7 @@ trait SeqNoHandler
|
|||||||
//$this->API->logger->logger("OUT: $value + $in = ".$this->session_out_seq_no);
|
//$this->API->logger->logger("OUT: $value + $in = ".$this->session_out_seq_no);
|
||||||
return $value * 2 + $in;
|
return $value * 2 + $in;
|
||||||
}
|
}
|
||||||
public function checkInSeqNo($current_msg_id)
|
public function checkInSeqNo($current_msg_id): void
|
||||||
{
|
{
|
||||||
$type = isset($this->incoming_messages[$current_msg_id]['content']['_']) ? $this->incoming_messages[$current_msg_id]['content']['_'] : '-';
|
$type = isset($this->incoming_messages[$current_msg_id]['content']['_']) ? $this->incoming_messages[$current_msg_id]['content']['_'] : '-';
|
||||||
if (isset($this->incoming_messages[$current_msg_id]['seq_no']) && ($seq_no = $this->generateInSeqNo($this->contentRelated($this->incoming_messages[$current_msg_id]['content']))) !== $this->incoming_messages[$current_msg_id]['seq_no']) {
|
if (isset($this->incoming_messages[$current_msg_id]['seq_no']) && ($seq_no = $this->generateInSeqNo($this->contentRelated($this->incoming_messages[$current_msg_id]['content']))) !== $this->incoming_messages[$current_msg_id]['seq_no']) {
|
||||||
@ -52,7 +52,7 @@ trait SeqNoHandler
|
|||||||
//$this->API->logger->logger("IN: $value + $in = ".$this->session_in_seq_no);
|
//$this->API->logger->logger("IN: $value + $in = ".$this->session_in_seq_no);
|
||||||
return $value * 2 + $in;
|
return $value * 2 + $in;
|
||||||
}
|
}
|
||||||
public function contentRelated($method)
|
public function contentRelated($method): bool
|
||||||
{
|
{
|
||||||
$method = \is_array($method) && isset($method['_']) ? $method['_'] : $method;
|
$method = \is_array($method) && isset($method['_']) ? $method['_'] : $method;
|
||||||
return \is_string($method) ? !\in_array($method, MTProto::NOT_CONTENT_RELATED) : true;
|
return \is_string($method) ? !\in_array($method, MTProto::NOT_CONTENT_RELATED) : true;
|
||||||
|
@ -91,7 +91,9 @@ trait FilesLogic
|
|||||||
* @param int $offset Offset where to start downloading
|
* @param int $offset Offset where to start downloading
|
||||||
* @param int $end Offset where to end download
|
* @param int $end Offset where to end download
|
||||||
*
|
*
|
||||||
* @return \Generator<bool>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, \Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<mixed>|mixed, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function downloadToStream($messageMedia, $stream, $cb = null, int $offset = 0, int $end = -1): \Generator
|
public function downloadToStream($messageMedia, $stream, $cb = null, int $offset = 0, int $end = -1): \Generator
|
||||||
{
|
{
|
||||||
@ -184,7 +186,9 @@ trait FilesLogic
|
|||||||
* @param string $fileName File name
|
* @param string $fileName File name
|
||||||
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
||||||
*
|
*
|
||||||
* @return \Generator<array>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\File\File>|array, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function uploadEncrypted($file, string $fileName = '', $cb = null): \Generator
|
public function uploadEncrypted($file, string $fileName = '', $cb = null): \Generator
|
||||||
{
|
{
|
||||||
@ -199,7 +203,9 @@ trait FilesLogic
|
|||||||
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
||||||
* @param boolean $encrypted Whether to encrypt file for secret chats
|
* @param boolean $encrypted Whether to encrypt file for secret chats
|
||||||
*
|
*
|
||||||
* @return \Generator<array>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int|mixed, \Amp\Promise|\Amp\Promise<\Amp\File\File>|\Amp\Promise<\Amp\Ipc\Sync\ChannelledSocket>|\Amp\Promise<int>|\Amp\Promise<mixed>|\Amp\Promise<null|string>|\danog\MadelineProto\Stream\StreamInterface|array|int|mixed, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function upload($file, string $fileName = '', $cb = null, bool $encrypted = false): \Generator
|
public function upload($file, string $fileName = '', $cb = null, bool $encrypted = false): \Generator
|
||||||
{
|
{
|
||||||
@ -251,7 +257,9 @@ trait FilesLogic
|
|||||||
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
* @param callable $cb Callback (DEPRECATED, use FileCallbackInterface)
|
||||||
* @param boolean $encrypted Whether to encrypt file for secret chats
|
* @param boolean $encrypted Whether to encrypt file for secret chats
|
||||||
*
|
*
|
||||||
* @return array
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int|mixed, \Amp\Promise|\Amp\Promise<int>|\Amp\Promise<null|string>|\danog\MadelineProto\Stream\StreamInterface|array|int|mixed, mixed, mixed>
|
||||||
*/
|
*/
|
||||||
public function uploadFromStream($stream, int $size, string $mime, string $fileName = '', $cb = null, bool $encrypted = false): \Generator
|
public function uploadFromStream($stream, int $size, string $mime, string $fileName = '', $cb = null, bool $encrypted = false): \Generator
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,9 @@ class RSA
|
|||||||
* @param TL $TL TL serializer
|
* @param TL $TL TL serializer
|
||||||
* @param string $rsa_key RSA key
|
* @param string $rsa_key RSA key
|
||||||
*
|
*
|
||||||
* @return \Generator<self>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<mixed, string, mixed, self>
|
||||||
*/
|
*/
|
||||||
public function load(TL $TL, string $rsa_key): \Generator
|
public function load(TL $TL, string $rsa_key): \Generator
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ class BufferedRawStream implements BufferedStreamInterface, BufferInterface, Raw
|
|||||||
/**
|
/**
|
||||||
* Async close.
|
* Async close.
|
||||||
*
|
*
|
||||||
* @return \Generator
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
|
@ -68,9 +68,11 @@ class UdpBufferedStream extends DefaultStream implements BufferedStreamInterface
|
|||||||
*
|
*
|
||||||
* @param int $length Length of payload, as detected by this layer
|
* @param int $length Length of payload, as detected by this layer
|
||||||
*
|
*
|
||||||
* @return Promise
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise, mixed, Failure<mixed>|Success<object>>
|
||||||
*/
|
*/
|
||||||
public function getReadBuffer(&$length): Promise
|
public function getReadBuffer(&$length): \Generator
|
||||||
{
|
{
|
||||||
if (!$this->stream) {
|
if (!$this->stream) {
|
||||||
return new Failure(new ClosedException("MadelineProto stream was disconnected"));
|
return new Failure(new ClosedException("MadelineProto stream was disconnected"));
|
||||||
|
@ -166,7 +166,7 @@ class HttpProxy implements RawProxyStreamInterface, BufferedProxyStreamInterface
|
|||||||
{
|
{
|
||||||
return $this->stream->write($data);
|
return $this->stream->write($data);
|
||||||
}
|
}
|
||||||
private function getProxyAuthHeader()
|
private function getProxyAuthHeader(): string
|
||||||
{
|
{
|
||||||
if (!isset($this->extra['username']) || !isset($this->extra['password'])) {
|
if (!isset($this->extra['username']) || !isset($this->extra['password'])) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -57,6 +57,9 @@ class DefaultStream implements RawStreamInterface, ProxyStreamInterface
|
|||||||
{
|
{
|
||||||
return $this->stream->setupTls($cancellationToken);
|
return $this->stream->setupTls($cancellationToken);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return EncryptableSocket
|
||||||
|
*/
|
||||||
public function getStream()
|
public function getStream()
|
||||||
{
|
{
|
||||||
return $this->stream;
|
return $this->stream;
|
||||||
|
@ -82,7 +82,7 @@ class PremadeStream implements RawStreamInterface, ProxyStreamInterface
|
|||||||
/**
|
/**
|
||||||
* Async close.
|
* Async close.
|
||||||
*
|
*
|
||||||
* @return \Generator
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function disconnect()
|
public function disconnect()
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ class PremadeStream implements RawStreamInterface, ProxyStreamInterface
|
|||||||
\danog\MadelineProto\Logger::log('Got exception while closing stream: '.$e->getMessage());
|
\danog\MadelineProto\Logger::log('Got exception while closing stream: '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function close()
|
public function close(): void
|
||||||
{
|
{
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace danog\MadelineProto\TL;
|
|||||||
|
|
||||||
trait TLParams
|
trait TLParams
|
||||||
{
|
{
|
||||||
public function parseParams($key, $mtproto = false)
|
public function parseParams($key, $mtproto = false): void
|
||||||
{
|
{
|
||||||
foreach ($this->by_id[$key]['params'] as $kkey => $param) {
|
foreach ($this->by_id[$key]['params'] as $kkey => $param) {
|
||||||
if (\preg_match('/(\\w*)\\.(\\d*)\\?(.*)/', $param['type'], $matches)) {
|
if (\preg_match('/(\\w*)\\.(\\d*)\\?(.*)/', $param['type'], $matches)) {
|
||||||
|
@ -665,7 +665,9 @@ abstract class Tools extends StrTools
|
|||||||
*
|
*
|
||||||
* @internal Generator function
|
* @internal Generator function
|
||||||
*
|
*
|
||||||
* @return \Generator<string>
|
* @return \Generator
|
||||||
|
*
|
||||||
|
* @psalm-return \Generator<int, Promise|Promise<null|string>, mixed, mixed|null>
|
||||||
*/
|
*/
|
||||||
public static function readLineGenerator(string $prompt = ''): \Generator
|
public static function readLineGenerator(string $prompt = ''): \Generator
|
||||||
{
|
{
|
||||||
@ -933,7 +935,8 @@ abstract class Tools extends StrTools
|
|||||||
*
|
*
|
||||||
* @psalm-suppress InvalidScope
|
* @psalm-suppress InvalidScope
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return void
|
||||||
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public static function setVar($obj, string $var, &$val): void
|
public static function setVar($obj, string $var, &$val): void
|
||||||
|
@ -13,7 +13,7 @@ function __coalesce($ifNotNull, $then)
|
|||||||
{
|
{
|
||||||
return $ifNotNull ?: $then;
|
return $ifNotNull ?: $then;
|
||||||
}
|
}
|
||||||
function __destructure($list, $value)
|
function __destructure($list, $value): array
|
||||||
{
|
{
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach ($list as $key) {
|
foreach ($list as $key) {
|
||||||
|
Loading…
Reference in New Issue
Block a user