From 2a80498542462ede3adcffb7b65eefd1ee60fdfe Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 19 Apr 2024 15:35:02 +0200 Subject: [PATCH] Fixes --- psalm-baseline.xml | 139 +++++++++++--------------- src/InternalDoc.php | 2 +- src/MTProtoTools/FilesAbstraction.php | 4 +- src/MTProtoTools/FilesLogic.php | 2 +- 4 files changed, 62 insertions(+), 85 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4253a9cdc..9411ec3c3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -611,9 +611,6 @@ - - - @@ -2231,77 +2228,6 @@ - - - wrapper->getAPI()->getEventHandler($class)]]> - - - - - - - - - wrapper->getAPI()->downloadToDir($messageMedia, $dir, $cb, $cancellation)]]> - wrapper->getAPI()->downloadToDir($messageMedia, $dir, $cb, $cancellation)]]> - wrapper->getAPI()->downloadToFile($messageMedia, $file, $cb, $cancellation)]]> - wrapper->getAPI()->downloadToFile($messageMedia, $file, $cb, $cancellation)]]> - wrapper->getAPI()->uploadFromCallable($callable, $size, $mime, $fileName, $cb, $seekable, $encrypted, $cancellation)]]> - wrapper->getAPI()->uploadFromCallable($callable, $size, $mime, $fileName, $cb, $seekable, $encrypted, $cancellation)]]> - wrapper->getAPI()->uploadFromTgfile($media, $cb, $encrypted, $cancellation)]]> - wrapper->getAPI()->uploadFromTgfile($media, $cb, $encrypted, $cancellation)]]> - wrapper->getAPI()->uploadFromUrl($url, $size, $fileName, $cb, $encrypted, $cancellation)]]> - wrapper->getAPI()->uploadFromUrl($url, $size, $fileName, $cb, $encrypted, $cancellation)]]> - - - account ??= new \danog\MadelineProto\Namespace\AbstractAPI('account')]]> - auth ??= new \danog\MadelineProto\Namespace\AbstractAPI('auth')]]> - bots ??= new \danog\MadelineProto\Namespace\AbstractAPI('bots')]]> - channels ??= new \danog\MadelineProto\Namespace\AbstractAPI('channels')]]> - chatlists ??= new \danog\MadelineProto\Namespace\AbstractAPI('chatlists')]]> - contacts ??= new \danog\MadelineProto\Namespace\AbstractAPI('contacts')]]> - folders ??= new \danog\MadelineProto\Namespace\AbstractAPI('folders')]]> - fragment ??= new \danog\MadelineProto\Namespace\AbstractAPI('fragment')]]> - help ??= new \danog\MadelineProto\Namespace\AbstractAPI('help')]]> - langpack ??= new \danog\MadelineProto\Namespace\AbstractAPI('langpack')]]> - messages ??= new \danog\MadelineProto\Namespace\AbstractAPI('messages')]]> - payments ??= new \danog\MadelineProto\Namespace\AbstractAPI('payments')]]> - phone ??= new \danog\MadelineProto\Namespace\AbstractAPI('phone')]]> - photos ??= new \danog\MadelineProto\Namespace\AbstractAPI('photos')]]> - premium ??= new \danog\MadelineProto\Namespace\AbstractAPI('premium')]]> - smsjobs ??= new \danog\MadelineProto\Namespace\AbstractAPI('smsjobs')]]> - stats ??= new \danog\MadelineProto\Namespace\AbstractAPI('stats')]]> - stickers ??= new \danog\MadelineProto\Namespace\AbstractAPI('stickers')]]> - stories ??= new \danog\MadelineProto\Namespace\AbstractAPI('stories')]]> - updates ??= new \danog\MadelineProto\Namespace\AbstractAPI('updates')]]> - upload ??= new \danog\MadelineProto\Namespace\AbstractAPI('upload')]]> - users ??= new \danog\MadelineProto\Namespace\AbstractAPI('users')]]> - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4112,18 +4038,47 @@ + + methodCallAsyncRead( $method, $params )]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4134,6 +4089,19 @@ + + + + + + + + + + + + + @@ -4180,13 +4148,9 @@ - - - - @@ -5147,6 +5111,14 @@ + + + + + + + + @@ -6433,6 +6405,14 @@ + + + + + + + + @@ -7909,9 +7889,6 @@ pluginInstances[$class]]]> pluginInstances[$class]]]> - - - diff --git a/src/InternalDoc.php b/src/InternalDoc.php index 754961dd3..127bbe501 100644 --- a/src/InternalDoc.php +++ b/src/InternalDoc.php @@ -2120,7 +2120,7 @@ abstract class InternalDoc /** * Upload file. * - * @param FileCallbackInterface|LocalFile|RemoteUrl|BotApiFileId|string|array|resource $file File, URL or Telegram file to upload + * @param FileCallbackInterface|LocalFile|RemoteUrl|BotApiFileId|ReadableStream|string|array|resource $file File, URL or Telegram file to upload * @param string $fileName File name * @param callable $cb Callback * @param boolean $encrypted Whether to encrypt file for secret chats diff --git a/src/MTProtoTools/FilesAbstraction.php b/src/MTProtoTools/FilesAbstraction.php index bf6ba9936..57e8a3926 100644 --- a/src/MTProtoTools/FilesAbstraction.php +++ b/src/MTProtoTools/FilesAbstraction.php @@ -1047,10 +1047,10 @@ trait FilesAbstraction } $p->getSink()->close(); $p->getSource()->close(); - unset($p); $mimeType ??= (new finfo())->buffer($buff, FILEINFO_MIME_TYPE); }); + unset($p); } $fileFuture = async(fn () => $this->upload(new StreamDuplicator($file, ...$streams), $fileName ?? '', $callback, cancellation: $cancellation)); @@ -1116,10 +1116,10 @@ trait FilesAbstraction } $p->getSink()->close(); $p->getSource()->close(); - unset($p); $mimeType ??= (new finfo())->buffer($buff, FILEINFO_MIME_TYPE); }); + unset($p); } $fileFuture = async(fn () => $this->upload(new StreamDuplicator($file, ...$streams), $fileName ?? '', $callback, cancellation: $cancellation)); diff --git a/src/MTProtoTools/FilesLogic.php b/src/MTProtoTools/FilesLogic.php index c5eb07111..375f6da1c 100644 --- a/src/MTProtoTools/FilesLogic.php +++ b/src/MTProtoTools/FilesLogic.php @@ -302,7 +302,7 @@ trait FilesLogic /** * Upload file. * - * @param FileCallbackInterface|LocalFile|RemoteUrl|BotApiFileId|string|array|resource $file File, URL or Telegram file to upload + * @param FileCallbackInterface|LocalFile|RemoteUrl|BotApiFileId|ReadableStream|string|array|resource $file File, URL or Telegram file to upload * @param string $fileName File name * @param callable $cb Callback * @param boolean $encrypted Whether to encrypt file for secret chats